We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
When generating geojson geometry from shapely the coordinates are tuples and so geojson_rewind fails when it tries to modify the coordinates
from shapely.geometry import Polygon, mapping import geojson_rewind p = Polygon([(0, 0), (1, 1), (1, 0)]) data = mapping(p) print(data) data = geojson_rewind.rewind(data) print(data)
{'type': 'Polygon', 'coordinates': (((0.0, 0.0), (1.0, 1.0), (1.0, 0.0), (0.0, 0.0)),)} Traceback (most recent call last): File "rewind.py", line 9, in <module> data = geojson_rewind.rewind(data) File "/.../python3.7/site-packages/geojson_rewind/rewind.py", line 15, in rewind return _rewind(gj, rfc7946) File "/.../python3.7/site-packages/geojson_rewind/rewind.py", line 31, in _rewind return correct(gj, rfc7946) File "/.../python3.7/site-packages/geojson_rewind/rewind.py", line 36, in correct feature['coordinates'] = correctRings(feature['coordinates'], rfc7946) File "/.../python3.7/site-packages/geojson_rewind/rewind.py", line 49, in correctRings rings[0] = wind(rings[0], clockwise) TypeError: 'tuple' object does not support item assignment ``
The text was updated successfully, but these errors were encountered:
Quick solution - dump it to JSON, which will convert the tuples to js arrays
import json from shapely.geometry import Polygon, mapping import geojson_rewind p = Polygon([(0, 0), (1, 1), (1, 0)]) data = mapping(p) print(data) data = geojson_rewind.rewind(json.dumps(data)) print(data)
if you want a python dict as output rather than a JSON string, you can json.loads() it again.
json.loads()
data = geojson_rewind.rewind(json.loads(json.dumps(data))) print(data)
or
data = geojson_rewind.rewind(json.dumps(data)) print(json.loads(data))
would both work.
Sorry, something went wrong.
thanks, I had the same idea as a workaround. Just letting you know about this situation in case you want to support it properly
No branches or pull requests
When generating geojson geometry from shapely the coordinates are tuples and so geojson_rewind fails when it tries to modify the coordinates
The text was updated successfully, but these errors were encountered: