Hello,
In Arcpro Jupyter Notebook, I am trying to get a map widget with data from our local system/network. My code is:
from arcgis.gis import GIS
gis = GIS("pro")
from arcgis.widgets import MapView
MapView.set_js_cdn("https://js.arcgis.com/4.18/")
map1 = gis.map("macon, GA")
map1.basemap = "topo"
map1.add_layer("N:\name\shp\shapefile.shp")
map1
I am getting the following error:
RuntimeError Traceback (most recent call last)
In [14]:
Line 8: map1.add_layer("N:\name\shp\shapefile.shp")
File C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\widgets\_mapview\_mapview.py, in add_layer:
Line 1153: self._add_layer_to_widget(item, options)
File C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\widgets\_mapview\_mapview.py, in _add_layer_to_widget:
Line 1263: raise RuntimeError("Cannot infer layer: will not be added to map")
RuntimeError: Cannot infer layer: will not be added to map
What does this error mean, and how do I fix it? Also, where is some good documentation on errors that occurs in Jupyter Notebooks?
Again I am just trying to gain familiarity with Jupyter in Arcpro. The ability to use our data in a Jupyter Notebook will be essential to any applications of the feature.
Arc Pro: 2.7
Thank you,
Laura
Solved! Go to Solution.
You are trying to add a layer that ArcGIS for Python API doesn't understand. The documentation for add_layer requires
Layer objects such as FeatureLayer, MapImageLayer, ImageryLayer etc.
Item objects and FeatureSet and FeatureCollections
Table objects
which are referring to web based/ hosted types of data... I know you can access local featureclasses/ data for analysis and the like, but I don't think it extends to webmap widgets. You could host that shapefile in AGOL and access it that way.
You are trying to add a layer that ArcGIS for Python API doesn't understand. The documentation for add_layer requires
Layer objects such as FeatureLayer, MapImageLayer, ImageryLayer etc.
Item objects and FeatureSet and FeatureCollections
Table objects
which are referring to web based/ hosted types of data... I know you can access local featureclasses/ data for analysis and the like, but I don't think it extends to webmap widgets. You could host that shapefile in AGOL and access it that way.
JeffK
Thanks for the Explanation. Do you know where I can find documentation on the errors.
Laura
Sorry for the delay- I don't think ESRI keeps a repo of all the errors, at least any that are publicly accessible. This thread might provide you some answers on what error codes are there, how to get a list of them and since they keep the codes consistent across the platform (maybe?), you can probably search for the code and get the documentation for it.