1

I have an ArcGIS Online hosted featurelayer that is used to collect data through ArcGIS Field Maps. Data is collected on a yearly basis, and after each year, I create a copy of the hosted feature layer. The new copy each year drops all of the collected values but maintains geometry, OID, et cetera. Collection fields to be reset are of type String, int, double.

When attempting to create a dataframe using ArcGIS API for Python,

sdf = pd.DataFrame.spatial.from_layer(COLLECTION_LAYER)

COLLECTION_LAYER is arcgis.gis.Layer instance pointing to my data collection table.

I'm thrown an IntCastingNaNError with message;

Exception: Could not load the dataset: Cannot convert non-finite values (NA or inf) to integer

because I am attempting to create a numpy array / pandas series of type int where all / most of the values are None.

I've tried to find a workaround using pd.df.fillnan() but I am unable to instantiate the dataframe to call any class methods.

I've considered using minimum integer value on AGOL using arcade, but presenting that value is awkward when collecting and analyzing the data. -1 is also not an option, because -1 is a valid entry value.

Is there a standard for representing unknown signed int's in GIS? I'm currently using an arbitrary negative int to represent unknown, but that is far from ideal.

TL;DR represent an unknown int value AGOL -> Python -> SQL -> AGOL

1
  • Is the None value actually an empty value or a string of "None" in the attribute table?
    – Ken T
    Commented Sep 29, 2022 at 7:31

1 Answer 1

1

The crux of the problem lies on the conversion from FeatureLayer to sdf. It is purely a programming problem. So I suggest resolve the problem from the coding point of view and I am also not aware any special integer standard. Try this:

item_id="xxx"
item=gis.content.get(item_id) 
featurelayer=item.layers[0]
featureset=featurelayer.query() 
sdf=featureset.sdf
2
  • I wonder why creating a dataframe from a featurelayer using the query() method is different than the spatial.from_layer() method. The sdf created using query casts nulls to NaN as user should reasonably expect. So far it seems like spatial.from_layer() is strictly worse than featureLayer.query() -> featureset.sdf, I wonder why from_layer() is the one used in the docs.
    – ColinAshe
    Commented Sep 29, 2022 at 11:49
  • @ColinAshe This is a bug.
    – Ken T
    Commented Sep 29, 2022 at 16:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.