I have a GeoPandas GeoDataFrame
with a geometry
column that contains both POLYGON
s and MULTIPOLYGON
s. How do I filter only MULTIPOLYGON
s?
I used this approach, but I am sure there might be better ones:
# 'at' because it's data about Austria
at_geometries.loc[at_geometries["geometry"].astype("str").str.startswith("MULTI")]
Best Answer
There are many solutions (see How to filter a geodataframe by geometry type? for example)
With
.loc
as you but withgeometry.type
orgeom_type
With
apply
,lambda
andtype
With
geom_type
With
geometry.type
as Kadir Şahbaz