Select to view content in your preferred language

SpatialDataFrame has been deprecated

3129
12
Jump to solution
03-31-2020 05:32 AM
artzaifman
Regular Contributor

I receive following warning after this statement is run: sdf = features.SpatialDataframe(df)

opt/anaconda3/lib/python3.7/site-packages/arcgis/features/_data/geodataset/geodataframe.py:221: UserWarning: SpatialDataFrame has been deprecated.  Please switch to the GeoAccessor/GeoSeriesAccessor.   warnings.warn("SpatialDataFrame has been deprecated.  Please switch to the GeoAccessor/GeoSeriesAccessor.")

What is the correct way to create an 'sdf' now?

0 Kudos
12 Replies
artzaifman
Regular Contributor

Related to the issues above, is it possible to use sdf.spatial.plot(map_widget=...) on an SEDF derived from a regular panda DF where the SEDF was NOT created with import_data() method?  The SEDF was instead created as follows:  sdf = GeoAccessor.from_xy(df, 'x', 'y')

0 Kudos
artzaifman
Regular Contributor

Found reason:  

SEDF which works = 

{'x': -13657899.64491753,  'y': 5749953.6899396395,  'spatialReference': {'wkid': 102100, 'latestWkid': 3857}}

SEDF which doesn't = 

{'x': -13657899.64491753,  'y': 5749953.689939638,  'spatialReference': {'wkid': 4326}}
artzaifman
Regular Contributor

Continuing to add to this thread since it may help other newbies to arcGIS Pro like like me!

Discovered that sdf.spatial.plot() will fail to render (without generation an error) if it encounters NaN values.

Here's snippet to remove NaNs from SEDF:

sdf = GeoAccessor.from_xy(df, 'x', 'y', sr=102100) # 102100 is necessary to render using sdf.spatial.plot() method

...

 sdf[~sdf['SHAPE'].apply(lambda r: numpy.isnan(r['x']) or numpy.isnan(r['y']))]   # drop NaNs which cause plot to silently fail

0 Kudos