|
POST
|
You can use the python '_file_' variable to get the path to your .py file. From there you can back it up to the root of your toolbox. Here is an example of how I do it: path_code_base = os.path.normpath(__file__ + '/../../../../')
... View more
01-12-2022
04:43 PM
|
1
|
0
|
1707
|
|
POST
|
I took at look at one of the REST endpoints behind one of the layers ('Registered Two Unit Dwellings') and it did not have the EXTRACT capability enabled. I suspect this is why it is not working for your.
... View more
01-11-2022
09:50 AM
|
0
|
0
|
1061
|
|
POST
|
I can't easily recreate the ExecutionError exception but one thing I would try is to see what you get with the exception's 'args' property, which will give you the arguments passed in by the ESRI code when the exception was created. try:
my code here...
except arcpy.ExecuteError as ex:
print (str(ex.args)) # Maybe the specific error code is one of the args ??????
e = sys.exc_info()[1]
print(e)
except:
handle of other errors
... View more
01-09-2022
02:52 PM
|
2
|
1
|
3340
|
|
POST
|
This may not be what you are looking for, but one way to get information on a hosted map service's tiles is using the REST apis - specifically this one. If you look at the response JSON's "lodInfos" section you can see which sets of tiles have been built. I've never worked with .rrd or .ovr files. Maybe there is a way to do this via a python API, but I'm not sure.
... View more
12-16-2021
08:34 AM
|
0
|
0
|
2034
|
|
POST
|
I recently stumbled over this also with SelectLayerByAttribute. I found if I created a layer using MakeFeatureLayer and passing that into SelectLayerByAttribute instead of passing in the feature class, it ran many times faster.
... View more
12-09-2021
11:29 AM
|
0
|
0
|
2654
|
|
POST
|
I would simply dump out the variables and see what they look like - something like this (this is in a python toolbox?) arcpy.AddMessage("search_string: " + search_string)
arcpy.AddMessage("whereClause: " + whereClause)
... View more
12-08-2021
04:17 PM
|
1
|
1
|
1153
|
|
POST
|
Have you tried to explicitly convert the string to a double before writing it? For instance in your 2nd example: row[1] = float(row[0])
... View more
12-08-2021
05:15 AM
|
0
|
2
|
1157
|
|
POST
|
You can get that from the "Derived Output" which is described in the documentation. Here is a snippet of my code that gets the item of the published image service rsp = arcpy.UploadServiceDefinition_server(<sd_output_filename>, "HOSTING_SERVER")
gis_item = gis.content.get(rsp[2])
... View more
11-18-2021
04:50 AM
|
2
|
2
|
4393
|
|
POST
|
Right, I see the same behavior when I upload to ArcGIS Online as a feature layer, and work around it by moving it to the right folder after the publish (See the code below). You may have a make some tweaks if publishing to a portal or publishing a map image layer. rsp = arcpy.UploadServiceDefinition_server(<sd_filename>, "HOTING_SERVER")
gis_item = gis.content.get(rsp[3])
gis_item.move(<destination_folder>)
... View more
11-17-2021
12:02 PM
|
1
|
1
|
1760
|
|
POST
|
I found an acceptable workaround for this by writing out the rows to insert into a temporary in-memory table then appending the in-memory table to the "intermediate table". At least that way I don't have to create an InsertCursor for every record that I want to add.
... View more
11-14-2021
05:07 PM
|
1
|
0
|
2272
|
|
POST
|
I wasn't able to access the layer from arcpy - I'm not sure why. But an alternative is to use the ArcGIS API for python. The code to access your object would look like this ('255af1ceee844d6da8ef8440c8f90d00' is the ArcGIS item ID for the sentinal image layer): from arcgis.gis import GIS
gis = GIS(url=None, username=<my_id>, password=<my_pw>)
item = gis.content.get('255af1ceee844d6da8ef8440c8f90d00')
record = item.layers[0].query(where="objectid=23156221").to_dict()['features'][0]
print (record)
... View more
11-11-2021
08:43 AM
|
1
|
1
|
2235
|
|
BLOG
|
I'm a big believer in using python dicts to optimizing the use of cursors, especially when the access patterns are more random than sequential. However in Chase's case it seems that using the python dict makes it more complicated than it needs to be. Unless there is a big performance advantage using the dicts (and there might very well be), this is how I would do it. import arcpy
relTable = r"C:\Path\RelateTable"
updateFC = r"C:\Path\UpdateFeatureClass"
with arcpy.da.UpdateCursor(updateFC, ["FacilityID", "LatestStatus"]) as updateRows:
for f_id, old_status in updateRows:
with arcpy.da.SearchCursor(relTable,
["Status"],
where_clause="FacilityIDRel=%s" % f_id,
sql_clause=(None, "ORDER BY last_edited_date DESC")
) as searchRows:
for (new_status,) in searchRows:
updateRows.updateRow(f_id, new_status)
break
... View more
11-11-2021
04:50 AM
|
1
|
0
|
19026
|
|
POST
|
You should be able to get rid of your loops and let the python Multiprocessing Pool manage running the body of the loop. You have to prepare a list of "parameter sets" that the Pool will use to invoke the body whenever a processor becomes available. In your case the list would look something like this (no guarantee on the exact syntax) parm_list = [('x','a'), ('x','b'),('x','c'),('y','a'),('y','b'),('y','c'),('z','a'),('z','b'),('z','c')] then your body would be encapsulated in a function something list this def my_body (parm):
outNALayerName = parm[0]
chunk = parm[1]
..... and you would call it like this p = multiprocessing.Pool(<number of processors>)
p.map(my_body, parm_list)
p.close() You have to be careful about lock conflicts, for instance if you use duplicate names for your temporary files or try have multiple processes updating the same file.
... View more
11-10-2021
10:20 AM
|
2
|
0
|
10569
|
|
POST
|
Very good. If I recall correctly, I opted for the JSON route only because the python code seemed simpler doing the updates that way versus navigating through the dom.
... View more
11-10-2021
05:31 AM
|
0
|
0
|
2217
|
|
POST
|
Hi Heiko. From python you can access the record data using cursors. The "input table" will be URL of the ArcGIS online item (in your case the hosted feature layer created from the uploaded file geodatabase).
... View more
11-10-2021
05:24 AM
|
1
|
0
|
562
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 11-18-2025 03:42 PM | |
| 1 | 11-19-2025 02:36 PM | |
| 1 | 08-11-2025 09:19 PM | |
| 2 | 08-07-2025 11:47 AM | |
| 1 | 01-18-2022 07:15 AM |
| Online Status |
Offline
|
| Date Last Visited |
11-28-2025
04:52 AM
|