|
POST
|
You can use the Calculate Field tool to calculate a text field with this Python expression: !Shape!.wkt
... View more
03-28-2023
01:21 PM
|
2
|
1
|
6723
|
|
IDEA
|
I always thought that was the intended behavior. It's the reason why I stopped using tool sets when developing my Python toolbox. It's just one click to open the tool set again, but that adds up...
... View more
03-28-2023
12:16 PM
|
0
|
0
|
1186
|
|
POST
|
AFAIK, it's not possible to get the name of the table in the Calculate Field tool. But you can throw together a litte script where you get the year from the table name and then use that to calculate a new field: arcpy.env.workspace = "G:/ArcGIS/.../my_database.gdb"
datasets = ["TestPoints_2019", "TestPoints_2020"]
for ds in datasets:
year = ds.split("_")[-1]
arcpy.management.CalculateField(ds, "Year", year, "PYTHON3")
... View more
03-28-2023
12:00 PM
|
0
|
1
|
1178
|
|
POST
|
So the rule actually moves the black polygons, but you only see that after you zoom out, and if you zoom back in it shows the old state. Is that correct? I think ArcGIS Pro uses some cashing to allow for faster display of areas that you have looked at before. It basically calculates an image of that extent, saves it on your hard drive, and shows it to you every time you want to display that extent. Sometimes, it doesn't realize that the data in that extent has changed, and displays the old state. You probably have to refresh the map. Sometimes, repeatedly zooming in and out also does the trick.
... View more
03-28-2023
11:46 AM
|
0
|
1
|
1366
|
|
POST
|
Hmmm... No idea why the symbology wouldn't translate to AGOL correctly. Try to change it in the MapViewer (just copy your expression) that worked for me.
... View more
03-28-2023
11:34 AM
|
0
|
0
|
2436
|
|
POST
|
It looks as if the rule doesn't find the parent feature and aborts in line 6. You could test that theory by returning a default value if that happens. Also, you're getting the related features in line 1 and then filter these features in lines 2&3. I used FeaturesetByName in my example and had to use the filter to get the related features. You use FeaturesetByRelationshipName, so the parent_fs already contains only the related features, the filter doesn't do anything. var parent_fs = FeatureSetByRelationshipName($feature, "SAN_Manhole_To_SAN_Manhole_Inspection");
var manhole = First(parent_fs);
if (manhole == null) {return {"result": {"attributes": {"LOCATIONDESCRIPTION": "No parent feature found!"}}}};
var atts =
{
"LOCATIONDESCRIPTION": manhole.LOCATIONDESCRIPTION,
"SETTLEMENTAREA": manhole.SETTLEMENTAREA,
"LOCALMUNICIPALITY": manhole.LOCALMUNICIPALITY,
"DEPOTAREA": manhole.DEPOTAREA
};
return {"result": {"attributes": atts}};
... View more
03-28-2023
11:20 AM
|
1
|
0
|
1680
|
|
POST
|
arcpy has FromWKB() and FromWKT(). with arcpy.da.InsertCursor(new_fc, ["SHAPE@"]) as cursor:
new_geom = arcpy.FromWKB(line.wkb)
cursor.insertRow([new_geom])
... View more
03-28-2023
03:23 AM
|
4
|
1
|
5493
|
|
POST
|
You can use an Arcade expression as unique value field (click the expression button on the right of the field). Something like this should do what you want: // for features without INSP_STATUS, return the subtype
if(IsEmpty($feature.INSP_STATUS)) {
var subtypes = ["MaintenanceHole", "InspectionMH", "BackFlow", "DiversionMH", "FlapGateMH"]
var i = $feature.SubtypeCD - 1
return subtypes[i]
}
// for features with INSP_STATUS, return a default value
return "YES"
... View more
03-28-2023
02:51 AM
|
1
|
0
|
4378
|
|
POST
|
I think the verification is run on a default object (new object with all default values). Don't quote me on this... Your default value for OUT_OF_SERVICE is probably null, so the rule doesn't enter the if block in line 1. This might also be why you're no getting the updates you expect. In its current state, the rule will only update the parent feature if OUT_OF_SERVICE is not empty (it accepts any value) and DATEWORK is empty If OUT_OF_SERVICE is empty or DATEWORK is not empty, the rule will not update the parent feature. Is that the expected behavior?
... View more
03-24-2023
06:06 AM
|
1
|
0
|
6407
|
|
POST
|
You could do something like this: // Calculation Attribute Rule on the Line fc
// field: leave empy
// triggers: insert
// exclude from application evaluation
// get the vertices
var vertices = Geometry($feature).paths[0]
// if first vertex isn't the same as last vertex, abort
var same = vertices[0].x == vertices[-1].x && vertices[0].y == vertices[-1].y
if(!same) { return }
// create the polygon
var sr = Geometry($feature).spatialReference
var poly_vertices = []
for(var v in vertices) {
var vertex = [vertices[v].x, vertices[v].y]
Push(poly_vertices, vertex)
}
var poly = Polygon({rings: [poly_vertices], spatialReference: sr})
// insert the polygon into the polygon fc
return {
edit: [{
className: "NameOfYourPolygonFC",
adds: [{
geometry: poly,
attributes: {} // you can add attributes here
}]
}]
}
... View more
03-24-2023
12:36 AM
|
1
|
0
|
3041
|
|
POST
|
The console messages are visible after you verified your expression. There should be green text like "Show Messages" or something.
... View more
03-24-2023
12:07 AM
|
0
|
0
|
6414
|
|
POST
|
Your first example doesn't work because GroupBy() returns a featureset (a collection of features), but the popup expects the expression to return a string value. Your second example doesn't work because you keep overwriting the result variable in your for loop. So the returned value will always be the count of the last mine site. You don't need GroupBy() here. You can just use Filter(): var fs = FeatureSetByPortalItem(Portal('https://www.arcgis.com'), 'ID', 0, ['OFFICIAL_N'], False)
var offilical_n = $feature.OFFICIAL_N
var mine_features_at_this_site = Filter(fs, "OFFICIAL_N = @official_n")
return Count(mine_features_at_this_site)
... View more
03-23-2023
10:56 AM
|
0
|
0
|
6869
|
|
POST
|
To post code: So far this is what I have setup as a "Validation" rule on the table the inspections get saved in It has to be a Calculation Attribute Rule. Is there a way to do this without using the GlobalID?? No. Attribute Rules need GlobalIDs to work. You apparently already found an example of how to update another table. But take a look at the official documentation for the return dictionary. It expects certain keys, and FACILITYID is not one of them. You have to supply the objectID or globalID of the feature you want to edit. Something like this should work (remember to enable GlobalID): // Calculation Attribute Rule on the inspection table
// field: leave empty
// triggers: insert
// exclude from application evaluation
if (($feature.OUT_OF_SERVICE != null) && ($feature.DATEWORK == null)) {
// get the hydrant
var hydrants = FeaturesetByName($datastore, 'WAT_Hydrant', ['FACILITYID', 'ObjectID'], false)
var facility_id = $feature.FACILITYID
var hydrant = First(Filter(hydrants, 'FACILITYID = @facility_id'))
// abort if no hydrant was found
if(hydrant == null) { return }
//update INSP_STATUS in the hydrant layer to OOS
return {
'edit': [{
'classname' : 'WAT_Hydrant',
'updates' : [{
'objectID': hydrant.ObjectID,
'attributes' : {'INSP_STATUS' : 'OOS'}
}]
}]
}
}
... View more
03-23-2023
10:45 AM
|
1
|
0
|
6422
|
|
POST
|
var LN1= $feature.LastName
var FN1 = Split($feature.FirstName,'(',-1, true)
var LN2 = $feature.LastName_2
var FN2 = $feature.FirstName_2
if(IsEmpty(FN2)) {
return `${FN1} ${LN1}`
}
return `${FN1} ${LN1} & ${FN2} ${LN2}`
... View more
03-23-2023
10:29 AM
|
1
|
0
|
1042
|
|
POST
|
To post code: Your SQL query is wring. CleanoutNeeded is a string field, so the query should look for a string (enclosed in single quotes). var co = Filter(fs, "CleanoutNeeded = 'Yes'")
... View more
03-22-2023
11:59 PM
|
0
|
1
|
1590
|
| 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
|