Can't use GIS() object in 'Binder' both in Jupyter Lab and Notebook

1420
6
04-19-2021 02:14 AM
ShaiSussman
New Contributor II

Hi, I am trying to execute my GitHub repository to a binder environment.

Everything works great, however I just cannot get the GIS() object to work, I cannot view map not in Notebook nor Jupterlab.

for example

 

from arcgis.gis import GIS
gis = GIS()
map1 = gis.map('Israel',8)
map1 # doesn't display

 

I could not even view this as an embedded html. 

what am I missing?

 

0 Kudos
6 Replies
IhabHassan
Esri Contributor

Hi

the fact that the application is not throwing an error while instantiating GIS object means that you got the GIS package installed without an issue. 
I tried to run this in Pro Notebook, it didn't work as well, but it did run on local jupyter notebook, although both are using the same python env.

Regards
Ihab
ChrissyRothgeb
New Contributor III

I'm not sure if this is related, but one of my faculty members brought a similar issue to my attention yesterday. He is unable to get a map to display within a Jupyter Notebook, neither from a local installation nor within ArcGIS Online. I tested this from Online, and am having trouble myself, though I am seeing errors generated even with the most basic usage:

ChrissyRothgeb_0-1619016010970.png

I've tried multiple browsers, two different logins, and even the sample Notebooks Esri has published throw an error. I'm wondering if the update to AGOL this past week changed something...

0 Kudos
evaaasate
New Contributor

@ChrissyRothgeb wrote:

I'm not sure if this is related, but one of my faculty members brought a similar issue to my attention yesterday. He is unable to get a map to display within a Jupyter Notebook, neither from a local installation nor within ArcGIS Online. I tested this from Online  Esencia de perfume, and am having trouble myself, though I am seeing errors generated   even with the most basic usage:

ChrissyRothgeb_0-1619016010970.png

I've tried multiple browsers, two different logins, and even the sample Notebooks Esri has published throw an error. I'm wondering if the update to AGOL this past week changed something...




You must to use a try and cacth for control of exceptions.

ChrissyRothgeb
New Contributor III

I get that you can use try-catch blocks to handle exceptions, but this should not be generating any exceptions. I'm getting the same from the example Notebooks Esri themselves published, and they had no try-catch usage in theirs, so it doesn't appear to be requisite.

Just in testing this, I tried the statement:

map = gis.map()
map

And this worked, if less than useful at only showing an interactive map of the planet:

ChrissyRothgeb_0-1619803968759.png

It appears to be an issue with the built-in geocoder, as suggested by the error message:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-8-3ea8a60e307b> in <module>
----> 1 m1 = gis.map('San Diego')
      2 m1

/opt/conda/lib/python3.7/site-packages/arcgis/gis/__init__.py in map(self, location, zoomlevel, mode, geocoder)
    955                 else:
    956                     for geocoder in get_geocoders(self):
--> 957                         locations = geocode(location, out_sr=4326, max_locations=1, geocoder=geocoder)
    958                         if len(locations) > 0:
    959                             if zoomlevel is not None:

/opt/conda/lib/python3.7/site-packages/arcgis/geocoding/_functions.py in geocode(address, search_extent, location, distance, out_sr, category, out_fields, max_locations, magic_key, for_storage, geocoder, as_featureset, match_out_of_range, location_type, lang_code, source_country)
   1118         location_type=location_type,
   1119         lang_code=lang_code,
-> 1120         source_country=source_country)   1121 
   1122 

/opt/conda/lib/python3.7/site-packages/arcgis/geocoding/_functions.py in _geocode(self, address, search_extent, location, distance, out_sr, category, out_fields, max_locations, magic_key, for_storage, as_featureset, match_out_of_range, location_type, lang_code, source_country)
    196         if address is not None:
    197             if isinstance(address, str):
--> 198                 params[self._address_field] = address
    199             elif isinstance(address, dict):
    200                 params.update(address)

AttributeError: 'Geocoder' object has no attribute '_address_field'

I'm just wondering if something changed in AGOL under the hood that their API does not have working. Is anyone else able to get a map to work in an AGOL-hosted Jupyter Notebook using a location or address? 

0 Kudos
ChrissyRothgeb
New Contributor III

I just figured it out. Or, I figured part of it out anyway. We had an additional geocoder service enabled in our organization and set to primary (it's a free geocoder service provided by the state - VGIN). Unfortunately, there appears to be an issue with it, or with our configuration for it. When I moved the ArcGIS World Geocoding Service back to the top, it resolved the issue.

ShaiSussman
New Contributor II

I don't think the geocoded is relevant to my problem...

I'm trying to work with Binder.

0 Kudos