POST
|
A general form could look like this: // define which attributes to return var return_attributes = ["lastinspdate", "nextinspdate"] // load the featureset var fs = FeatureSetByName($map, "InspInspectionDates", ['central_asset_id', 'lastinspdate', 'nextinspdate'], false) // filter for id and dates in future var ref_id = $feature["CENTRAL_AS"] var dt = Now() var filt = "central_asset_id = @ref_id AND nextinspdate > @DT" // get the next future inspection date var filtered_fs = OrderBy(Filter(fs, filt), "nextinspdate") var cou = First(filtered_fs) if(cou == null) { return "No future inspection found" } var all_attributes = Dictionary(Text(cou))["attributes"] var popup_lines = [] for(var a in return_attributes) { var att = return_attributes[a] var val = all_attributes[att] var line = `${att}: ${val}` Push(popup_lines, line) } return Concatenate(popup_lines, TextFormatting.NewLine) This is useful if you want to keep the expression expandable to include more/less fields later. If you don't need that, you can just hardcode it: // define which attributes to return var return_attributes = ["lastinspdate", "nextinspdate"] // load the featureset var fs = FeatureSetByName($map, "InspInspectionDates", ['central_asset_id', 'lastinspdate', 'nextinspdate'], false) // filter for id and dates in future var ref_id = $feature["CENTRAL_AS"] var dt = Now() var filt = "central_asset_id = @ref_id AND nextinspdate > @DT" // get the next future inspection date var filtered_fs = OrderBy(Filter(fs, filt), "nextinspdate") var cou = First(filtered_fs) if(cou == null) { return "No future inspection found" } var popup_lines = [ `Last inspection: ${cou["lastinspdate"]}`, `Next inspection: ${cou["nextinspdate"]}`, ] return Concatenate(popup_lines, TextFormatting.NewLine)
... View more
06-13-202307:09 AM
|
0
|
1
|
360
|
POST
|
Untested, supply your table and field names in lines 13 & 17. import arcpy def mean(values): values = [v for v in values if v is not None] try: return sum(values) / len(values) except ZeroDivisionError: raise ValueError("No non-null values in input list!") # get the morning and evening readings from the update table (dict with id as key) update_rows = { i: [m, e] for i, m, e in arcpy.da.SearchCursor("UpdateTable", ["GaugeID", "Morning", "Evening"]) } # update the gauge layer with arcpy.da.UpdateCursor("Gauges", ["GaugeID", "AverageReading"]) as cursor: for i, avg in cursor: try: avg = mean(update_rows[i]) except KeyError: print("GaugeID not found in update table: " + str(i)) continue except ValueError: print("Could not calculate average for GaugeID " + str(i)) continue cursor.updateRow([i, avg])
... View more
06-13-202305:00 AM
|
0
|
0
|
96
|
POST
|
This is expected behavior, current is different to a file path. When you use current, ArcGIS knows that you want to work with the currently opened project. When you use a file path, ArcGIS loads that project into RAM, without actually opening it in the application. IT does all its operations on that copy in RAM, regardless of whether you currently have opened that project or not. Your code works perfectly fine. Just add that piece at the end of it and then take a look at the copy: aprx.saveACopy(r"project_folder\ProjectCopy") You can also use the save() method, but for that to work, you need to call the script from outside the current project.
... View more
06-12-202312:33 PM
|
0
|
2
|
303
|
POST
|
Maybe use the complete name in line 11? Database.DataOwner.PipelineJunction
... View more
06-12-202303:31 AM
|
0
|
1
|
220
|
POST
|
Something like this? // split the field into single districts var districts = Split($feature.districts, ", ") // get a count for each district var counts = Dictionary() for(var i in districts) { var d = districts[i] counts[d] = IIf(HasKey(counts, d), counts[d], 0) + 1 } // combine districts and counts var output = [] for(var d in counts) { Push(output, counts[d] + " * " + d) } // return return Concatenate(output, ", ")
... View more
06-09-202302:34 PM
|
1
|
0
|
163
|
POST
|
Does it work if you insert this after line 9? // check if the DataOwner is included in the dictionary if(!HasKey(partners, featureDataOwner)) return false
... View more
06-09-202302:04 PM
|
1
|
1
|
175
|
POST
|
表达式返回“块”或“没有”。这些圣rings are used to show (block) or hide (none) the element in the popup's HTML code. To get what you want, you'll have to create a new expression that returns the inverse of the expression you have (just switch the return values in the IIf function). You can then create a new HTML element before Survey A:
You have not submitted your field information survey yet. ... ... This solution is for Map Viewer Classic. If you're working with the current Map Viewer, you can also use an Arcade element, do all your decisions in there and return the HTML code.
... View more
06-09-202310:25 AM
|
0
|
1
|
519
|
POST
|
Good catch, but this site would be riddled with semi-correct answers if I did this on purpose It was probably a copy/paste issue, I fixed it. Glad you got it to work!
... View more
06-09-202310:15 AM
|
0
|
0
|
114
|
POST
|
Yes, it is because of null values. To fix it, you can insert this after line 7 to ignore features with null values in either field: fs = Filter(fs, "LGA IS NOT NULL AND Activity IS NOT NULL")
... View more
05-25-202311:21 PM
|
1
|
1
|
231
|
POST
|
Export your table to a gdb and run either the Field Calculator or the script on that exported table. If the errors persist, I'm absolutely out of ideas.
... View more
05-25-202302:26 PM
|
0
|
1
|
167
|
POST
|
var赛格= $特性。(Featur SEG_ID var addr =过滤器esetByName($datastore, "Address_fc", ["STNO", "SEG_ID", "SIDE_OF_RD"], false), "SEG_ID = @seg") var left_addr = Filter(addr, "SIDE_OF_RD = 'Left'") var right_addr = Filter(addr, "SIDE_OF_RD = 'Right'") return{ result: {attributes: { FROMLEFT: Min(left_addr, "STNO"), TOLEFT: Max(left_addr, "STNO"), FROMRIGHT: Min(right_addr, "STNO"), TORIGHT: Max(right_addr, "STNO"), }} }
... View more
05-25-202301:00 PM
|
1
|
2
|
158
|
POST
|
I have no idea why this is happening... Try doing it with a Python script instead (not in the Field Calculator, in the Python Window): table = "TestPolygons" # the table path or layer name sort_field = "DateField1" # the sort field number_field = "IntegerField1" # the field that will be calculated i = 1 with arcpy.da.UpdateCursor(table, [number_field], sql_clause=[None, "ORDER BY {}".format(sort_field)]) as cursor: for row in cursor: row[0] = i cursor.updateRow(row) i += 1
... View more
05-25-202308:38 AM
|
0
|
3
|
430
|
POST
|
But this is for ArcGIS Pro, and I didn't realize that you posted this question in the ArcMap group. If you're working with ArcMap, it's much easier to do this task with a little Python script. Open your Python Window Paste in this script, edit the first three lines and execute (hit Enter). table = "TestPolygons" # the table path or layer name text_field = "TextField1" # the sort field number_field = "IntegerField1" # the field that will be calculated i = 1 with arcpy.da.UpdateCursor(table, [text_field, number_field], sql_clause=[None, "ORDER BY {}".format(text_field)]) as cursor: for row in cursor: row[1] = i cursor.updateRow(row) i += 1
... View more
05-25-202308:27 AM
|
1
|
0
|
246
|
POST
|
Switch language to Arcade, use this expression (change "TextField1" to the name of your field): var oid = $feature.OBJECTID var txt = $feature.TextField1 var previous = Filter($featureset, "TextField1 < @txt") var same_lower = Filter($featureset, "TextField1 = @txt AND OBJECTID < @oid") return Count(previous) + Count(same_lower) + 1
... View more
05-25-202304:26 AM
|
0
|
2
|
260
|
POST
|
The behavior you want isn't that simple... Your two rules influence each other. The first rule looks at the field that gets changed by the second rule and vice versa. It might be better to do it in one rule: // Calculation Attribute RUle // field: empty! // triggers: update var lifecycle = $feature.TextField1 var old_lifecycle = $originalfeature.TextField1 var retire_date = $feature.DateField1 var old_retire_date = $originalfeature.DateField1 // Was the date changed to a non-null value? var abandon_feature = retire_date != null && retire_date != old_retire_date // Was the lifecycle changed to "ABANDONED"? var feature_was_abandoned = lifecycle == "ABANDONED" && lifecycle != old_lifecycle // Calculate the new values var new_retire_date = When( abandon_feature, retire_date, // the date was changed by the user, use that value feature_was_abandoned, Date(), // the lifecycle was changed to "ABANDONED", use current date lifecycle != "ABANDONED", null, // the feature is not abandoned, set the date to null retire_date // the feature is abandoned, some other field was updated, use existing value ) var new_lifecycle = IIf( abandon_feature, "ABANDONED", // the date was changed by the user, abandon the feature lifecycle // some other field was updated, use the existing value ) return { result: {attributes: { DateField1: new_retire_date, TextField1: new_lifecycle }} } Change the field names in lines 5-8 and 31-32.
... View more
05-25-202304:16 AM
|
0
|
1
|
148
|
Title | Kudos | Posted |
---|---|---|
1 | 3 weeks ago | |
2 | 3 weeks ago | |
1 | 3 weeks ago | |
1 | 3 weeks ago | |
1 | 4 weeks ago |
Online Status |
Offline
|
Date Last Visited |
3 weeks ago
|