I'm doing some data processing in Jupyter Notebook with arcpy geoprocessing tools and storing the result into file geodatabase as a feature class. To check the results inside the notebook I imported the feature class to spatial dataframe (sdf) with from_featureclass() method. Everything seems to be ok and sdf has a SHAPE column and the first row contents of the SHAPE column looks good when printed out:
print(sdf.iloc[0, sdf.columns.get_loc('SHAPE')])
and the SHAPE field referenced by itself
sdf.iloc[0, sdf.columns.get_loc('SHAPE')]
results in a polygon being drawn to the cell's output.
However, if i try to plot it to a map widget with:
mw = gis.map("Center of the Map")
sdf.spatial.plot(map_widget=mw,
col='columnName')
mw
it results in a map widget drawn with only the default base map.
On the other hand, if I export it to a feature layer in AGOL with:
lyr = sdf.spatial.to_featurelayer('export_test', folder='exportDemo')
It draws correctly on the Map Viewer, but there are still some issues regarding the calculated values (it only allows unique values symbology and not "Counts and Amounts"), but that I think is just a data type issue.
The usual suspect in this type of problem is often an issue with the spatial references. My SDF has a projected national grid spatial reference, and the widget basemap probably is Web Mercator. There might be some projection issue even if no error is displayed. But the reference in the SDF should be okay, because it plots correctly in AGOL.
Do you have any ideas or recommendations on how to tackle this? Should I try to re-project my data to Web Mercator before plotting, or can/should I define my national grid as the default spatial reference?
Edit: After doing the stuff above, I exported the SDF to file geodatabase with:
sdf.spatial.to_featureclass("path to file geodatabase feature class")
That feature class also plots correctly in ArcGIS Pro. Interestingly, export changed the "columnName" style column names to the "column_name" style. I tried to re-import that feature class back to the notebook and plot it in the map widget, but I got the same result: it did not plot.
Edit: tidying up extra linebreaks.