RuntimeError error when loading local data to the map widget.

442
3
Jump to solution
03-11-2021 01:01 PM
Laura_m_Conner
New Contributor II

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

0 Kudos
1 Solution

Accepted Solutions
JeffK
by
Regular Contributor

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.

 

View solution in original post

0 Kudos
3 Replies
JeffK
by
Regular Contributor

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.

 

View solution in original post

0 Kudos
Laura_m_Conner
New Contributor II

JeffK

Thanks for the Explanation. Do you know where I can find documentation on the errors.

Laura

0 Kudos
JeffK
by
Regular Contributor

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.

 

0 Kudos