Open darribas opened 11 months ago
Yes. Should be a straight swap to shapely!
One fewer dependency for the book would be great. Here is a proposed update for this.
For the minimum rotated rectangle, we will use the minimum_rotated_rectangle
function from the pygeos
module, which constructs the minimum rotated rectangle for an input multi-point object. This means that we will need to collect our points together into a single multi-point object and then compute the rotated rectangle for that object.
from pygeos import minimum_rotated_rectangle, from_shapely, to_shapely
point_array = geopandas.points_from_xy(x=user.x, y=user.y)
min_rot_rect = minimum_rotated_rectangle(
from_shapely(
point_array.unary_union()
)
)
min_rot_rect = to_shapely(min_rot_rect)
For the minimum rotated rectangle, we will use the minimum_rotated_rectangle
property from GeoPandas, which constructs the minimum rotated rectangle for an input multi-point object. This means that we will need to collect our points together into a single multi-point object and then compute the rotated rectangle for that object.
point_array = geopandas.points_from_xy(x=user.x, y=user.y)
min_rot_rect = point_array.unary_union().minimum_rotated_rectangle
Chapter 8 (points) includes imports from
pygeos
:My sense is, since
shapely
2.0, general recommendation is to rely onshapely
rather thanpygeos
directly. Should we update this? One probably more for @ljwolf