sdf.spatial.plot on SEDF that was NOT created with import_data

226
1
Jump to solution
03-31-2020 02:26 PM
artzaifman
New Contributor III

I have the following simple Spatially Enabled Data Frame (SEDF):  

Should sdf.spatial.plot(map_widget=m) work for this object because it's not working for me.

An exact duplicate SEDF was created with GIS().content.import_data().query().sdf and plot DOES work for this one.

Main question is: Is calling plot() on an SEDF that was NOT created with import_data valid?

0 Kudos
1 Solution

Accepted Solutions
artzaifman
New Contributor III

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

Also 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

View solution in original post

0 Kudos
1 Reply
artzaifman
New Contributor III

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

Also 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