Select to view content in your preferred language

Converting geodataframe feature layer to AGOL

435
3
02-11-2025 12:56 PM
HieuTran12
Emerging Contributor

Hi All,

I'm trying to convert my geodataframe to a feature layer so I can overlay it with other layers from AGOL.

I've been researching for a way to do it; the best way is hosted feature layer. When I publish to my content it only has a table view but I want it has polygons as well.

I was following the documentation from ESRI.

 

HieuTran12_0-1739307348585.png

 

Tags (3)
0 Kudos
3 Replies
EarlMedina
Esri Regular Contributor

Hi,

The way that I have done this in the past is like this:

  1. Create a spatially enabled dataframe from a geodataframe via geoaccessor's from_geodataframe 
  2. Then, just publish using to_featurelayer()

Something like this:

from arcgis.features import GeoAccessor

sdf = GeoAccessor.from_geodataframe(you_gdf)
lyr = sdf.spatial.to_featurelayer("layer_name")
0 Kudos
HieuTran12
Emerging Contributor

Thanks for your reply. I tried with that solution as well, but this error persists! 

AttributeError: `np.NaN` was removed in the NumPy 2.0 release. Use `np.nan` instead.

 

I tried to reinstall numpy but still no luck. Is there any way to overlay data from gdf to an imagery layer from living atlas? 

 

0 Kudos
EarlMedina
Esri Regular Contributor

Hmm, that error makes me think maybe the gdf needs a bit of cleanup before getting converted to a sedf? When does that error show up? On the publish attempt, or when trying to do the conversion?

0 Kudos