|
POST
|
With Arcade: Create a new integer field Calculate the field, change language to Arcade, use the script below The rows you want have IntegerField = 1. You can use that to eg Select Layer By Attribute Query definition Delete all other rows var fid = $feature.In_FID
var min_days = Min(Filter($featureset, "In_FID = @fid"), "Days")
return IIF($feature.Days == min_days, 1, 0)
... View more
06-27-2022
02:23 AM
|
0
|
0
|
3389
|
|
POST
|
With Python: backup your table copy/paste the script below, change the table variable, run # read table
fields = ["In_FID", "Days"]
table = "table_path_or_layer_name"
table_data = [row for row in arcpy.da.SearchCursor(table, fields)]
# create a dictionary {fid: min(days)}
fids = set([td[0] for td in table_data]) # unique fids
min_days = dict()
for fid in fids:
days = [td[1] for td in table_data if td[0] == fid]
min_days[fid] = min(days)
# delete all rows where Days > min(Days[fid])
with arcpy.da.UpdateCursor(table, fields) as cursor:
for fid, days in cursor:
if days > min_days[fid]:
cursor.deleteRow()
... View more
06-27-2022
02:17 AM
|
0
|
1
|
3389
|
|
POST
|
The When() function is set up correctly. If you don't get output, try these: Make sure you actually included the expression in your form Make sure your field names are correct and that you use the actual names, not the aliases try using 22222.0 (a double) as default value try the written-out version of When(): var A = $feature.A
var B = $feature["B_B"]
if(A=='010417192124' && B == 'Pre2000s') {
return 2.3
}
return 22222 does that have to be a number or can I put 'No value'? It has to be a number. So either a default value like your 22222 (or the more common 99999) or you could return null, which leaves the field empty.
... View more
06-26-2022
10:25 PM
|
1
|
0
|
1418
|
|
POST
|
It's line 15 of my code. It found at least 1 domain, but one of the domains' codedValue attribute is null. This might be a ranged domain. You could try replacing line 15 with this: domain_values = dict()
for d in domains:
try:
domain_values[d.name] = list(d.codedValues.keys())
except AttributeError:
print(f"{d.name} is not a coded value domain.")
... View more
06-25-2022
05:40 AM
|
1
|
0
|
4665
|
|
POST
|
Have you tried using the qualified sequence name? NextSequenceValue("SCAOPFOwnerTest.ParcelNumberAssignmentSequence") creating the sequence with the ArcGIS tool (Create Database Sequence (Data Management)—ArcGIS Pro | Documentation)?
... View more
06-24-2022
10:13 AM
|
0
|
1
|
9199
|
|
POST
|
ArcGIS Pro uses Python 3.X (ArcMap uses 2.7.X I think). TKinter was renamed to tkinter. You could try using that. In my experience, Pro and Python guis don't play very well together. Save your work before you try, there's a good chance Pro will crash or freeze. I belive the way to do something like that would be writing your own AddIn. But that seems like a lot of hassle for a simple dialog window. For a simple message box, something like this could suffice: import webbrowser
def open_dialog_box(message):
path = "H:/dialog_box.txt" # some location you have write access to
with open(path, "w") as f:
f.write(message)
webbrowser.open(path)
open_dialog_box("Hey there!")
... View more
06-24-2022
10:04 AM
|
0
|
1
|
2494
|
|
POST
|
this will raise exceptions in at least these scenarios: you input a shapefile you input a flag_field that is not Integer probably when you have range domains in your database
... View more
06-24-2022
09:53 AM
|
1
|
1
|
4701
|
|
POST
|
Huh, I would have guessed that it's easier in Python than in Arcade, but it certainly took longer to write... Same setup as in your Arcade question (Flag row if any field has invalid domain values - Esri Community). import pathlib
def check_domain_values(in_features, flag_field, database=None):
"""sets the flag field to 0 if at least 1 field value is not in the field's domain, else 1
in_features: str, path to the feature class or table
flag_field: str, name of the field that has the flag
database: str, path to the database. defaults to the parent directory of the feature class, should be set when the fc is in a feature dataset.
"""
if database is None:
database = pathlib.Path(in_features).parent
domains = arcpy.da.ListDomains(database)
domain_values = {d.name: list(d.codedValues.keys()) for d in domains}
print(f"domain_values: {domain_values}\n")
fields = arcpy.ListFields(in_features)
allowed_values = {f.name: domain_values[f.domain] for f in fields if f.domain not in ["", None]}
fields_with_domains = list(allowed_values.keys())
print(f"allowed values: {allowed_values}\n")
print(f"domain fields: {fields_with_domains}\n")
fields = fields_with_domains + [flag_field]
with arcpy.da.UpdateCursor(in_features, fields) as cursor:
for row in cursor:
ok = True
for i, value in enumerate(row):
try:
field = fields[i]
if value not in allowed_values[field]:
ok = False
break
except KeyError: # flag_field is not in the dictionary
pass
new_row = list(row)
new_row[-1] = ok
cursor.updateRow(new_row) fc = arcpy.Describe("TestPoints").catalogPath
check_domain_values(fc, "IntegerField") domain_values: {'MyDomain': ['Value 1', 'Value 2', 'Value 3']}
allowed values: {'TextField': ['Value 1', 'Value 2', 'Value 3']}
domain fields: ['TextField']
... View more
06-24-2022
09:46 AM
|
2
|
2
|
4701
|
|
POST
|
Point FC with coded value domain ["Value 1", "Value 2", "Value 3"] on TextField: Using CalculateField, I can insert other values (same works with arcpy cursors and attribute rules): Calculation Attribute Rule on that point fc, field IntegerField, triggers insert & update function code_is_in_domain(domain_dict, code) {
for(var i in domain_dict.codedValues) {
if(domain_dict.codedValues[i].code == code) {
return true
}
}
return false
}
var attributes = Dictionary(Text($feature)).attributes // a dictionary
for(var field in attributes) { // loop through the dictionary keys ( = field names)
var domain_dict = Domain($feature, field)
if(domain_dict != null && !code_is_in_domain(domain_dict, $feature[field])) {
return 0//"INVALID"
}
}
return 1//"VALID" (you could of course also populate a text field with that rule, or you could return booleans and use it as constraint rule) I can still input values that are not in the domain, but now the flag gets set:
... View more
06-24-2022
08:58 AM
|
2
|
0
|
1454
|
|
POST
|
You can set a fixed scale for map frames in layouts: Map frame constraints—ArcGIS Pro | Documentation For working in the actual map, you can utilize a custom scale: ´Then you can pan (and zoom) to a differnet part of your map and select your scale from the scale list: If you only want to see your custom scale, you can delete all other scales from the list...
... View more
06-24-2022
02:41 AM
|
0
|
1
|
5413
|
|
POST
|
Very basic: If you don't have one already, create a feature class for the trees (probably points) with a text field. When you planned the tree, fill out the text field with the current date (you could also use a date field, but working with date fields becomes tiresome later on [time zones, different sql formattings etc.]). Symbolize the trees by unique values: Kinda basic: Use Summarize Attributes to create a table containing the dates and a tree count for each date: In your layout, insert a table frame, point it to the summary table, show the date and count fields: Advanced: Automate the process with Attribute Rules. Create a table with a text field and an integer field (this will mimic the summary table). Create a Calculation Attribute Rule on your tree fc (add GlobalIDs first): // Calculation Attribute rule on tree fc
// field: empty
// triggers: update (I'm assuming you don't insert or delete tree features)
// Exclude from application evaluation: checked
// determine if the planning date changed
// it changed if it was previously empty or if we previously edited the tree on another day
var current_date = Text(Today(), "Y-MM-DD")
var original_date = $originalfeature.TextField
var date_changed = (original_date == null) || (original_date != current_date)
// if the date didn't change, we don't need to do anything.
if(!date_changed) { return }
// load the summary table
var summary_table = FeatureSetByName($datastore, "TestTable")
// create empty arrays that will hold edits to be made to the summary table
var adds = []
var updates = []
// if the date changed, we have to increase the cuurent date's count in the summary table.
// if the current date isn't there yet, we have to create it
var sql = "TextField = @current_date"
var summary_current_date = First(Filter(summary_table, sql))
if(summary_current_date == null) { // nothing found -> insert row
var new_row = {"attributes": {"TextField": current_date, "IntegerField": 1}}
Push(adds, new_row)
} else { // row found, increase count
var updated_row = {"objectID": summary_current_date.OBJECTID, "attributes": {"IntegerField": summary_current_date.IntegerField + 1}}
Push(updates, updated_row)
}
// return current_date to the tree feature's date field and tell ArcGIS to update the summary table
return {
"result": {"attributes": {"TextField": current_date}},
"edit": [{
"className": "TestTable",
"adds": adds,
"updates": updates
}]
} Now, when you update a tree feature, the entry in the summary table with today's date will be inserted or its count increased. If you point your table frame to the new summary table, the changes will be reflected there: You will probably still have to refresh the symbology after each day... Also, charts!:
... View more
06-24-2022
02:25 AM
|
0
|
0
|
1060
|
|
POST
|
Something like this? var fsParcel = FeatureSetByName($datastore, "Parcel", ["APN", "Unit"]) // load Unit, too
var fsParcelIntersect = Intersects(fsParcel, $feature)
// this block returns the APN of the parcel whose unit is equal to the address's unit
for(var Parcel in fsParcelIntersect) {
if(Parcel.Unit != null && Parcel.Unit == $feature.Unit) {
return Parcel.APN
}
}
// if we land here, none of the intersected parcels have the address's unit
// just return the first one
var Parcel = First(fsParcelIntersect)
return IIF(Parcel == null, null, Parcel.APN)
... View more
06-23-2022
10:12 PM
|
0
|
1
|
1982
|
|
POST
|
Reason for your error: The second argument of Filter is a SQL where clause, you only supply a value, not the where clause. Other things: You don't have to load the pipelines a second time. Even if PipelineSegmentsNumber is 1, you can still just call Sum on that feature set. That makes the code easier (and your code would not give the correct result for multiple pipeline segments). You load LENGTH but you want to get the sum of PIPE_LENGTH. After you intersect the leak feature with the pipelines, you're gonna need a null check to make sure you got an intersecting pipeline. The variable feature_field isn't used in your script. The variable intersecting_field is used, but you type out GIS_PIPE_ID multiple times, so you could do it one more time... // This rule will populate the edited features field LENGTH with a sum of PIPE_LENGTH from selected pipelines with same GIS_PIPE_ID
// Create feature set to the intersecting class
var Pipelines = FeatureSetByName($datastore, "Pipelines", ["GIS_PIPE_ID", "PIPE_LENGTH"], true)
// Intersect the edited feature with the feature set and retrieve the first feature
var search_feature = Buffer($feature, 0.5, "meter")
var IntersectedPipe = First(Intersects(Pipelines, search_feature))
// Return null if no pipeline was intersected
if(IntersectedPipe == null) {
return null
// or return an error message:
//return {"errorMessage": "No pipeline was intersected"}
}
//select pipelines by GIS_PIPE_ID
var ID = IntersectedPipe.GIS_PIPE_ID
var SqlWhere = "GIS_PIPE_ID = @ID"
var SelectAllSegmentsSameID = Filter(Pipelines, SqlWhere)
// return the sum of PIPE_LENGTH
return Round(Sum(SelectAllSegmentsSameID, "PIPE_LENGTH"), 2)
... View more
06-23-2022
04:10 AM
|
1
|
0
|
1708
|
|
POST
|
It sounds like you did not create the rule for the polygon. If your polygons are static (you don't edit them), you can do all of the work from within the point fc: // Calculation Attriute Rule in TestPoints
// field: empty
// triggers: insert, update, delete
var fs_polygons = FeatureSetByName($datastore, "TestPolygons", ["GlobalID"], true)
var updates = []
// update all polygons that intersect the feature
for(var poly in Intersects($feature, fs_polygons)) {
var point_count = Count(Intersects(poly, $featureset))
if($editcontext.editType == "DELETE") {
// $feature is still there hwen this rule is executed, so we have to substract 1
point_count -= 1
}
Push(updates, {globalID: poly.GlobalID, attributes: {IntegerField: point_count}})
}
// update all polygons that intersected the original feature (before update)
if($editcontext.editType == "UPDATE") {
for(var poly in Intersects($originalfeature, fs_polygons)) {
var point_count = Count(Intersects(poly, $featureset))
Push(updates, {globalID: poly.GlobalID, attributes: {IntegerField: point_count}})
}
}
return {
edit: [{className: "TestPolygons", updates: updates}]
} Creating points: Moving points: Deleting points: Literal edge cases:
... View more
06-22-2022
01:32 AM
|
0
|
0
|
3142
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 01-30-2023 09:57 AM | |
| 1 | 05-18-2023 12:51 AM | |
| 1 | 03-05-2023 12:46 PM | |
| 1 | 12-07-2022 07:01 AM | |
| 1 | 06-21-2022 08:27 AM |
| Online Status |
Offline
|
| Date Last Visited |
02-03-2024
06:14 PM
|