|
POST
|
These were changes made in 2.6 (geometry updates) and 2.7 (update multiple fields). Arcade and Attribute Rules are under active development, so sadly, something like this is bound to happen now and then. how can I create an attribute rule that updates the geometry? In 2.5, you can't.* You'll have to update your production environment. Pro 2.7 should be enough for your rule, but go take a look at the Arcade Release History, maybe there are some functions you want to use from later releases. Combined with the Arcade Version Matrix, this will tell you the versions of Pro and Enterprise. *: Well, maybe (I didn't check versions or test this) you can update the geometries from another table: // Calculation Attribute Rule on GeometryUpdateControlTable
// field: DoItNow (integer field, 1 means "update now")
// triggers: update
// requires another field: ObjectIDsToBeEdited (Text field with comma separated ObjectIDs of the polyline features. Null means all.)
var fs_polylines = FeatureSetByName($datastore, "PolylineFC", ["OBJECTID"], true)
if(!IsEmpty($feature.ObjectIDsToBeEdited)) {
var where = `ObjectID IN (${$feature.ObjectIDsToBeEdited})`
fs_polylines = Filter(fs_polylines, where)
}
var polyline_updates = []
for(var f in fs_polylines) {
var geom = Dictionary(Text(Geometry(f))) // f instead of $feature
var paths = geom['paths']
var oldX = paths[0][0][0];
var oldY = paths[0][0][1];
var line_length = 0;
for (var path_idx in paths) {
for (var point_idx in paths[path_idx]) {
var newX = paths[path_idx][point_idx][0];
var newY = paths[path_idx][point_idx][1];
//For multi-part features, we want the M-value for additional parts to start at the last M-value from the last part. We don't want to measure the distance *between* parts.
//So, for the first vertex in a given part, we will skip calculating the length between vertices.
if (point_idx != 0) {
line_length += pythagoras(oldX, oldY, newX, newY);
}
//We can use a negative slice: it will work when there is no Z.
paths[path_idx][point_idx][-1] = line_length;
oldX = newX;
oldY = newY;
}
}
Push(polyline_updates, {"objectID": f.OBJECTID, "geometry": Polyline(geom)})
}
return {
"result": 0,
"edit": [
{
"className": "Database.Dataowner.PolylineFC",
"updates": polyline_updates
}
]
} This way, you could start the calculation manually by setting DoItNow to 1. Also, you could do it automatically: // Calculation Attribute Rule on PolylineFC
// field: SomeField that is editable
// triggers: update
if (Text(Geometry($feature)) == Text(Geometry($originalfeature))) {
console("The geometry has not changed. We don't need to redefine the M-Values.")
return $feature.SomeField
}
console("The geometry has changed. So we *will* redefine the M-Values.")
return {
"result": $feature.SomeField,
"edit": [
{
"className": "Database.Dataowner.GeometryUpdateControlTable",
"updates": [{
"objectID": 1, "attributes": {
"ObjectIDsToBeEdited": Text($feature.ObjectID),
"DoItNow": 1
}}]
}
]
}
... View more
03-24-2022
11:49 PM
|
1
|
1
|
2615
|
|
POST
|
Was hoping someone more knowledgable than me would answer, but before this gets completely buried: Some users use ArcMap, some use ArcGIS Pro, some use FME to make updates, some use web editing tools. So Attribute Rules are probably not going to cut it, because you can't even read them in ArcMap (don't know about FME and web services). You could take a look at database triggers. All I know about that: they work on the database (not geodatabase!) and are implemented using SQL. As they are not ESRI-specific, you can probably find many resources with your preferred search engine. You could maybe also find something in the Data Management - Esri Community.
... View more
03-24-2022
08:35 AM
|
1
|
0
|
1060
|
|
POST
|
Hey, welcome to the ESRI community! This is a forum specifically for all GIS products of ESRI. If you have nothing to do with that and only have questions about Python, this might not be the best place to ask. a class can inherit from another class (simple inheritance) a class can inherit from multiple classes (multiple inheritance) inheritance means that the class has all attributes and methods of its parent class(es) the class can define its own additional attributes and methods the class can overwrite attributes and methods from its parent class(es) In Python, the base classes of a class are stored in the __mro__ attribute (a tuple of classes). When you call a method or want to use an attribute, Python goes through this tuple from left to right and tries to find that method or attribute. If it doesn't find it, it goes to the next class. If it finds it, it returns the result, the other classes are not checked. What this code example tries to teach you: child inherits from 3 classes you can call all methods of the parents on child you can define additional methods on child if 2 parent classes have methods/attributes with the same name, only the first will be returned Python uses the __mro__ attribute to look for the methods and attributes. The order of the parent classes in this tuple determines which parent's method will be returned. Your code samples has many errors. Here is the correct version: class parent1: # first parent clas
def func1(self):
print("Hello Parent1")
class parent2: # second parent class
def func2(self):
print("Hello Parent2")
class parent3: # third parent class
def func2(self): # the function name is same as parent2
print("Hello Parent3")
class child(parent1, parent2, parent3): # child class
def func3(self): # we include the parent classes
print("Hello Child") # as an argument comma separated
# Driver Code
test = child() # object created
test.func1() # parent1 method called via child
test.func2() # parent2 method called via child instead of parent3
test.func3() # child method called
# to find the order of classes visited by the child class, we use __mro__ on the child class
print(child.__mro__)
... View more
03-24-2022
08:14 AM
|
1
|
1
|
12875
|
|
POST
|
Hey, welcome to the ESRI community! This is a forum specifically for all GIS products of ESRI. If you have nothing to do with that and only have questions about Python, this might not be the best place to ask. What will be the output? Well, have you tried to run it? You create a BaseClass object and run its display() method. This method prints two attributes (a & __c) of the object. You don't do anything with the derived class. The output will be "GoForGyan goforgyan".
... View more
03-24-2022
08:00 AM
|
0
|
0
|
943
|
|
POST
|
It sounds as if you want the field to update itself when the specified date is passed. That is not possible. An Attribute Rule only triggers when you actively do something to a feature (insert/update/delete), they are not checked continually. What you can do is create a Batch Attribute Rule. These are rules that don't trigger on insert/update/delete, but are evaluated when the user wants. Batch rules need Editor Tracking, so enable that for your feature class. Enable or disable editor tracking—ArcGIS Pro | Documentation Create a new Batch Calculation Attribute Rule This will add a new field "VALIDATIONSTATUS" to your table. Use your script or the script below (slightly modified) Evaluate the rule periodically Use the tool Evaluate Rules (Data Management)—ArcGIS Pro | Documentation Either do that manually or write a Python script and run that automatically every night var skedenr = $feature.IntegerField
var utstallningsdatum = $feature.DateField
if(skedenr == null || skedenr == 105) {
return 105
}
if(utstallningsdatum == null) {
return skedenr
}
var datum = DateDiff(utstallningsdatum, Today())
return IIF(datum <= 0, 105, skedenr) My test features before and after evaluating the rule (on 2022-03-24) Before After Notes: The second row didn't get changed because there was no date supplied. The last row didn't get changed because DateDiff(datevalue, Today()) returned 1 hour. Might be related to daylight saving time, I don't know. This is a file gdb, did not test on enterprise. To change this behavior, you can replace the last 2 lines with this: var datum = DateDiff(utstallningsdatum, Today(), "hours")
return IIF(datum <= 1, 105, skedenr)
... View more
03-24-2022
07:05 AM
|
0
|
1
|
1888
|
|
POST
|
You assume right. // define your decode dictionary
var decode_dict = {
"1": "a",
"3": "c",
"5": "e"
}
// get an array of your coded values
// here, I'm removing spaces from the field and then split by comma
var coded_values = Split(Replace($feature.Field, " ", ""), ",", -1, true)
// create an empty array and append the decoded values
var decoded_values = []
for(var i in coded_values) {
Push(decoded_values, decode_dict[coded_values[i]])
}
// convert the array to string (here, I concatenate with comma) and return
return Concatenate(decoded_values, ", ") The ArcGIS Developer page for Arcade is a good place to start: Getting Started | ArcGIS Arcade | ArcGIS Developer I find the function reference especially important, this is a page that I have bookmarked: Function Reference | ArcGIS Arcade | ArcGIS Developer If you want to play around, you can do so in the Arcade Playground: Playground | ArcGIS Arcade | ArcGIS Developer If you're looking for examples, there is a Github with Arcade expressions for diffferent profiles: GitHub - Esri/arcade-expressions: ArcGIS Arcade expression templates for all supported profiles in the ArcGIS platform.
... View more
03-23-2022
11:41 PM
|
3
|
1
|
6831
|
|
POST
|
Do it the other way around: instead of setting the map coordinate system, project the extent. d = arcpy.Describe(raster_in)
r_in_sr = d.spatialReference
# Make sure data is not unprojected or in common GCS
if r_in_sr.factoryCode in [4326, 3857, None]:
raise ProjectionException("Input data not projected. Please ensure all inputs are projected and retry.")
# Get the current view extent
p = arcpy.mp.ArcGISProject("CURRENT")
view_extent = p.activeView.camera.getExtent()
arcpy.AddMessage(view_extent.polygon.spatialReference.factoryCode)
arcpy.AddMessage(view_extent.polygon.firstPoint)
# project view_extent; note that you don't have to construct the polygon yourself!
extent_poly = view_extent.polygon.projectAs(r_in_sr)
arcpy.AddMessage(extent_poly.spatialReference.factoryCode)
arcpy.AddMessage(extent_poly.firstPoint)
... View more
03-23-2022
12:31 AM
|
1
|
1
|
3058
|
|
POST
|
@RhettZufelt I was wondering the same, but looking at the Length and Area fields, it seems as if the geometry is the same for all rows. So when OP clicks on a feature, she expects all features to show up in the popup pane. @ElizabethFrancis Check that you have the Explore tool set to the appropriate option:
... View more
03-22-2022
11:52 PM
|
1
|
1
|
3000
|
|
POST
|
First, it's important that you understand the difference between layers and data. Data mostly comes in the form of tables, shape files, and feature classes in geodatabases. This is what gets saved on your hard drive or server. Layers are representations of data. They control what data to show (data source and applied filters), and how to show it (e.g. symbols, labels, popups), and they allow you to change the underlying data (create, update, and delete features). Layers normally don't get saved separately, they are a part of the ArcGIS project. When you copy a layer, you create a new layer that represents the same underlying data. If you delete a feature in the new layer, you don't delete it from the layer, but from the data. All other layers representing that data will show the change, too. Solutions: If you need separate feature classes / shape files for each boundary (different data structure), go with Aubri's solution: Export the features from the original layer into three different feature classes, then delete the unneeded features in each feature class. If you only need to show the boundaries indepently from each other (different representation), copy the layer three times and set the defniition query of each layer: Filter features with definition queries—ArcGIS Pro | Documentation
... View more
03-22-2022
11:18 PM
|
1
|
0
|
5938
|
|
POST
|
Currently, Attribute Rules don't work in ArcGIS Online, only in Pro and Portal. Go lend your support to this very popular idea: Support for Attribute rules in ArcGIS Online - Esri Community
... View more
03-22-2022
10:58 PM
|
1
|
1
|
3481
|
|
POST
|
alias properly spelled See, there's your problem. You need the real field names, not the aliases.
... View more
03-22-2022
06:19 AM
|
1
|
4
|
3506
|
|
POST
|
Set as Distance seems to try to minimize the distance. In your second case, V2 is closer to V4 than to V3, so it continues the route that way. That feels kinda wrong, but maybe there are good reasons for that behavior, I don't know. Workaround: Set as Distance Set From/To, using the highest M value as To
... View more
03-22-2022
02:03 AM
|
0
|
1
|
1476
|
|
POST
|
I get this error if I supply wrong field names. In your case, Arcade could not find the field "serial" in "VPS_BFP_FAIL_2022".
... View more
03-22-2022
12:43 AM
|
1
|
6
|
3518
|
|
POST
|
From the documentation:, This function has 2 signatures: Within(innerGeometry, outerGeometry) -> Boolean Within(innerGeometry, outerFeatures) -> FeatureSet You use the second version (with a geometry for the inner feature and a feature set for the outer features) and expect a boolean return value, but it actually returns a feature set of polygons. So you have to check if this feature set contains any features. var aor = FeatureSetByName($datastore, "aor")
return Count(Within($feature, aor)) > 0
// you could also do this
//return First(Within($feature, aor)) != null
... View more
03-22-2022
12:30 AM
|
0
|
0
|
1771
|
|
POST
|
Looks good! As Mike said, the else is unnecessary and makes it a little harder to read. Personally, I would declare geom and paths right before oldX, so that they are closer to where you actually use them.
... View more
03-21-2022
11:41 PM
|
1
|
3
|
5811
|
| 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
|