Merging multiple shapefiles into one shapefile using python and GeoPandas

Combine multiple shapefiles into one shapefile using python and GeoPandas

GeoPandas is one of the most famous python GIS library that can automate your GIS workflows. GeoPandas provides good functionality and features to create really good geoprocessing tools like geospatial analysis, reading/writing from/to postgis database, transforming GIS data between different formats etc.

In this tutorial, we will learn how to merge multiple shapefiles into one shapefiles using geopandas. We will follow following steps to achieve this task.

  1. Import geopandas library.
  2. Read shapefiles using geopandas that you want to merge. At line number 4 and 5, we are reading multiple shapefiles. You can read as many as you want.
  3. Bring all those shapefiles into one common coordinate system. In this example, we converting the shapefiles into 4326 coordinate system. There may be a chance the shapefiles you are trying to merge are in different coordinate system.
  4. Use gpd.pd.concat method in line number 12 in below code snippet to concat multiple shapefiles into one. This particular magic line of code will get job done for us.
  5. Export the merged geodataframe into shapefile.
  6. Hurray, you have successfully merge multiple shapefiles into one.

You don’t have to worry about any column difference between shapefiles. This method will automatically insert null values for shapefile which does not have common column.

We also offer freelancing services. Please email us at contact@spatial-dev.guru for any query.

Leave a ReplyCancel reply

Discover more from Spatial Dev Guru

Subscribe now to keep reading and get access to the full archive.

Continue reading

Discover more from Spatial Dev Guru

Subscribe now to keep reading and get access to the full archive.

Continue reading