Skip to content

Instantly share code, notes, and snippets.

View dimzog's full-sized avatar
🎯
Focusing

dimzog

🎯
Focusing
View GitHub Profile
@dimzog
dimzog / geopandas_convert_geometry_3D_2D.py
Created June 2, 2021 08:26 — forked from rmania/geopandas_convert_geometry_3D_2D.py
flatten geometry series (3D to 2D) in geopandas dataframe
# Often when reading in a ShapeFile from Basemap, you'll get: "ValueError: readshapefile can only handle 2D shape types"
# A trick can be to convert your geometry in your GeoPandas Dataframe and restoring the new flattened 2D geometry
# series back into a shapefile and try again.
# edit from http://stackoverflow.com/questions/33417764/basemap-readshapefile-valueerror
from shapely.geometry import Polygon, MultiPolygon, shape, Point
import geopandas as gp
def convert_3D_2D(geometry):
'''