ArcGIS API for Python not plotting Spatially Enabled Dataframe

01-07-2020 02:08 PM
Occasional Contributor

I'm pulling data from an API and viewing it in a pandas dataframe using a Jupyter Notebook. The data has several attributes including latitude and longitude. I can successfully convert the pandas dataframe to a spatially enabled dataframe, call the .head() method and see the new SHAPE column. I can create a map object but when I try to plot my dataframe on the map object, the map does not update and display the points. I've included my code below:

# Define parameters for API call
headers = {
    'accept': 'application/json',
    'Api-Token': 'Key',
    'Agency-ID': 'ID'

# Call API and save to a varialbe
response = requests.get('URL', headers=headers).json()

# Convert json to dataframe
df = pd.DataFrame(response)

# Convert dataframe to spatially enabled dataframe
df = pd.DataFrame.spatial.from_xy(df, x_column = 'longitude', y_column = 'latitude')

# Create map object and display map
gis = GIS()
m = GIS().map() = [36.081179, -79.556955]
m.zoom = 9

# Plot dataframe
df.spatial.plot(map_widget= m)‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Line 22 returns a map and Line 25 returns 'True' but no updates to the map are made. I've also tried using the renderer and symbol_type and symbol_style attributes.

            symbol_style='d', # d - for diamonds

This block of code replaced Line 25 in the first section but did not display in the map either.

I've been through the documentation and the guide on GitHub but cannot find anything to make it work. Please advise.


Miguel Fernandez

Miguel Fernandez
0 Kudos
1 Reply
Occasional Contributor

One year and a few months later, and I still can't get the data to plot. Can anyone offer any insights?

Miguel Fernandez
0 Kudos