FeatureSet.from_geojson Fails on MultiPolygons
See original GitHub issueWhile responding to a GeoNet thread, FeatureSet.from_geojson bug?, I was able to verify a defect in FeatureSet.from_geojson with MultiPolygon.
Using a basic MultiPolygon example from GeoJSON - Wikipedia, you can generate an error:
>>> from arcgis.features import FeatureSet
>>>
>>> geojson_multipolygon = {
... "type": "FeatureCollection",
... "features": [{
... "type": "Feature",
... "geometry" : {
... "type": "MultiPolygon",
... "coordinates": [
... [[[30, 20], [45, 40], [10, 40], [30, 20]]],
... [[[15, 5], [40, 10], [10, 20], [5, 10], [15, 5]]]
... ]
... },
... "properties": {
... "name": "Wikipedia MultiPolygon example"
... }
... }]
... }
>>>
>>> FeatureSet.from_geojson(geojson_multipolygon)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\features\feature.py", line 922, in from_geojson
return FeatureSet.from_dict(geo_to_esri(geojson))
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\features\feature.py", line 826, in geo_to_esri
esri["features"] = list(esri_features)
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\features\feature.py", line 832, in extract
geometry = get_geometry(feature)
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\features\feature.py", line 880, in get_geometry
geometry = Geometry(json.loads(geom))
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\json\__init__.py", line 348, in loads
'not {!r}'.format(s.__class__.__name__))
TypeError: the JSON object must be str, bytes or bytearray, not 'Polygon'
>>>
Using the polygon with a hole example from GeoJSON - Wikipedia , the method works fine:
>>> from arcgis.features import FeatureSet
>>>
>>> geojson_polygon = {
... "type": "FeatureCollection",
... "features": [{
... "type": "Feature",
... "geometry": {
... "type": "Polygon",
... "coordinates": [
... [[35, 10], [45, 45], [15, 40], [10, 20], [35, 10]],
... [[20, 30], [35, 35], [30, 20], [20, 30]]
... ]
... },
... "properties": {
... "name": "Wikipedia Polygon example with hole"
... }
... }]
... }
>>>
>>> FeatureSet.from_geojson(geojson_polygon)
<FeatureSet> 1 features
>>>
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
FeatureSet.from_geojson bug? - Esri Community
When calling FeatureSet.from_geojson (ArcGIS API for Python) in an ArcGIS ... Using a basic MultiPolygon example from GeoJSON - Wikipedia, ...
Read more >QGIS/GeoJSON: Dissolve featurecollection consisting of ...
Do a dissolve (vector --> geoprocessing tools --> dissolve). Then all the normal polygons get merged into a giant multipolygon, but not the ......
Read more >Bokeh is not rendering properly multipolygon (islands) from ...
My geodata is an GeoJSON with Polygons and MultiPolygons. I have trouble rendering the Multipolygons: If I extract all geometries of an feature ......
Read more >GeoJSONLayer | ArcGIS Maps SDK for JavaScript 4.25
Set featureEffect property if different effects need to be applied features that meet or fail a specified filter. If all of the following...
Read more >Geography functions | BigQuery - Google Cloud
See ST_GEOGFROMGEOJSON to construct a GEOGRAPHY from GeoJSON. ... Pre-GA products and features may have limited support, and changes to pre-GA products and ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It will be fixed in the next release. That is why it was closed.
@achapkowski , I see this with ArcPy from Pro 2.6 installed as well.
Esri Support was able to reproduce the defect with ArcPy installed as well, and the following Esri Support bug was logged: