|
IDEA
|
In the Fields tab in ArcGIS Pro: Currently, if we rename a field, the field alias stays the same as it was before we renamed the field: We often don't think to update the alias when renaming a field. The old name doesn't apply anymore, and is often downright misleading. Especially since the alias is used as the field header in the attribute table, not the field name. Intuitively, when renaming a field, we'd expect the alias to be reset to the field’s new name. Could Esri consider changing that behavior? ArcGIS Pro 2.6.8
... View more
03-14-2022
11:57 PM
|
2
|
5
|
2470
|
|
POST
|
I thought this was interesting: "Luckily, arcpy can be accessed inside field calculator, so it's a simple call to arcpy.Array():" def plineM(shp):
for part in arcpy.Array(shp.getPart(0)):
for p in part:
return None if p is None else p.X
plineM(!Shape!) Script (ArcPy) vs field calculator (Python Parser) behaviour of getPart in ArcGIS for Desktop?
... View more
03-12-2022
07:00 PM
|
1
|
0
|
1993
|
|
POST
|
Using a calculation attribute rule: Is there a way to insert a new row into the same table? For example, in a non-spatial table, I want to split a linear referencing record into two separate records (the original record and a new record). Is there a way to do that? Thanks.
... View more
03-12-2022
05:01 PM
|
0
|
0
|
578
|
|
POST
|
By the way, the keyboard shortcut for auto-formatting code in VS Code is: Shift + Alt + F. How do you format code in Visual Studio Code (VSCode)?
... View more
03-12-2022
10:05 AM
|
0
|
0
|
1956
|
|
POST
|
I have an Arcade calculation attribute rule that sets polyline M-values to the cumulative length of the line. The script works as expected. But I'm still a novice, so I thought I'd ask: Can the script be improved? Notes about the script: - It works for both singlepart and multipart features. - It densifies true curves (unavoidable, since Arcade pre-densifies true curves). - The code below is out-of-date. I've posted an updated version in a reply...further down in this post. //var paths = [[[0, 5, null], [10, 10, null], [30, 0, null], [50, 10, null], [60, 10, null]]]; //JS
//Only do the calculation if the geometry was changed/edited.
if (!Equals(Geometry($feature), Geometry($originalfeature))) {
var geom = Dictionary(Text(Geometry($feature)));
var paths = geom['paths'];
//Alternatively, this could be done with the Arcade distance() function. I chose to do the math manually so that the script can be used elsewhere, such as VSCode (for debugging).
function pythagoras(x1, y1, x2, y2) {
return sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2));
}
for (var path_idx in paths) {
var oldX = paths[0][0][0], oldY = paths[0][0][1], length = 0;
for (var point_idx in paths[path_idx]) {
var newX = paths[path_idx][point_idx][0], newY = paths[path_idx][point_idx][1];
length += pythagoras(oldX, oldY, newX, newY);
paths[path_idx][point_idx][2] = length;
oldX = newX;
oldY = newY;
}
}
console(paths);
return { "result": { "geometry": Polyline(geom) } };
//Output: [[[0,5,0],[10,10,11.180339887498949],[30,0,33.54101966249685],[50,10,55.90169943749475],[60,10,65.90169943749476]]]
} (The script was adapted from this GitHub sample: Set Ms to Index.) Thanks!
... View more
03-11-2022
10:19 AM
|
0
|
14
|
7554
|
|
POST
|
What are some tips/tricks for debugging Arcade scripts in VS Code/Node.js? (assuming that the Arcade script is fairly vanilla -- as in, it doesn't use many Arcade-specific functions that need to be stripped-out) For example, Arcade uses console(), whereas VS Code/Node.js uses console.log(). Solution: In VS Code, put this line at the top of the script: console = Object.assign(console.log, console); That will assign console.log() to console(). Which means I can use the console() script in both programs -- without constantly doing "find and replace" on .log. Note: Only use that line in VS Code; it won't work in Arcade (and isn't needed in Arcade). Any other ideas? (I'm a novice, so it's possible the console.log() thing is wonky...I'm just trying to learn, and not get too frustrated while I'm at it 🙂 Related: Idea: Arcade Extension for Visual Studio Code
... View more
03-11-2022
05:41 AM
|
0
|
2
|
2017
|
|
POST
|
Related: if ($feature.structureheight >= 65)
{
If (DomainName($feature, 'Material') == 'Steel')
{ return true; }
else
{ return false; }
}
Else
{ return true; } Validation attribute rule examples
... View more
03-10-2022
10:28 AM
|
0
|
0
|
4019
|
|
POST
|
Regarding this code sample from the attribute rule docs: (Mark another feature as requiring evaluation) //Updating the substation name marks its transformers as requiring calculation and updates the yearName to the new name and year.
//To recalculate the facility id on all transformers, mark all associated transformers as requiring calculation.
var fsDevice = FeatureSetByName($datastore, "Transformer", ["globalid"], false)
var fsDeviceIntersects = Intersects (fsDevice, Geometry($feature))
var transformers = [];
var count = 0;
for (var i in fsDeviceIntersects)
transformers[count++] = i.globalid;
var newName = $feature.name + " " + Year(Now())
return {
'result': newName,
'calculationRequired':
[
{
'className':"Transformer",
'globalIDs': transformers
}
]
} How does this line work? transformers[count++] = i.globalid; Is it populating a "count" element in the transformers array with a list of global IDs? And then returning the entire transformers array in the result? If so, I don't think I realized ++ could be used that way. Thanks.
... View more
03-10-2022
01:41 AM
|
1
|
9
|
4843
|
|
POST
|
In an Oracle 18c Enterprise GDB; St_Geometry: If I add a calculation attribute rule to a FC via ArcGIS Pro 2.4, what will that mean for ArcMap 10.7.1 users? A. ArcMap can’t read the FC B. ArcMap can’t write to the FC C. ArcMap can’t read anything in the GDB D. ArcMap can’t write anything in the GDB F. Using ArcMap to write to the GDB would corrupt the FC. G. Using ArcMap to write to the GDB would corrupt the entire GDB. I. Attribute rules wouldn’t be honoured/invoked when edits are made to the FC in ArcMap. J. Something else? I’m Just trying to get a handle on what would happen at a practical level. I know the general sentiment is that attribute rules are incompatible with ArcMap. But if it ends up working the way I described in B) or I) above, then that might mean that certain departments could switch to Pro/Attribute Rules now (like me), even though other departments haven’t switched to Pro yet (outside of my control). I could add attribute rules to my FCs, since I’m the only one who edits them, without breaking the whole GDB. What would happen in the scenario mentioned above? Thanks.
... View more
03-09-2022
11:54 PM
|
1
|
1
|
1354
|
|
POST
|
The Attribute Rules documentation says: Attribute rules are complementary to existing rules used in the geodatabase, such as domains and subtypes. For example, domains can be assigned to an attribute field to aid in the data collection process by providing a list of valid values for editors. Additionally, an attribute rule can be used to restrict values for an attribute field that are not part of the domain when performing a field calculation. After rules are added to a dataset, they can be evaluated as edits take place or at a later time. Question: What is involved in setting up an attribute rule to enforce a coded value domain? I.e. prevent non-domain values from being entered, even when tools like the field calculator are used. - Do we need to hardcode the domain values in an IF statement in Arcade? - Or can we reference the domain list in Arcade and use it to dynamically restrict values in a field? Thanks.
... View more
03-09-2022
10:44 AM
|
0
|
3
|
4095
|
|
IDEA
|
Could Esri add a section to the docs that explains how to work with vertices in Arcade? For example, to loop through polyline vertices and read them, do the following: var geo = Geometry($feature); for (var part in geo.paths) { var line_part = geo.paths[part] for (var i in line_part) { To loop through polyline vertices and modify them, do the following: var geo = Dictionary(Text(Geometry($feature)));
var paths = geo['paths'];
for (var path_idx in paths){
for (var vert_idx in paths[path_idx]){ Explanation: Geometries are immutable, so we can't modify them directly. But if we convert them to a dictionary, then we can modify the entries in the dictionary, and then use that dictionary to create a new geometry. As far as I know, there isn't anything in the docs that explains how to work with individual vertices by looping through geometries. Sure, there are samples in the GitHub repo, and they're definitely useful. But it seems like a thorough explanation in the docs would be a big help to people who are learning this stuff from scratch. Related post: Arcade: Get paths array from feature
... View more
03-08-2022
11:08 PM
|
8
|
1
|
1468
|
|
POST
|
For my records, here's where the $originalfeature global variable can be found in the docs: Attribute Rule Calculation Globals Variable Name Type Description $datastore FeatureSetCollection A collection of layers in the same feature service or database as the$featureexecuting the script. $editcontext.editType Text Indicates whether the edit event isINSERT,UPDATE,DELETE, or NA(not applicable). $feature Feature The feature being calculated. $originalFeature Feature The previous state of the feature being calculated. $featureSet FeatureSet A collection of features in the same table as the$featureevaluating the expression. Related: - Identify whether a specific attribute value has changed - Arcade: Editing M-values not treated as change to geometry
... View more
03-08-2022
05:49 PM
|
0
|
0
|
1615
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 03-20-2026 02:12 PM | |
| 1 | 03-19-2026 11:42 AM | |
| 1 | 06-03-2026 04:02 AM | |
| 1 | 03-18-2026 07:08 PM | |
| 2 | 2 weeks ago |