Can't create spatially enabled data frame from AGOL layer

556
3
Jump to solution
09-14-2022 02:21 AM
HanliePetoors
New Contributor III

Hi,

I'm trying to convert an AGOL layer to a spatially enabled data frame, following the steps in https://developers.arcgis.com/python/guide/part2-data-io-reading-data/#read-in-web-feature-layers

I can access the AGOL item and its layers:

HanliePetoors_0-1663147138204.png

But when I try to read one of them into a spatially enabled data frame, I get this:

HanliePetoors_1-1663147248933.png

The layer contains 3 features, it's not empty.

Does anyone know why this happens?

Thanks

Hanlie

0 Kudos
1 Solution

Accepted Solutions
HanliePetoors
New Contributor III

I found this pattern at http://geospatialtraining.com/tutorial-using-pandas-dataframes-with-the-arcgis-api-for-python/ and it doesn't seem to mind empty fields.

HanliePetoors_1-1663158736349.png

I'm going to try to complete my script using this approach.

Regards

Hanlie

View solution in original post

0 Kudos
3 Replies
jcarlson
MVP Esteemed Contributor

I see this now and then. It's not about the layer itself, it's that a null value is being encountered when it expects an integer, and it's throwing an error.

Take a look at the data table, see if there are any fields where this might be happening.

If you want to work around this, try instead using bldg.query(as_df=True, out_fields=['subset', 'of', 'fields']) to just pull what you need and potentially avoid the offending field.

- Josh Carlson
Kendall County GIS
0 Kudos
HanliePetoors
New Contributor III

Hi Josh,

Thanks for the reply. I can now confirm that fields that have no value cause this error. When I use the query you suggested and only include fields that are mandatory and therefore do have values, the code works.

HanliePetoors_0-1663157550129.png

How can I get around this? I want to place the attribute tables of all the layers in the feature service into one data frame that I then want to export to CSV. Obviously I can't predict which optional attributes will have values and which won't.

Can you suggest any options other than spatial data frames? I don't actually need the spatial abilities.

Thanks

Hanlie

0 Kudos
HanliePetoors
New Contributor III

I found this pattern at http://geospatialtraining.com/tutorial-using-pandas-dataframes-with-the-arcgis-api-for-python/ and it doesn't seem to mind empty fields.

HanliePetoors_1-1663158736349.png

I'm going to try to complete my script using this approach.

Regards

Hanlie

0 Kudos