Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Vectorized version of shape #1993

Open
cheginit opened this issue Feb 16, 2024 · 0 comments
Open

Feature Request: Vectorized version of shape #1993

cheginit opened this issue Feb 16, 2024 · 0 comments

Comments

@cheginit
Copy link

Currently, shapely.geometry.shape only works with single objects. It'd be great, if it also accepts an array of geojson dicts and made vectorized.

Currently, this is my workaround:

import rasterio.features as rio_features
from shapely.geometry import shape as geojson2geom
import numpy as np

shapes = rio_features.shapes(...)
geojsons, _ = zip(*shapes)
geoms = np.vectorize(geojson2geom)(geojsons)

Also, I think once it's vectorized, it can be added to the top-level namespaces and renamed to something more descriptive, maybe?

Ideally, the vectorized version can be called like so:

import rasterio.features as rio_features
import shapely

shapes = rio_features.shapes(...)
geojsons = (g for g, _ in shapes)
geoms = shapely.geojson2geom(geojsons)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant