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?
Solved! Go to Solution.
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
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