Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Publishing dataframe with missing geometry via the GeoAccessor causes inconsistent behavior

See original GitHub issue

Describe 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)
# returns: <FeatureCollection>

# returns: arcgis.features.feature.FeatureCollection

s ='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
----> 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/ 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/ in import_data(self, df, address_fields, folder, item_id, **kwargs)
   4935             if item_id:
   4936                 postdata['itemIdToCreate'] = item_id
-> 4937             res =, postdata)#, use_ordered_dict=True) - OrderedDict >36< PropertyMap
   4939             fc = FeatureCollection(res['featureCollection']['layers'][0])

/usr/local/anaconda3/envs/spark/lib/python3.7/site-packages/arcgis/gis/_impl/_con/ 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/ 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/ in _handle_json_error(self, error, errorcode)
    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

  1. Return type should be: arcgis.features.layer.FeatureLayer
  2. Feature layer should be published to org/portal, respecting given parameters (title, folder, tags, gis).
  3. Publishing behavior/responses should (ideally) be consistent across AGOL/Portal
  4. If there is a problem with the DataFrame or publishing process, publishing/conversion should fail noisily

From the docs:

- 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:

Conda env.yml (as .txt): env.txt

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

achapkowskicommented, Aug 28, 2020

Does gis.content.import_data work with the SeDF?

nanaeaubrycommented, Mar 17, 2022

Fixed in 2.0.0

Read more comments on GitHub >

github_iconTop Results From Across the Web

Geoaccessor.from_df - Esri Community
I am trying to convert a pandas dataframe that contains geometry (started from a feature class) to a spatially enabled dataframe using the ......
Read more >
Behavioral Inconsistencies Do Not Imply Inconsistent Strategies
Although inconsistent behavior presents a problem for the notion of stable preferences, for the framework of heuristics it does not.
Read more >
Data Engineering with Spatially Enabled DataFrames and ...
The ArcGIS API for Python adds spatial capabilities to these DataFrames using an elegant accessor model. With these DataFrames, you can not ...
Read more >
Inconsistent Mathematics - Internet Encyclopedia of Philosophy
A theory containing every sentence is trivial. Classical logic therefore makes nonsense of inconsistency and is inappropriate for inconsistent mathematics.
Read more >
When Your Boss Is Under Pressure: On the Relationships ...
Under stress, positive leader behaviors such as transformational leadership may ... inconsistency and volatility in leaders' behavior across ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found