Short answer everything works as intended - thank you again. FWIW the github link to min_bounding_rect.py
returns identical return as geom.minimum_rotated_rectangle
.
Long answer is that the KML writer enforces geographic coordinates, which I did not know. So QGIS' project on the fly visually was not showing a true rectangle versus the underlying (in my case) local UTM. I had done quick tests with min_bounding_rect.py
at large scales only, and tests with minimum_rotated_rectangle
at small scale only. Obviously at large scale the difference in the projection were not as noticeable so the two calls appeared to have different results. Using the same projections for minimum rectangle and the underlying in a non-KML format works as intended.
apply
and 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 query_bulk
.
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.
warnings
python 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'][0]), 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))
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)
try to get your coordinates in a structure like this