-
Notifications
You must be signed in to change notification settings - Fork 572
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
Shapely 2.0 doesn't accept Decimal Fields in the Polygon constructor. #1707
Comments
The root of the issue that is that NumPy doesn't recognize Not sure if this is a known limitation. |
I'm very comfortable with the answer being "we've dropped Decimal support for Polygons, you'll have to cast", but I do want to make sure that it is a known regression from this new release and should either be fixed or documented somewhere. |
I think it is a low effort to keep supporting So I am 👍 of fixing the regression. |
I could make a PR to fix this, but I need someone to review my PRs... |
Yeah, it seems that ctypes (or cython, for functions that had a speedups version) automatically converted Decimals to floats where needed. Also +1 on keeping a general conversion to float for individual coordinates in the class constructors. We currently have this function in several places (for linestrings/linearring): shapely/shapely/geometry/polygon.py Lines 86 to 91 in 5a3d023
We can probably update the
I am prioritizing issues/PRs for 2.0.1, so yes you can be ensured to get a review. |
I landed here because my app reads billions of GeoJSON items and converts the feature items to shapes for geoprocessing. I use It appears that with open(geojson) as f:
for item in ijson.items(f, 'features.item'):
geom = item['geometry']
shape = geometry.shape(geom) Into this: with open(geojson) as f:
for item in ijson.items(f, 'features.item', use_float=True):
geom = item['geometry']
shape = geometry.shape(geom) Since my GeoJSON is lat/lon decimal degrees with at least 8-digits of precision, we don't care about eliminating the floating point drift as its buried well below the perceivable accuracy on our maps. And now Just passing this info on as an FYI... |
@dotysan thanks for the heads up about that! Apart from speed, it also makes sense to directly keep floats (and not convert to Decimal), since shapely (GEOS) would otherwise convert the coordinates to floating point values anyway. |
Expected behavior and actual behavior.
Before the Shapely 2.0 update our code worked:
now it returns a:
ValueError: Inconsistent coordinate dimensionality
I've run this also with the latest on master and gotten the same result. We are able to mitigate this by casting the Decimals to floats, but I'd rather not if this is truly a regression and not an intended change.
now it
Steps to reproduce the problem.
Operating system
Ubuntu 22.04.1 LTS, but also recreated in a python docker image
Shapely version and provenance
shapely==2.0.0 installed from PyPI using pip
The text was updated successfully, but these errors were encountered: