Publishing dataframe with missing geometry via the GeoAccessor causes inconsistent behavior
See original GitHub issueDescribe the bug
When using GeoAccessor.to_featurelayer, I get a FeatureCollection returned and the dataframe is not published to a feature layer (ArcGIS Online) or the process throws error code 500 (Portal 10.7.1).
To Reproduce Steps to reproduce the behavior:
from arcgis.features import GeoAccessor
lyr = df.spatial.to_featurelayer('dwelling events', gis=agol)
lyr
# returns: <FeatureCollection>
type(lyr)
# returns: arcgis.features.feature.FeatureCollection
s = agol.content.search('dwelling events'); s
# returns: [ ]
Note: when passing a GIS object connected to a 10.7.1 Portal as the gis
parameter, throws 500 internal server error:
---------------------------------------------------------------------------
Exception Traceback (most recent call last)
<ipython-input-51-f6f9e09801c1> in <module>
1 from arcgis.features import GeoAccessor
2
----> 3 lyr = final_df.spatial.to_featurelayer("dwelling_events", gis=gis)
4 lyr
/usr/local/anaconda3/envs/spark/lib/python3.7/site-packages/arcgis/features/geo/_accessor.py in to_featurelayer(self, title, gis, tags, folder)
2132 raise ValueError("GIS object must be provided")
2133 content = gis.content
-> 2134 return content.import_data(self._data, folder=folder, title=title, tags=tags)
2135 # ----------------------------------------------------------------------
2136 @staticmethod
/usr/local/anaconda3/envs/spark/lib/python3.7/site-packages/arcgis/gis/__init__.py in import_data(self, df, address_fields, folder, item_id, **kwargs)
4935 if item_id:
4936 postdata['itemIdToCreate'] = item_id
-> 4937 res = self._portal.con.post(path, postdata)#, use_ordered_dict=True) - OrderedDict >36< PropertyMap
4938
4939 fc = FeatureCollection(res['featureCollection']['layers'][0])
/usr/local/anaconda3/envs/spark/lib/python3.7/site-packages/arcgis/gis/_impl/_con/_connection.py in post(self, path, params, files, **kwargs)
708 file_name=file_name,
709 try_json=try_json,
--> 710 force_bytes=kwargs.pop('force_bytes', False))
711 #----------------------------------------------------------------------
712 def put(self, url, params=None, files=None, **kwargs):
/usr/local/anaconda3/envs/spark/lib/python3.7/site-packages/arcgis/gis/_impl/_con/_connection.py in _handle_response(self, resp, file_name, out_path, try_json, force_bytes)
503 if 'error' in data:
504 errorcode = data['error']['code'] if 'code' in data['error'] else 0
--> 505 self._handle_json_error(data['error'], errorcode)
506 return data
507 else:
/usr/local/anaconda3/envs/spark/lib/python3.7/site-packages/arcgis/gis/_impl/_con/_connection.py in _handle_json_error(self, error, errorcode)
521
522 errormessage = errormessage + "\n(Error Code: " + str(errorcode) +")"
--> 523 raise Exception(errormessage)
524 #----------------------------------------------------------------------
525 def post(self,
Exception: Internal Server Error
(Error Code: 500)
Expected behavior
- Return type should be: arcgis.features.layer.FeatureLayer
- Feature layer should be published to org/portal, respecting given parameters (title, folder, tags, gis).
- Publishing behavior/responses should (ideally) be consistent across AGOL/Portal
- If there is a problem with the DataFrame or publishing process, publishing/conversion should fail noisily
From the docs:
to_featurelayer
- publishes a spatial dataframe to a Feature Layer
Argument | Description
-----------------------
title - Required string. The name of the service
gis - Optional GIS. The GIS connection object
tags - Optional list of strings. A comma seperated list of descriptive words for the service.
folder - Optional string. Name of the folder where the featurelayer item and imported data would be stored.
returns FeatureLayer
Platform (please complete the following information):
- OS: macOS Catalina
- Browser [e.g. chrome, safari]: Chrome
- Python API Version: 1.8.2
Additional context Potentially related to #682
The DataFrame is the output of a notebook almost identical to this one for finding dwell locations put out by the tracker team, but executed on some of the natural resources team’s tracks and polygons
Zipped pickle of the DataFrame: df.zip
Conda env.yml (as .txt): env.txt
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
Does gis.content.import_data work with the SeDF?
Fixed in 2.0.0