|
POST
|
Another option. import arcpy
DeltaTable ='E:\\Data\\JRAlessi\\Conflation_URD_GPTest\\ConflationTest.gdb\\TestTable'
QTField = "QuarterTWNSHP"
QTSet = [str(row[0]) for row in arcpy.da.SearchCursor(DeltaTable, [QTField], "FME_Status IS NULL")]
print(QTSet)
... View more
11-29-2022
02:38 PM
|
0
|
2
|
3055
|
|
POST
|
I have not done this, but it looks like you could use the geometryEngine nearestCoordinate to get the location on a feature. Then you could use the coordinate from the NearestPointResult object to query your feature layer for intersecting geometry. Edit: Since you will probably have to input the geometry of all features for the nearestCoordinate, you might as well reuse those with the geometryEngine again with intersects (iterating over all features) instead of querying the feature layer.
... View more
11-23-2022
09:14 AM
|
0
|
0
|
1766
|
|
POST
|
You could watch for when the popup is visible, then zoom to the selected feature. reactiveUtils.watch(
() => view.popup.visible,
() => {
console.log(`Popup visible: ${visible}`);
}); Edit: Here is another possible solution Solved: Zoom to selected feature using JavaScript - Esri Community
... View more
11-21-2022
07:49 AM
|
1
|
0
|
686
|
|
POST
|
Apparently I was doing something wrong, but indeed the catalogPath from describe on the layer does allow the edit session to start. Thanks @Anonymous User! In my case, the data source of the layer is in a feature dataset, so here's the method I used to parse out the path to the sde connection file. catalogPath = arcpy.Describe(theLayer).catalogPath
# Traverse up the path to get the sde connection file or error at the end of the path.
while not catalogPath.endswith('.sde'):
if catalogPath == os.path.dirname(catalogPath):
raise OSError("This catalogPath does not have an sde connection file.")
catalogPath = os.path.dirname(catalogPath)
with arcpy.da.Editor(catalogPath) as edit:
# editing logic here
... View more
11-18-2022
01:17 PM
|
0
|
0
|
3774
|
|
POST
|
I'm creating a Python toolbox in ArcGIS Pro that will start an edit session on a layer in the map. In order to create the edit session, a workspace is needed. How can I derive the workspace from a layer in the map to use for the edit session? Nothing in Layer properties or Describe seems to work. Since the layer is in an enterprise geodatabase (Oracle), the only solution I see right now is to get the connection_info from the layer object's connectionProperties and create a new sde connection file in a temp folder. I'm hoping there's a better way.
... View more
11-17-2022
03:28 PM
|
0
|
4
|
3858
|
|
POST
|
I'm not sure this is the solution to your problem, but the list comprehension on line 3 seems wrong. It should be something like def get_mapped_permits():
building_permits_2022 = "path.to.sde"
mapped = [permit[0] for permit in arcpy.da.SearchCursor(building_permits_2022, "PERMIT_NUM")]
return mapped
... View more
11-01-2022
07:16 AM
|
0
|
1
|
2603
|
|
POST
|
This is a perfect answer. However, I want to add something that I found in our organization while doing something similar. We have some streets that don't have a street suffix. You should make sure that scenario does not exist or code to handle it.
... View more
10-25-2022
07:11 AM
|
1
|
0
|
2324
|
|
POST
|
There must be some formatting issue with the path of the feature class. Try running this as a standalone script and tinker with the path until you figure out the problem. import arcpy
import os
arcpy.env.workspace = r"C:/Users/***/AppData/Roaming/Esri/ArcGISPro/Favorites/***.sde/CCDS.CCDS.TempLyrs"
cws = arcpy.env.workspace
fc_known_to_exist = os.path.join(cws, "CCDS.CCDS.FEMA_FLOOD_ZONES_Temp")
if arcpy.Exists(fc_known_to_exist):
print(f"The feature class exists: {fc_known_to_exist}")
else:
print(f"{fc_known_to_exist} does NOT exist.")
... View more
10-21-2022
11:14 AM
|
0
|
2
|
2392
|
|
POST
|
Is there only ever exactly one match for a given ID among all the feature layers? In the process of you getting the ID for the feature, there's never any way to determine which feature layer it's intended for? Maybe you can use a combination of fields so you know which feature layer to search?
... View more
10-13-2022
07:46 AM
|
0
|
1
|
1133
|
|
POST
|
Is this search initiated by clicking a point on the map or by entering a value?
... View more
10-12-2022
07:03 AM
|
0
|
3
|
1148
|
|
POST
|
In Python 3 (ArcGIS Pro) this is what I typically do, mostly to track where errors occur so I can more easily troubleshoot to data. Especially if this update cursor work is in a separate function than your main code. with arcpy.da.UpdateCursor("myFeatureClass", ["someUniqueID", "Field1", "Field2"]) as uCursor:
for uid, field1, field2 in uCursor:
try:
# Do some business logic.
field2 = field1 * 100
# Commit new values to table.
# To throw an error with the cursor:
# use a value that does not conform to your field type
# or change the number of values in the row.
uCursor.updateRow([uid, field1, field2, "thisWillError"])
except Exception as e:
raise Exception(f"Error updating row at someUniqueID {uid}") from e If you want the most coverage possible, following the "suggestions" in the documentation, I suppose you could do something like this (though I never have). with arcpy.da.UpdateCursor("AnchorPoints", ["someUniqueID", "Field1", "Field2"]) as uCursor:
try:
for uid, field1, field2 in uCursor:
try:
# Do some business logic.
field2 = field1 * 100
# Commit new values to table.
uCursor.updateRow([uid, field1, field2])
except Exception as e:
raise Exception(f"Error updating row at someUniqueID {uid}") from e
finally:
del uCursor As for having an incorrect field name, the cursor will fail to be created so there's no cursor object to delete. In that case, you would have to follow the suggestion in the documentation and have it in a separate function so the everything gets cleaned up with garbage collection when it goes out of scope on exit (regardless of an exception). That's pretty tedious though. You might need to contact Esri support about the behavior your seeing when the cursor fails.
... View more
10-11-2022
02:11 PM
|
0
|
1
|
7416
|
|
POST
|
@RogerDunnGIS wrote: I thought arcpy would "take care of it." Doesn't the existence of the UpdateCursor keep an unnecessary lock on my feature class and/or workspace? I have not done a deep dive, but the documentation does say Update cursors also support with statements to reset iteration and aid in removal of locks. However, using a del statement to delete the object or wrapping the cursor in a function to have the cursor object go out of scope should be considered to guard against all locking cases. However, I have never experienced an issue with locks using a with statement. Even with an Editor session or list comprehension like a_field_values = [i[0] for i in arcpy.da.SearchCursor("the_fc", ["a_field"])]
... View more
10-06-2022
09:46 AM
|
0
|
0
|
7460
|
|
POST
|
When using a with statement, there's no need to explicitly clean up the cursor yourself. Maybe that's causing some weirdness. Just let the cusor's context manager take care of it. Since you don't have an except block, try removing the try/finally. When an exception occurs in your business logic, do you want to continue updating rows?
... View more
10-06-2022
08:13 AM
|
0
|
0
|
7486
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 10-23-2025 03:53 PM | |
| 1 | 04-28-2026 07:25 AM | |
| 1 | 03-19-2026 08:59 AM | |
| 1 | 02-12-2026 01:37 PM | |
| 1 | 12-01-2025 06:19 AM |