find_nearest error

847
6
Jump to solution
03-12-2021 03:23 PM
YuliaMamonova
Occasional Contributor III

Hi all,

I get the following error when I run the script with find_nearest function or any other function from use_proximity module. I am lost, tried all kinds of workarounds, nothing worked so far. I would appreciate any help.

The script is as following:

import arcgis
from arcgis.features import FeatureLayer, FeatureLayerCollection, use_proximity
from arcgis.features.use_proximity import find_nearest
from arcgis.geometry import Geometry, Point, Polyline
from arcgis.gis import GIS

agoLogin = GIS(#),
username='#',
password='#',
verify_cert=False)
 
# Get point layer with trees
trees_layer = agoLogin.content.get('#')
trees = trees_layer.layers[0].query()
 
# Get line layer with road segments
roads_layer = agoLogin.content.get('#')
roads = roads_layer.layers[0].query()

# Find nearest road segment for each tree
nearest = use_proximity.find_nearest(analysis_layer=trees, near_layer=roads,measurement_type = "StraightLine",gis = agoLogin,max_count=1)
 
The error is as following:
File "/usr/local/lib/python3.9/site-packages/arcgis/features/use_proximity.py", line 773, in find_nearest
params = inspect_function_inputs(fn=gis._tools.featureanalysis._tbx.find_nearest,
File "/usr/local/lib/python3.9/site-packages/arcgis/_impl/tools.py", line 644, in _tbx
self._gptbx = import_toolbox(url_or_item=self._url, gis=self._gis, verbose=self._verbose)
File "/usr/local/lib/python3.9/site-packages/arcgis/geoprocessing/_tool.py", line 454, in import_toolbox
f = executor.submit(fn=_generate_fn, **{"task": task, "tbx" :tbx})
TypeError: submit() missing 1 required positional argument: 'fn'
 
Thank you!!!
0 Kudos
1 Solution

Accepted Solutions
YuliaMamonova
Occasional Contributor III

I changed the environment to conda and the script ran successfully. I don't quite understand why, because arcgis was installed on both environments. Any ideas?

View solution in original post

0 Kudos
6 Replies
DavidPike
MVP Frequent Contributor

I think because you have only imported find_nearest from use_proximity, when you then reference use_proximity.find_nearest() it croaks.

perhaps try just find_nearest() or otherwise - from arcgis.features import use_proximity

0 Kudos
YuliaMamonova
Occasional Contributor III

Thank you, I tried what you've proposed before, still same error no matter what.

YuliaMamonova
Occasional Contributor III

When I try this create_bufferes function on any hosted layer, I get the same result. I am thinking - can there be a problem with geoprocessing on my end because of my negative arcgis credits balance?

YuliaMamonova_0-1615653345807.png

 

0 Kudos
CalvinLietz
Esri Contributor

Hi Yulia,

That is definitely possible. A lot of these analysis tools use the default ArcGIS Online utility services, which can incur a credit cost. A worthwhile test may be to add a table/hosted feature layer to a new Web Map in your Portal organization, and then click the Analysis button from the toolbar. Here, we can run the same tools manually, including Find Nearest. If run in the web map, does the tool succeed?

Also, what do you see listed under Portal -> Organization -> Settings -> Utility Services -> Directions and Routing -> Closest Facility (Asynchronous)? If this is an ArcGIS Online URL, then it means that the operation will cost credits according to the credit breakdown here: https://doc.arcgis.com/en/arcgis-online/administer/credits.htm#ESRI_SECTION1_709121D2C7694DCAB9B8592...

The Find Nearest tool using this utility service endpoint to perform the operation.

Thanks, 

Calvin

YuliaMamonova
Occasional Contributor III

Hi Calvin,

I realized that this issue is not related to credits, because my colleague successfully ran the same script with the same account credentials.

I don't know what else I can do about it. The error persists with all analysis module functions. 

Thank you,

Yulia

0 Kudos
YuliaMamonova
Occasional Contributor III

I changed the environment to conda and the script ran successfully. I don't quite understand why, because arcgis was installed on both environments. Any ideas?

0 Kudos