|
POST
|
I also had to add the Text function to string field types for those values to show up That's weird, this conversion should happen automagically. The problem with Date fields is something that leads to confusion quite regularly. Please consider lending your support to this idea to hopefully get that fixed: https://community.esri.com/t5/arcgis-online-ideas/arcade-allow-date-values-in-date-fields/idi-p/1204894
... View more
12-16-2022
07:30 AM
|
0
|
0
|
2325
|
|
POST
|
Hmm... "Request canceled" is an error I have never seen before, and I can't find it online, either. There is always the tried and true "restart ArcGIS", but other than that I have no idea. While checking Shape_Length and Shape_Area should work ( I could do it when testing), maybe start with a simple test table. Yes, you should be able to find identical Strings, Integers, Doubles (excluding rounding errors), Dates, and Geometries. Good catch with overwriteOutput. That defaults to True in my setup, so I didn't think about that.
... View more
12-15-2022
05:34 AM
|
1
|
1
|
2339
|
|
POST
|
# input parameters
fc = r"N:\...\db.gdb\TestPoints" # path to the fc
csv = r"N:\...\testpoints.csv" # path to csv
copy_fields = ["TextField", "IntegerField", "DoubleField"] # list of the fields you want to copy. First field has to be a unique identifer
import arcpy
# read the csv, store its data in a dictionary
csv_dict = {row[0]: row for row in arcpy.da.SearchCursor(csv, copy_fields)}
# loop over the features with an UpdateCursor
with arcpy.da.UpdateCursor(fc, copy_fields) as cursor:
for row in cursor:
# get the csv data for that row
key = row[0]
try:
new_row = csv_dict[key]
except KeyError: # row not found in csv
print(f"Entry not found in csv: {copy_fields[0]} = {key}")
# cursor.deleteRow() # uncomment this to delete the feature
continue
# update the feature
cursor.updateRow(new_row)
del csv_dict[key]
# every feature that is left in the csv_dict is new
with arcpy.da.InsertCursor(fc, copy_fields) as cursor:
for new_row in csv_dict.values():
cursor.insertRow(new_row)
... View more
12-15-2022
04:02 AM
|
0
|
1
|
3942
|
|
POST
|
Instead of taking the First() feature of parkA_intersect, you need to loop through the featureset: // get parkA feature (polygon)
var parkA = FeatureSetByName($datastore, "parkA", ["*"], false)
var parkA_intersect = Intersects(parkA, Geometry($feature))
// return error if $feature doesn't intersect any parkA polygon
if (Count(parkA_intersect) == 0)
return {"errorMessage": "Buffer must be intersected with parkA polygon."}
// create the result dict
var result = {
"attributes": {
}
}
// initialize the edit arrays for adds and updates
var adds = []
var updates = []
if(mode == "INSERT") {
for(var p in parkA_intersect) {
var add = {
"geometry": Geometry(p),
"attributes": {
"Status_A": p.statusA
}
}
Push(adds, add)
}
}
if(mode == "UPDATE") {
for(var p in parkA_intersect) {
var update = {
"objectID": p.OBJECTID,
"geometry": Geometry(p),
"attributes": {
"Status_A": p.statusA
}
}
Push(updates, update)
}
} A note on the update objects: You need to specify which feature you want to update. You do that by supplying either the objectID or the globalID, see line 34 in the code above. Attribute rule dictionary keywords—ArcGIS Pro | Documentation
... View more
12-15-2022
01:37 AM
|
0
|
3
|
2533
|
|
IDEA
|
Considering the fact that much of my work both in my job and on this site involves Arcade, it's really odd that I never had this idea. But now that you suggested it: YES, PLEASE. Query Layers and Database Views are great tools and do a lot of the heavy lifting in my applications, but there is only so much you can do with SQL. Arcade enables us to do more complex calculations. We regularily use Arcade Featuresets in Dashboards and Popups, displaying them on maps, both in the online Map Viewer and in ArcGIS Pro, is the next logical step.
... View more
12-15-2022
01:06 AM
|
0
|
0
|
2512
|
|
IDEA
|
Thanks Jeff, that helps alot. I have done some work with the CIM (especially configuring popups), but I haven't looked too far into it regarding symbology.
... View more
12-15-2022
12:13 AM
|
0
|
0
|
3395
|
|
POST
|
# input parameters
in_table = "path_or_layer_name"
out_table_folder = "memory"
out_table_name = "identical"
fields = ["IntegerField", "Shape"]
only_duplicate = False
# create output table
out_table = arcpy.management.CreateTable(out_table_folder, out_table_name)
arcpy.management.AddField(out_table, "IN_FID", "LONG")
arcpy.management.AddField(out_table, "FEAT_SEQ", "LONG")
# read and group in_table
groups = dict()
for i, f in enumerate(fields):
if f == "Shape":
fields[i] = "SHAPE@WKT"
with arcpy.da.SearchCursor(in_table, ["OID@"] + fields) as cursor:
for row in cursor:
oid = row[0]
key = tuple(row[1:])
try:
groups[key].append(oid)
except KeyError:
groups[key] = [oid]
# write groups into out_table
with arcpy.da.InsertCursor(out_table, ["IN_FID", "FEAT_SEQ"]) as cursor:
for seq, key in enumerate(groups.keys()):
oids = groups[key]
if only_duplicate and len(oids) < 2:
continue
for oid in oids:
cursor.insertRow([oid, seq])
... View more
12-14-2022
04:28 AM
|
0
|
3
|
2361
|
|
POST
|
There is nothing wrong with the data, it's just how the serial chart works. You can change how the year is displayed in the category axis parameters:
... View more
12-14-2022
01:39 AM
|
1
|
1
|
2046
|
|
POST
|
You can get related features with FeaturesetByRelationshipName() or Filter(). To update another table, you have to return a dictionary with specific keys: Attribute rule dictionary keywords—ArcGIS Pro | Documentation // Calculation Attribute Rule on inspection table
// field: empty
// triggers: Insert, Update
// load the hydrants
var hydrant_fs = FeaturesetByName(...)
// filter for the hydrant this inspection belongs to
var asset_id = $feature.asset_id
var hydrant = First(Filter(hydrant_fs, "asset_id = @asset_id"))
// if no corresponding hydrant is found, abort
if(hydrant == null) { return }
// else update the hydrant
return {
edit: [{
className: "HydrantFC", // full name of the hydrant fc
updates: [{
objectID: hydrant.OBJECTID,
attributes: {
recent_condition_rating: $feature.condition_rating
recent_inspection_date: $feature.inspection_date
}
}]
}]
}
... View more
12-13-2022
10:36 PM
|
1
|
1
|
1633
|
|
POST
|
From the tool doc: To see the symbology created in a script tool, the tool must include the layer as a derived output parameter.
... View more
12-13-2022
09:59 PM
|
1
|
5
|
4048
|
|
POST
|
what is the difference between making a new geometry object vs reading and utilizing the existing geometry object? There is no difference. Reading the SHAPE@ token returns a geometry object, same as when you create it on your own. extracted_geometry = [row[0] for row in arcpy.da.SearchCursor("TestPoints", ["SHAPE@"])][0]
created_geometry = arcpy.PointGeometry(arcpy.Point(523433, 5848821), arcpy.SpatialReference(25832))
extracted_geometry
#<PointGeometry object at ...>
created_geometry
#<PointGeometry object at ...> can this be utilized with the contains method or will I need to create a whole new object in order to do so? contains() is a method of the Geometry classes, so you can call it on the extracted geometries without problem.
... View more
12-13-2022
06:47 AM
|
0
|
0
|
1447
|
|
POST
|
Loop through Rounds - would grouping it like above allow me to loop through the rounds and buffer and union them?? No, it's a little more complicated. Buffer(), Union(), and Area() don't work on Featuresets, only on singular Features/Geometries (or arrays in case of Union), so you need two loops: outer loop over the rounds inner loop over the features of a round Something like this should work: // we don't need GroupBy, we just need the distinct values of the group field
var treatmentRounds = Distinct(fsTreatment, "Round_Num")
// outer loop over the rounds
for(var treatRound in treatmentRounds) {
// filter the Featureset
var roundNum = treatRound.Round_Num
var query = "Round_Num " + Iif(roundNum == null, "IS NULL", "= @roundNum")
var filtered = Filter(fsTreatment, query)
// inner loop over the filtered features
var buffer_geometries = []
for(var f in filtered) {
// buffer the geometry and append it to the array
Push(buffer_geometries, Buffer(f, 5, "meters"))
}
// union all those buffers into one geometry
var union_geometry = Union(buffer_geometries)
// create the new output feature
var f = {attributes: {Round_Treat: roundNum, Area_Treat: AreaGeodetic(union_geometry, "hectares")}}
Push(TreatmentDict.features, f)
}
return Featureset(Text(TreatmentDict))
... View more
12-13-2022
12:13 AM
|
1
|
0
|
2996
|
|
POST
|
You actually never call the function, you pass it to Filter() as an argument. Passing functions around is something that is not done very often, so it can seem unintuitive, even for people somewhat familiar with programming. Basically, the argument of the function is a placeholder for the elements of the array to which the function is applied. This is mostly done for code brevity. The expression above could also be written this way: var arr = [20, 20, 21, 21, 21, 22]
var filter_arr = []
for(var i in arr) {
if(arr[i] == 21) {
Push(filter_arr, arr[i])
}
}
return Count(filter_arr) This is cumbersome to write and read, especially if you have to do it multiple times. To make the code more manageable, we use a predefined function (Filter) that takes care of the for loop. So, while it may seem confusing, it's actually simply a for loop that returns each element of the array for which the functions returns true.
... View more
12-12-2022
07:20 AM
|
0
|
0
|
3140
|
|
POST
|
Because you need a function to filter an array: Array functions | ArcGIS Arcade | ArcGIS Developers var arr = [20, 20, 21, 21, 21, 22]
function is_21(x) { return x == 21 }
return Count(Filter(arr, is_21))
... View more
12-12-2022
05:23 AM
|
3
|
3
|
3150
|
|
POST
|
It helps tremendously, because now I can see what you're doing wrong. Based on the working default code, you're trying to add an Arcade element. For that to work, you need to return a dictionary (documentation). In your actual expression, you're not doing that, instead you return a string. There is a difference between a "normal" Arcade expression (#1 in the images) and an Arcade element (#2). The value of a "normal" Arcade expression can be shown in the fields list. The Arcade element is more customizable, and, as said, you need to return a dictionary. Replace your last line with this: return {
type: 'text',
text: DefaultValue(popupString, 'Geen dossier')
}
... View more
12-12-2022
05:14 AM
|
3
|
2
|
7078
|
| 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
|