POST
|
When it comes to Esri getting their money, I've found them to be helpful 😉 Are you able to log into My Esri to see the your organization? Under "Overview", "Esri Contacts", you should find contact information for a Customer Service Representative who should be able to assist you with transitioning your licenses.
... View more
07-09-2024
04:22 PM
|
0
|
0
|
377
|
POST
|
Maybe this is a bug in how updateConnectionProperties() works on workspaces. I have had luck iterating over each layer rather than applying to the whole map. for layer in mymap.listLayers():
layer.updateConnectionProperties(
current_connection_info=r'C:\oldpath\database.gdb',
new_connection_info=r'C:\newpath\database.gdb',
ignore_case=True
)
... View more
07-09-2024
12:09 PM
|
1
|
0
|
227
|
POST
|
The conditions are evaluated in order so put the most important one first and use elif for the other conditions. You'll also need to update the parameters in your function to accept Field2. # Expression
Reclass(!Field1!, !Field2!)
# Code Block
def Reclass(field1, field2):
if field2 == "y":
return "4"
elif field1=="x":
return "1"
elif field1 =="y":
return "2"
else:
return "3"
... View more
07-09-2024
10:58 AM
|
3
|
1
|
347
|
POST
|
You can use an f-string to dynamically insert the field name into the calculate field expression. fields = arcpy.ListFields("perc_test_table")
for field in fields:
if field.name not in ['OBJECTID', 'Shape_Length', 'Shape_Area', 'SumField', 'Spatial_ID']:
arcpy.management.CalculateField(table, f"{field.name}_perc", f"!{field.name}!/!SumField!", "PYTHON3", field_type="DOUBLE")
... View more
07-01-2024
01:53 PM
|
1
|
0
|
257
|
POST
|
Some of these topics would make some interesting blog articles, @HaydenWelch. Hopefully you'll consider sharing your methods with the world.
... View more
06-18-2024
01:21 PM
|
0
|
1
|
278
|
POST
|
The final solution must not use arcpy at all? What format is your source data in and what format do you need the output in?
... View more
06-17-2024
02:03 PM
|
0
|
2
|
475
|
POST
|
This is what I do and it seems to work. Maybe you're just missing clearMessage() def updateParameters(self, parameters):
"""Modify the values and properties of parameters before internal
validation is performed. This method is called whenever a parameter
has been changed."""
project_id = parameters[0].valueAsText
valid_project_ids = ['123', '456', '789']
error_msg = f'Unrecognized project ID; please enter one of the following: {valid_project_ids}'
if project_id:
if project_id not in valid_project_ids:
project_id.setErrorMessage(error_msg)
else:
project_id.clearMessage()
else:
project_id.setErrorMessage(error_msg)
return
... View more
06-14-2024
01:26 PM
|
0
|
0
|
544
|
POST
|
Thanks for chiming in, @anonymous_geographer! Seeing as I'm on Pro 3.1.3, it makes sense that I am not able to replicate the issue. Looking forward to your results with Pro 3.3.
... View more
06-14-2024
11:20 AM
|
0
|
1
|
523
|
POST
|
@JamesMorrison1 wrote: Could it be related to how Python converts the value 1040058 to a string? That doesn't seem reasonable to me, but you can test that with print(sdeReturn) before you do all that parsing and formatting.
... View more
06-14-2024
09:31 AM
|
0
|
1
|
559
|
POST
|
I tested your code in SQL Developer (Oracle 19c) and in Python (ArcGIS Pro 3.1.3) and the SDE_ID value is the same both times: the correct (non-negative) id.
... View more
06-14-2024
07:30 AM
|
1
|
3
|
568
|
POST
|
The latest on this is to expect it in the June release.
... View more
06-13-2024
01:11 PM
|
0
|
0
|
227
|
POST
|
I have a question about your logic. You are creating a new field called DATE (which is a reserved word, so I suggest you pick a different name) and setting all the (selected) records to the same value: StartDate Then you are making a selection on that same DATE field where the value is between StartDate and EndDate. Wouldn't that always select everything you just calculated? Why do you need the first step to create and calc the DATE field? Here's an example using an UpdateCursor and a where clause. I didn't put in a field name because I'm not sure what you actually want to compare StartDate to. expression = f"your_field_name >= date '{StartDate}' and your_field_name <= date '{EndDate}'"
with arcpy.da.UpdateCursor(Project_Layer, ["Symbology"], where_clause=expression) as u_cursor:
for row in u_cursor:
u_cursor.updateRow(["Beyond 90"]) This SQL expression should work in a file geodatabase and SQL Server. I'm not sure what dbms your data is in.
... View more
06-12-2024
10:02 AM
|
1
|
1
|
743
|
POST
|
Since you are choosing a layer as your input parameter, there's no need to get the layer from the Project again. def UpdateSymbology():
# To allow overwriting outputs change overwriteOutput option to True.
arcpy.env.overwriteOutput = True
# Model Environment Setting
Projects_Layer = arcpy.GetParameter(0) # Input parameter
# ... rest of the code ...
... View more
06-12-2024
08:15 AM
|
0
|
1
|
318
|
POST
|
Looking at the documentation, the sample code does not use the output layer for anything. Try without chaining the outputs, only use the input layer. import arcpy
def UpdateSymbology():
# To allow overwriting outputs change overwriteOutput option to True.
arcpy.env.overwriteOutput = True
# Model Environment Setting
aprx = arcpy.mp.ArcGISProject("CURRENT")
mp = aprx.activeMap
Projects = arcpy.GetParameterAsText(0) # Input parameter
Projects_Layer = mp.listLayers(Projects)[0]
# Process: Add Field to Projects layer that is Date Only type (Add Field) (management)
arcpy.management.AddField(
in_table=Projects_Layer,
field_name="Date",
field_type="DATEONLY",
field_alias="Date"
)
# Process: Calculate added Date Only field equal to the exisiting 'Start Date' text field (Calculate Field) (management)
arcpy.management.CalculateField(in_table=Projects_Layer, field="Date", expression="!Start_Date!")
# Process: Select Layer By Date And Time (Select Layer By Date And Time) (ca)
arcpy.ca.SelectLayerByDateAndTime(
in_layer_or_view=Projects_Layer,
selection_type="NEW_SELECTION",
time_type="SINGLE_TIME_FIELD",
date_field="Date",
selection_options=["DATE"],
date_selection_type="DATE_RANGE",
start_date=StartDate,
end_date=EndDate
)
# Process: Calculate Field with Selection to "Beyond 90" (Calculate Field) (management)
arcpy.management.CalculateField(in_table=Projects_Layer, field="Symbology", expression="Beyond 90")
if __name__ == '__main__':
UpdateSymbology()
print("FIN")
... View more
06-11-2024
07:35 AM
|
1
|
5
|
498
|
POST
|
In this latest code, StartDate and EndDate are undefined when you call them in SelectLayerByDateAndTime().
... View more
06-10-2024
04:03 PM
|
0
|
7
|
523
|
Title | Kudos | Posted |
---|---|---|
2 | 4 weeks ago | |
2 | 07-31-2024 09:15 AM | |
1 | 07-29-2024 11:40 AM | |
1 | 05-21-2021 03:18 PM | |
1 | 07-09-2024 12:09 PM |