applyand try to rely as much as you can on built-in GeoSeries methods. If needed use the underlying array of pygeos geometries directly with pygeos functions. You can access it as
gdf.geometry.values.data. When you can use numpy functions instead of for loops, use them. Look up some vectorization guide for pandas, the rules are fairly similar. And when using spatial index, use
get_geometry), but we've been adding more functions to vectorize the most common operations where you would get these back as ragged arrays (e.g.,
get_parts), where there are varying numbers of geometries within arrays of multi / geometry collections.
UserWarning: The Shapely GEOS version (3.8.0-CAPI-1.13.1 ) is incompatible with the GEOS version PyGEOS was compiled with (3.9.0-CAPI-1.16.2). Conversions between both will be slow.
warningspython package, you can filter that specific UserWarning
GeoDataFrame? I'm trying to quickly make many simple plots at once. I've tried variations on the following, but it feels a bit hacky.
for feature in gdf.iterfeatures(): temp = gpd.GeoSeries(Point(*feat['geometry']['coordinates']), crs=gdf.crs) ax = temp.plot(figsize=(20, 20), color='red', marker='o', alpha=0.9) ctx.add_basemap(ax=ax) fig = ax.get_figure() fig.savefig('.../out/path/...')
x_coords = np.array([[1, 2, 3], [4, 5, 6]]) y_coords = np.array([[1, 2, 3], [4, 5, 6]]) pygeos.polygons(pygeos.linearrings(x_coords, y=y_coords))
try to get your coordinates in a structure like this
array([<pygeos.Geometry POLYGON ((1 1, 2 2, 3 3, 1 1))>, <pygeos.Geometry POLYGON ((4 4, 5 5, 6 6, 4 4))>], dtype=object)
numpy, but I can be wrong