|
POST
|
You'll want to get familiar with the arcpy.mp sub module. In general, you'll define a project, then identify a map in that project, then a layer in that map, then call the layer's getSelectionSet () method. This only gives you a list of objectId values for the selected features, not the actual feature. If you want access to the feature, use a data access cursor. Or, if you want to run a tool on the selected feature, you can usually just use the layer with the selection as the input and it will only run on the selection.
... View more
05-03-2022
12:32 PM
|
4
|
8
|
12732
|
|
POST
|
Here's an exploration of some different methods for counting the number of rows in a table. The Iterable Cursor: Python Built-ins & Itertools - Esri Community
... View more
05-03-2022
09:30 AM
|
2
|
0
|
4320
|
|
POST
|
Your logic is difficult to follow, but it looks like you're updating everything based on what is in the valueDict so maybe update the abbreviations there. Please rearrange and adjust as necessary. sourceFieldsList = ['TARGET_FID', poly,'Field1_1','Field2_1','Field3_1','Field4_2','Field4_1','Field5_1','Field6_1']
# define the field list to the original points
updateFieldsList = ['OID@', Pnt,'Field1','Field2','Field3','Field4','Field5','Field6']
valueDict = {r[0]:(r[1:]) for r in arcpy.da.SearchCursor(sjpoints1, sourceFieldsList)}
# Update abbreviation field values to full text description.
abbreviation_lookup = {
"MH": "MOBILE HOME",
"SFR": "SINGLE FAMILY RES",
# etc...
}
for key, rest_of_the_fields in valueDict.items():
# Look up full text of abbreviation. Return original value if not found.
# I don't know which index your abbreviation data is at. Maybe it's rest_of_the_fields[6] ?
rest_of_the_fields[5] = abbreviation_lookup.get(rest_of_the_fields[5], rest_of_the_fields[5])
# Update the original values.
valueDict[key] = rest_of_the_fields
# Run the Spatial Join tool, using the defaults for the join operation and join type
arcpy.SpatialJoin_analysis(ptSelection, parcel, sjpoints)
with arcpy.da.UpdateCursor(ptSelection, updateFieldsList) as updateRows:
for updateRow in updateRows:
# store the Join value of the row being updated in a keyValue variable
keyValue = updateRow[0]
# verify that the keyValue is in the Dictionary
if keyValue in valueDict:
# transfer the values stored under the keyValue from the dictionary to the updated fields.
for n in range (1,len(sourceFieldsList)):
updateRow[n] = valueDict[keyValue][n-1]
updateRows.updateRow(updateRow)
... View more
04-29-2022
02:26 PM
|
1
|
0
|
1380
|
|
POST
|
valueDict is undefined in your code snippet so please update if I'm missing something. If you don't have a coded value domain in the geodatabase for the values in Field4, you'll have to define them in your code. I would suggest a dictionary. field4_coded_values = {
"MH": "MOBILE HOME",
"SFR": "SINGLE FAMILY RES",
# etc...
} Then look up your abbreviation in the dictionary to get the the full value. Passing the look up value (abbreviation) in as the second argument means that is what will be returned if it doesn't exist. for updateRow in updateRows:
# Look up full text of abbreviation. Return original value if not found.
field4 = updateRow[5]
field4_out_value = field4_coded_values.get(field4, field4)
updateRow[5] = field4_out_value
... View more
04-27-2022
04:01 PM
|
0
|
2
|
1449
|
|
POST
|
And to clarify further, I currently have the utility functions in their own .py file that is imported into each individual tool's .py file. This is working, but I'd like it to be in the Python toolbox .pyt file so I can encrypt it.
... View more
04-22-2022
07:42 AM
|
0
|
0
|
3256
|
|
POST
|
Thanks Dan. It does have an alias. While double checking, I decided to check something else and I think I found the problem. I'm importing separate .py files into my Python toolbox (like the Spatial Analyst Supplemental Tools). I took that part out and it seems to import fine. Ultimately what I'm trying to do is have a Python toolbox with some basic utility functions used by many tools. Each tool is saved as a separate .py file and imported into the Python toolbox. I would like to be able to call functions defined in the Python Toolbox from the separate, imported .py scripts. Testing arcpy.ImportToolbox() was just the first step.
... View more
04-22-2022
07:21 AM
|
0
|
1
|
3257
|
|
POST
|
I'm not sure what I'm doing wrong with arcpy.ImportToolbox() in ArcGIS Pro 2.9. No matter what I do, it always errors with OSError: The toolbox file C:\temp\MyToolbox.pyt was not found. There's not much to it besides calling arcpy.ImportToolbox(). What am I missing?
... View more
04-21-2022
04:02 PM
|
0
|
5
|
3326
|
|
POST
|
Is this any Different in ArcGIS Pro? I used this approach in ArcMap but in transitioning to ArcGIS Pro (2.9), I get an error Traceback (most recent call last):
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\arcobjects\_base.py", line 90, in _get
return convertArcObjectToPythonObject(getattr(self._arc_object, attr_name))
AttributeError: FieldMap: Get attribute outputField does not exist
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\...", line 223, in execute
address_eid = fm_tf_eid.outputField
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\arcobjects\_base.py", line 96, in _get
(attr_name, self.__class__.__name__))
AttributeError: The attribute 'outputField' is not supported on this instance of FieldMap. This is from the geoprocessing window in ArcGIS Pro running my script in a Python toolbox.
... View more
04-19-2022
04:31 PM
|
1
|
0
|
2988
|
|
IDEA
|
When inspecting the connectionProperties of a Layer object in ArcGIS Pro (2.9), the value of the 'server' property of 'connection_info' is inconsistent depending if the database connection was created in ArcMap or ArcGIS Pro. For example, with Oracle, the 'server' property is 'sde' on a layer added from a database connection created in ArcMap but it's the proper name when the layer uses a database connection created from ArcGIS Pro. The same is true for adding a layer to the map or importing a map from an mxd. Could the 'server' property be derived more correctly when inspecting the connectionProperties of a Layer added (or imported) from an ArcMap database connection?
... View more
04-19-2022
10:49 AM
|
2
|
0
|
723
|
|
POST
|
@MattStayner wrote: If I go with that solution, I'm still stuck with using the Editor widget, which doesn't really fit into my flow. Is there a way I can use that tool, but hide the widget and pass in the feature before I start it? Possibly, but I haven't worked with editing in 4.x yet so I really can't advise how to go about customizing that functionality. Hopefully someone else with more experience can contribute to this conversation.
... View more
04-06-2022
08:10 AM
|
0
|
0
|
4123
|
|
POST
|
Moving a single feature seems pretty straightforward with 4.x. Have you seen this demo of the Editor Widget? It got some major updates in the 4.23 release.
... View more
04-05-2022
12:35 PM
|
0
|
2
|
4143
|
|
POST
|
If it was working fine, it must be an access issue. I would start by logging in to the computer running the scheduled task as the user the scheduled task is running as, then see if you can run the script inside of an IDE there. If that works, then there's a configuration issue with Windows Task Scheduler. If it doesn't work, you should be able to debug it from the IDE.
... View more
03-22-2022
11:03 AM
|
0
|
1
|
3761
|
|
POST
|
Either your field value is not empty (maybe a space or something) or you're not adding the expression to the display property of the html style of the element. See step 8 in this guide: Hide Field in Pop-up Using Arcade - Esri Community
... View more
03-16-2022
08:03 AM
|
0
|
4
|
3668
|
|
POST
|
If you want to zoom to a feature by attribute (560001), the Search widget or Query() method should both work on a graphics layer. The source for the Search widget will be a LayerSearchSource, which notes that "Feature layers created from client-side graphics are not supported." If using Query, you'll also need to use goTo() to zoom the map. The goTo() method will also accept lat, long coordinates to zoom in.
... View more
03-14-2022
07:23 AM
|
0
|
0
|
3223
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | Friday | |
| 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 |