unable to save webmap from notebook

795
6
05-01-2021 09:56 AM
SB9
by
New Contributor

I am learning Python through ArcGIS Notebooks. In the lesson:

https://www.arcgis.com/home/item.html?id=5aee4d0f252941e1ae421b78a8ccbe60

https://learngis1.maps.arcgis.com/home/item.html?id=2eda03cbeec64e89a924cd9f9a1fad4b

my_first_map.save(webmap_properties)
traffic_map.save(webmap_properties)

 gives an error

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-9-6aee56bfc856> in <module>
----> 1 traffic_map.save(webmap_properties)

/opt/conda/lib/python3.7/site-packages/arcgis/widgets/_mapview/_mapview.py in save(self, item_properties, mode, thumbnail, metadata, owner, folder)
   1513                                         metadata = metadata,
   1514                                         owner = owner,
-> 1515                                         folder = folder)   1516         elif mode == "3D" or "webscene" in mode.lower():
   1517             return self._save_as_webscene(item_properties,

/opt/conda/lib/python3.7/site-packages/arcgis/widgets/_mapview/_mapview.py in _save_as_webmap(self, item_properties, thumbnail, metadata, owner, folder)
   1537         self._update_webmap_layers_from_js()
   1538         item = self.webmap.save(item_properties, thumbnail,
-> 1539                                 metadata, owner, folder)   1540         self.webmap.item = item
   1541         return item

/opt/conda/lib/python3.7/site-packages/arcgis/mapping/_types.py in save(self, item_properties, thumbnail, metadata, owner, folder)
    827 
    828         item_properties['type'] = 'Web Map'
--> 829         item_properties['extent'] = self._process_extent(item_properties.get('extent', None))
    830         item_properties['text'] = json.dumps(self._webmapdict, default=_date_handler)
    831         if 'typeKeywords' not in item_properties:

/opt/conda/lib/python3.7/site-packages/arcgis/mapping/_types.py in _process_extent(self, extent)
    711 
    712                         #process and return the result
--> 713                         if self._contains_nans(result):
    714                             return ""
    715                         else:

/opt/conda/lib/python3.7/site-packages/arcgis/mapping/_types.py in _contains_nans(self, result)
    729         """a bool of if projection output `result` contains any NaNs"""
    730         for value in result:
--> 731             if "nan" in str(value['x']).lower():
    732                 return True
    733             if "nan" in str(value['y']).lower():

/opt/conda/lib/python3.7/site-packages/arcgis/geometry/_types.py in __getitem__(self, k)
    181 
    182     def __getitem__(self, k):
--> 183         return dict.__getitem__(self, k)
    184 
    185 

KeyError: 'x'

 

0 Kudos
6 Replies
DavidPike
MVP Frequent Contributor

Sharing your full code would be beneficial.

0 Kudos
SB9
by
New Contributor

from arcgis.gis import GIS
gis = GIS("home")

# Item Added From Toolbar
# Title: Traffic Collisions | Type: Feature Service | Owner: Learn_ArcGIS
traffic = gis.content.get("79d3e458dcaf486f81c5591a67538179")
traffic

# Item Added From Toolbar
# Title: Pasadena Block Groups | Type: Feature Service | Owner: Learn_ArcGIS
block_groups = gis.content.get("af363700f8f84c11a02f084e78a296aa")
block_groups

traffic_map=gis.map('Pasadena, California')

traffic_map.add_layer(block_groups)

traffic_map.add_layer(traffic)

webmap_properties = {'title':'Pasadena_Traffic_NB_SB','snippet':'Pasadena Traffic map from a notebook,',
'tags':['ArcGIS Notebooks', 'Pasadena','traffic']}
traffic_map.save(webmap_properties)
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
<ipython-input-9-6aee56bfc856> in <module>
----> 1 traffic_map.save(webmap_properties)

/opt/conda/lib/python3.7/site-packages/arcgis/widgets/_mapview/_mapview.py in save(self, item_properties, mode, thumbnail, metadata, owner, folder)
1513 metadata = metadata,
1514 owner = owner,
-> 1515 folder = folder)
1516 elif mode == "3D" or "webscene" in mode.lower():
1517 return self._save_as_webscene(item_properties,

/opt/conda/lib/python3.7/site-packages/arcgis/widgets/_mapview/_mapview.py in _save_as_webmap(self, item_properties, thumbnail, metadata, owner, folder)
1537 self._update_webmap_layers_from_js()
1538 item = self.webmap.save(item_properties, thumbnail,
-> 1539 metadata, owner, folder)
1540 self.webmap.item = item
1541 return item

/opt/conda/lib/python3.7/site-packages/arcgis/mapping/_types.py in save(self, item_properties, thumbnail, metadata, owner, folder)
827
828 item_properties['type'] = 'Web Map'
--> 829 item_properties['extent'] = self._process_extent(item_properties.get('extent', None))
830 item_properties['text'] = json.dumps(self._webmapdict, default=_date_handler)
831 if 'typeKeywords' not in item_properties:

/opt/conda/lib/python3.7/site-packages/arcgis/mapping/_types.py in _process_extent(self, extent)
711
712 #process and return the result
--> 713 if self._contains_nans(result):
714 return ""
715 else:

/opt/conda/lib/python3.7/site-packages/arcgis/mapping/_types.py in _contains_nans(self, result)
729 """a bool of if projection output `result` contains any NaNs"""
730 for value in result:
--> 731 if "nan" in str(value['x']).lower():
732 return True
733 if "nan" in str(value['y']).lower():

/opt/conda/lib/python3.7/site-packages/arcgis/geometry/_types.py in __getitem__(self, k)
181
182 def __getitem__(self, k):
--> 183 return dict.__getitem__(self, k)
184
185

KeyError: 'x'

?

0 Kudos
MichelleMarasco
New Contributor

I am having the exact same issue. Super frustrating.

 

@SB9  Did you ever resolve this?

0 Kudos
MichelleMarasco
New Contributor

@SB9 Just an update. I was able to resolve this by clicking the "restart the kernel, re-run the whole notebook" button at the top

tchaulla
New Contributor II

Worked for me too!

0 Kudos
DanHuerter2
New Contributor II

Thanks MichelleMarasco.  That works.  I'm unsure why restarting the kernel is necessary, but it solved the problem.