Accessing Geospatial Data with PyShp, Shapely and Fiona (2024)

The new 1.5 version of the ArcGIS API for Python integrates the PyShp, Shapely and Fiona packages, so that vector data from other libraries can be accessed through the API as well. Let’s have a look at the these three Python libraries and how they are used within the latest version of the API for Python.

Users familiar with open source spatial Python libraries will be very happy to know that the Esri API for Python 1.5 version can read spatial data from multiple sources, thanks to the integration of these three Python libraries for using shapefile data. This makes it easier to use the API and work with geospatial data regardless of the platform used.

Shapely

This Python library is used for manipulation and analysis of geometric objects. It can be described as a more Pythonic version of the OGR library, that has mainly the same functions and classes as Shapely. OGR is part of GDAL, a popular open source library that deals with vector data. It is very powerful and is used by many geospatial applications. However, OGR was written in C++ and is available in Python through a set of Python bindings: using it will feel strange, as it doesn’t follow the Python syntax rules.

Shapely uses its own geometry types that are stored as classes in the library’s geometry module: the available classes are points, multi points, line strings, multiline strings, linear rings, polygons, multi polygons and geometry collections. Using Shapely, you can manipulate and analyze the geometries of these different classes using geometry functions such as “buffer”, “intersects” and “contains”.

With regards to the Esri API for Python, consulting the Documentation shows that a large number of properties and functions from the Shapely library are valid on the API’s new data object called Spatially Enabled DataFrame (SEDF). When creating a spatial object from a SEDF, the API will first leverage the arcpy geometry engine, then shapely.

Fiona

This Python library can be used for reading and writing spatial vector data formats. It is often used in combination with Shapely, so that Fiona is used for creating the input and output, while Shapely does the “data wrangling” part in between. Fiona uses two markup languages worth knowing: WKT and WKB, Well-known Text and Well-known Binary. These formats allow for interchanging geographical objects between different GIS programs. With regards to the Esri Python API for Python, both are valid properties on Spatially Enabled DataFrame objects.

pyshp

This full name of this Python library is Python Shapefile Library. Its use is quite limited: it is meant for reading and writing shapefiles. The Esri API for Python uses it to read and write shapefiles when it cannot find a local installation of the arcpy site package.

Accessing Geospatial Data with PyShp, Shapely and Fiona (2024)

FAQs

What is the difference between shapely and Fiona? ›

This Python library can be used for reading and writing spatial vector data formats. It is often used in combination with Shapely, so that Fiona is used for creating the input and output, while Shapely does the “data wrangling” part in between.

Which plot library is an excellent choice for geospatial data visualization and helps to create interactive and customizable maps? ›

Geoplot. Geoplot is a Python library that provides a high-level interface for creating various map types. It simplifies the process of visualizing geospatial data. Geoplot offers an easy way to create choropleth maps, scatter plots on maps, and other geospatial visualizations.

How to read shapefile in Python geopandas? ›

Reading a Shapefile
  1. In [2]: # Import necessary modules import geopandas as gpd # Set filepath fp = "L2_data/DAMSELFISH_distributions.shp" # Read file using gpd.read_file() data = gpd. ...
  2. type(data)
  3. Out[3]: geopandas.geodataframe.GeoDataFrame.
  4. print(data. head(2))
  5. %matplotlib inline data. plot()
  6. Out[7]:

What is fiona in Python? ›

Fiona provides uncomplicated Python interfaces to functions in OGR, the best open source C/C++ library for reading and writing geographic vector data. Fiona is designed to be simple and dependable.

What does shapely figure mean? ›

Definitions of shapely. adjective. having a well-proportioned and pleasing shape. “a slim waist and shapely legs” synonyms: bosomy, busty, buxom, curvaceous, curvy, full-bosomed, sonsie, sonsy, stacked, voluptuous, well-endowed.

Can GeoPandas read kmz files? ›

If the file is a KML, we can easily import it using geopandas with just a few lines of code. However, when dealing with a KMZ file, we require additional dependencies and a slightly more intricate procedure.

Can GeoPandas read GeoPackage? ›

Reading files

Assuming you have a file containing both data and geometry (e.g. GeoPackage, GeoJSON, Shapefile), you can read it using geopandas.

What kind of files can GeoPandas read? ›

GeoPandas can read almost any vector-based spatial data format including ESRI shapefile, GeoJSON files and more using the geopandas. read_file() command: geopandas.

Does Fiona require GDAL? ›

Fiona depends on GDAL but is different from GDAL's own bindings.

Why is it called Fiona? ›

Fiona originates from the Gaelic word fionn, meaning white or fair, being a Latinised form; or an Anglicisation of the Irish name Fíona meaning vine. In ninth-century Welsh and Breton language Fion (today: ffion) referred to the foxglove species and is also a female given name as in Ffion Hague.

Which command is used to install the Fiona? ›

Once GDAL and its dependencies are installed on your computer (how to do this is documented at https://gdal.org) Fiona can be built and installed using setuptools or pip. If your GDAL installation provides the gdal-config program, the process is simpler. With pip (version >= 22.3 is required):

How do I view shapefile data? ›

You can access a shapefile in ArcGIS Pro using a folder connection in the Catalog pane.
  1. Add a connection to a folder.
  2. Browse to the location of the shapefile in the folder connection.
  3. Right-click the shapefile and click Add To Current Map or point to Add To New and click Map .

How to visualize a shape file? ›

How to Open a Shapefile? Geographic Information Systems (GIS) software is typically required to open and view a shapefile. There are a few popular options that range from free to thousands of dollars per year. Equator is free and easy to use (no installation required), just click on “Go To Viewer” to give it a try.

How to extract shapefile from GIS? ›

To export a shapefile from the Catalog pane, right-click the shapefile, select Export.

What is the difference between SHX and SHP files? ›

shp : the file that contains the geometry for all features. . shx : the file that indexes the geometry.

Top Articles
Latest Posts
Article information

Author: Dong Thiel

Last Updated:

Views: 6222

Rating: 4.9 / 5 (59 voted)

Reviews: 90% of readers found this page helpful

Author information

Name: Dong Thiel

Birthday: 2001-07-14

Address: 2865 Kasha Unions, West Corrinne, AK 05708-1071

Phone: +3512198379449

Job: Design Planner

Hobby: Graffiti, Foreign language learning, Gambling, Metalworking, Rowing, Sculling, Sewing

Introduction: My name is Dong Thiel, I am a brainy, happy, tasty, lively, splendid, talented, cooperative person who loves writing and wants to share my knowledge and understanding with you.