The basics of the work with programming languages involve getting your hands dirty with libraries. This implies entering a completely different world, where the Dewey Decimal system does not play a significant role.
To clarify what libraries are, we need some definitions first of key terms. Then, off to the discovery of libraries for geospatial data analysis, my growing passion.
First, some definitions
What is the difference between library, package, module, and framework? Mohammed Ibrahim provides a cool analogy for each. He says a module is the fingers of a hand. A package is the hand that controls the module (fingers). The library is comparable to building your own house, while a framework is an already built house. It’s pretty straightforward.
- A module is a part of the script we are writing, and it contains a number of routines. Modules include functions, variables, data structures, etc.
- Related modules form up a package. Packages provide a way of structuring and reusing functionality across different projects.
- “Packages” and “libraries” are sometimes used interchangeably because they involve using pre-existing code to do specific tasks.
My interest in geospatial analysis brought me in front of libraries used for that end: geopandas, folium, ipyleaflet, rasterio, rasterstats, shapely, Fiona, arcpy, RSGISLib, and others. I chose one to dive into.

A library for geospatial analysis
The first wall I hit was with Geopandas. Who are “Geopandas”? Well, the question is a bit distorting, I admit. Geopandas is the geospatial extension of the pandas library. Pandas library manipulates data. Geopandas manipulates geospatial data, meaning data with spatial geometry information. Here are a few main aspects of Geopandas.
- It presents 2 of the most used data structures (storage used to organize and store data): Geoseries (one-dimensional array-like) and Geodataframe (two-dimensional tabular data).
- Geopandas reads and writes geospatial data format, meaning vector data, in different formats: Shapefiles, GeoJSON, GeoPackage, etc.)
- Geospatial data can be plotted and visualized using geopandas. Not alone, geopandas must be integrated with MatplotLib (used for creating static, animated, and interactive visualizations in Python).
- Geopandas allows handling coordinate reference system (CRS). We can reproject data to different CRS. CartoPy library and Geopandas can do significant work when it comes to projection.
Example of scripts using Geopandas
To read a shapefile, its Coordinate Reference System (CRS), and its geometry type:
import geopandas as gpd
#Read a shapefile
file_path = ‘path/to/your/shapefile.shp’
gdf = gpd.read_file(file_path)
#Access and print the CRS information
crs_info = gdf.crs
print(“Coordinate Reference System (CRS) information:”)
print(crs_info)
#Access and print the geometry types
geometry_types = gdf.geom_type
print(“Geometry Types:”)
print(geometry_types)
#Display the GeoDataFrame
print(gdf.head())
Leave a comment