ArcGIS Python API Sample Notebook "Using Geoprocessing tools" does not work

08-11-2016 08:47 AM
Esri Contributor


I'm following along with this sample notebook but the following input doesn't seem to produce any output on the map when I click on the map:

def do_analysis(m, g😞

   ret = gptool.message_in_a_bottle(g, 150)

   for geom in ret:



The gptool object is returning a 'NoneType':

TypeError  Traceback (most recent call last) 
<ipython-input-24-a0a0d2de3044> in <module>()       
1 ret = gptool.message_in_a_bottle(g,150) 
----> 2 for geom in ret:       
3     map.draw(geom)  TypeError: 'NoneType' object is not iterable 

Any insight would be helpful (I'm  a newbie to this API)



0 Kudos
4 Replies
MVP Esteemed Contributor

Providing a link to the sample notebook would be most helpful.

You have some indentation issues, but I am guessing those are copy & paste artifacts.

Your error message is informing you that your geoprocessing tool returned nothing.  When you iterate over the list with a single None object, it generates an error when you try to draw it.

0 Kudos
Esri Contributor

Try running this notebook and see if you can reproduce the problem - I'm following exactly as it's laid out in the sample:

0 Kudos
MVP Esteemed Contributor

I get an error at the very end, but different than your error when I click on the map in various locations:

TypeError                                Traceback (most recent call last)

TypeError: _handle_map_msg() takes 3 positional arguments but 4 were given


I just downloaded the sample/example Jupyter notebook from Github, and it generates the same error as when I manually type in the code.  I will have to dig in a bit deeper.

UPDATE:  I found the cause of the error for me, lines 327-329 of look like this:

def _handle_map_msg(self, _, content):
#def _handle_map_msg(self, _, content, buffers):
     """Handle a msg from the front-end.

The code calling _handle_map_msg() is passing 4 arguments instead of 3.  I will have to ask in the beta forums if the function definition is wrong or code calling it.

MVP Esteemed Contributor

Heard back from Esri, the function is supposed to have 4 parameters, so one can just comment out the three parameter definition and uncomment the other one until Esri changes the code.