|
POST
|
Is it possible to include these custom output fields in the geocode results with the "Minimal" output fields option? I can only get them to come through with "All" output fields, which is way too much. Geocode Addresses (Geocoding)—ArcGIS Pro | Documentation
... View more
11-12-2021
02:23 PM
|
0
|
1
|
3856
|
|
BLOG
|
@ChaseSchieffer, using the methods outlined by Richard in this blog article, you would first need to read all the related data into a dictionary. I can't figure out how you would do it with max() on the date field using a SearchCursor so you could use ArcSDESQLExecute() if your data is in an rdbms. Otherwise, you can just manipulate the data with Python in a SearchCursor. That would look something like this. # Build dictionary with only the most recent related records.
latest_related_data = {}
with arcpy.da.SearchCursor(related_table, ["rel_id", "rel_date", "other_rel_field", "etc"]) as s_cursor:
for rel_id, rel_date, other_rel_field, etc in s_cursor:
related_record = latest_related_data.get(rel_id)
# Only update the entry if it's a new id or the date is newer than what's there.
if not related_record or rel_date > related_record["rel_date"]:
latest_related_data[rel_id] = {
"rel_date": rel_date,
"other_rel_field": other_rel_field,
"etc": etc
}
# Update the hydrant feature class with something from the latest related record.
with arcpy.da.UpdateCursor(hydrant_fc, ["id", "other_field"]) as u_cursor:
for id, other_field in u_cursor:
# Find the related record for this hydrant id.
# This will error if the hydrant id doesn't have a related record.
# Maybe use dict.get() instead?
latest_related_record = latest_related_data[id]
# Do something with the data.
# You can get data with individual field names from the related table.
print(f"The latest related data for Hydrant ID {id} ({other_field})is from {latest_related_record['task_date']}")
print(f"\tother_rel_field{latest_related_record['other_rel_field']}")
print(f"\tetc{latest_related_record['etc']}")
... View more
11-10-2021
10:18 AM
|
1
|
0
|
24422
|
|
POST
|
Change the equality statements (==) to assignment (=) for everything that's not part of an if statement. updateFields = ["BarrierTyp", "StructureCategory", "StructureClass", "Diversion"]
with arcpy.da.UpdateCursor(schemaone, updateFields) as cursor:
for row in cursor:
if row[0] is None:
continue
if row[0] == "Water Diversion":
row[1] = 3
row[2] = 31
row[3] = 1
elif row[0] == "Manmade Dam":
row[1] = 9
row[2] = 0
row[3] = 0
else:
row[1] = 0
row[2] = 0
row[3] = 0
cursor.updateRow(row)
... View more
11-02-2021
08:35 AM
|
3
|
0
|
1646
|
|
POST
|
I've seen some of the Esri GP tools do this. When you run the tool and then copy the Python snippet, it'll put "#" for the optional parameters that were left empty. I have never done this explicitly with my Python toolboxes and I don't see a need for it.
... View more
10-27-2021
08:11 AM
|
1
|
0
|
6194
|
|
POST
|
I'll just toss out that you could also simply check for "truthiness" if isOptional:
# isOptional has a value.
# do a thing.
else:
# isOptional has no value.
# handle it.
... View more
10-26-2021
03:58 PM
|
1
|
0
|
5976
|
|
POST
|
I would say you should find a way to use a default value if OptionalParameter is not defined and write your code logic in a way that can handle any valid value (including the default).
... View more
10-26-2021
02:21 PM
|
1
|
6
|
6001
|
|
POST
|
The function parameters in the code block should not have exclamation marks, that's only for the field names in the expression. Get rid of all ! characters in the code block.
... View more
10-26-2021
09:41 AM
|
1
|
0
|
9232
|
|
POST
|
That code block is terribly difficult to interpret being all on one line like that. Try making a multiline string with three single quotes for the code block. myFun_def = '''def myFun(LocationStartNumber,StreetDirection,StreetName,StreetWay,UnitNumber):
if UnitNumber is None:
UnitNumber = ''
if LocationStartNumber == 0:
if StreetName == 'TBD':
return StreetName
else:
val = '{} {} {} {}'.format(StreetDirection,StreetName,StreetWay,UnitNumber)
return val.strip()
else:
return '{} {} {} {} {}'.format(LocationStartNumber,StreetDirection,StreetName,StreetWay,UnitNumber)
'''
arcpy.management.CalculateField(
in_table=finalTable,
field="SiteAddress",
expression="myFun(!LocationStartNumber!,!StreetDirection!,!StreetName!,!StreetWay!,!UnitNumber!)",
expression_type="PYTHON_9.3",
code_block=myFun_def
)
... View more
10-26-2021
09:08 AM
|
1
|
1
|
3272
|
|
POST
|
No, but I have not revisited it either. Do you have any suggestions?
... View more
10-21-2021
03:28 PM
|
0
|
0
|
5835
|
|
POST
|
Wouldn't it be more efficient to use count() instead of reading all the data? select COUNT(*) from owner.table_name
... View more
10-21-2021
03:24 PM
|
1
|
2
|
10075
|
|
POST
|
What happens if you take out the semicolon at the end of the sql?
... View more
10-21-2021
01:57 PM
|
0
|
0
|
10087
|
|
POST
|
Here's another solution to consider. s = "West Wind Ruisseau"
s = s.rsplit(" ", 1)
last_word = s.pop()
s = " ".join([last_word] + s)
... View more
10-21-2021
10:05 AM
|
2
|
1
|
4037
|
|
POST
|
Work with date fields—ArcGIS Online Help | Documentation All dates in ArcGIS Online are assumed to be UTC. You might need to convert the time before you upload the data.
... View more
10-18-2021
09:02 AM
|
0
|
0
|
7044
|
| 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 |