Jupyter Notebooks: display local shapefiles in map widget?

1111
1
08-06-2019 11:59 AM
Highlighted
New Contributor II

I am just starting to explore ArcGIS API for python Jupyter Notebooks and am looking for a method to display a map in my notebook that I can add shapefiles to that are saved locally. More specifically I am after a way to have a persistent map widget in my notebook that has layers that will update through various geoprocessing steps.

I have explored the map.gis() function but it appears to only be able to map.addlayer() that exist on AGOL or an Enterprise portal. I would be great if I could pull local shapefiles in this same way.

I have stumbled upon a couple other modules that look like they might accomplish this, but I wanted to ask here and see if there is an out-of-the-box solution first.

1 Reply
Highlighted
Esri Contributor

Hi Hayden Hinton

Here's one way of adding local shapefiles to a map in Jupyter Notebook:

from arcgis.gis import GIS
from arcgis.features import SpatialDataFrame
gis = GIS(url, user, password)
sdf = SpatialDataFrame.from_featureclass(r"Path to local shapefiles")
map1 = gis.map() #local region can be added in parentheses
map1
sdf.plot(kind='map', map_widget= map1)‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍