|
POST
|
Ah, I misunderstood your original question. So you want to calculate a field "datafim" based on the fields "dataoccr" and "stat"? You can do that by using this expression in the CalculateField tool or in an Attribute Rule: // Calulation Attribute Rule
// or Calculate Field
// on field "datafim"
var dataini = $feature.dataoccr // read the dataoccr field of the current feature
if($feature.stat == "Closed") { // if the value of field "stat" is "Closed"
return dataini
}
return null // $feature.stat != "Closed"
... View more
05-20-2022
01:36 AM
|
1
|
0
|
1286
|
|
POST
|
Hmm, yeah, nothing there... If you didn't make some mistake, maybe @MichelleMathias can help?
... View more
05-19-2022
10:38 PM
|
0
|
1
|
1032
|
|
POST
|
Arcade is a relatively simple language. Things like POST requests, asynchronous processes and sleep() are not possible. What you describe doesn't seem possible in Arcade. What is your end goal here? Maybe it can be achieved in another way (or not at all, but then you know...).
... View more
05-19-2022
10:26 PM
|
0
|
0
|
1289
|
|
POST
|
For getting started: Getting Started | ArcGIS Arcade | ArcGIS Developer Your Arcade Questions Answered (esri.com) Attribute Rules in Arcade (From Scratch) - Demo Th... - Esri Community Introduction to Attribute Rules Useful documentation (I have this bookmarked): Function Reference | ArcGIS Arcade | ArcGIS Developer Code examples: GitHub - Esri/arcade-expressions: ArcGIS Arcade expression templates for all supported profiles in the ArcGIS platform. Some videos: Attribute Rules Videos - Esri Community And of course the Attribute Rules - Esri Community for asking all of your questions about Attribute Rules. Sadly, there's no group for general Arcade yet; the jury is out on whether to post those in the ArcGIS Pro group or the AGOL group...
... View more
05-19-2022
10:15 PM
|
0
|
0
|
9958
|
|
POST
|
Because Arcade is used for many different things (eg Attribute Rules, popups, labeling, symbology, field calculation), there are differences in what global variables (like $feature, $map, and $datastore) get exposed to the user. The exposed globals are described in the Arcade profiles. For example, here is the profile for Calculation Attribute Rules: Profiles | ArcGIS Arcade | ArcGIS Developer Attribute Rules should work regardless from where you trigger them, so it's sensible that you don't get access to $map. For accessing data from different databases the only option I know of is publishing that data to AGOL or Portal and then using FeatureSetByPortalItem().
... View more
05-19-2022
10:00 PM
|
0
|
0
|
2473
|
|
POST
|
If you want to do this in the CalculateField tool, you can use this expression, modified for each statistic: // load the whole feature class
var fs_buildings = FeatureSetByName($datastore, "BuildingFC", ["BlockID", "BuildingID", "BuildingHeight", "BuildingArea"], false)
// only select rows with the current feature's BlockID
var id = $feature.BlockID
var fs_buildings_block = Filter(fs_buildings, "BlockID = @ID")
// edit this line for each statistic and field
return Min(fs_buildings_block, "BuildingHeight")
... View more
05-19-2022
09:48 PM
|
1
|
1
|
3868
|
|
POST
|
You need a table with a block id, building height, and building area You need one of the FeatureSetBy*() functions to load your building data You need the GroupBy() function to group your building data by block id. For the functions, look here: https://developers.arcgis.com/arcade/function-reference/data_functions/#featuresetbyid https://developers.arcgis.com/arcade/function-reference/data_functions/#groupby As an example, you can use the following code in the Playground | ArcGIS Arcade | ArcGIS Developer var fs_buildings = {
"geometryType": "",
"fields": [
{"name": "BlockID", "type": "esriFieldTypeInteger"},
{"name": "BuildingID", "type": "esriFieldTypeInteger"},
{"name": "BuildingHeight", "type": "esriFieldTypeDouble"},
{"name": "BuildingArea", "type": "esriFieldTypeDouble"}
],
"features": [
{"attributes": {"BlockID": 1, "BuildingID": 1, "BuildingHeight": 10., "BuildingArea": 300.}},
{"attributes": {"BlockID": 1, "BuildingID": 2, "BuildingHeight": 30., "BuildingArea": 500.}},
{"attributes": {"BlockID": 1, "BuildingID": 3, "BuildingHeight": 15., "BuildingArea": 250.}},
{"attributes": {"BlockID": 2, "BuildingID": 4, "BuildingHeight": 16., "BuildingArea": 400.}},
{"attributes": {"BlockID": 2, "BuildingID": 5, "BuildingHeight": 10., "BuildingArea": 300.}},
{"attributes": {"BlockID": 3, "BuildingID": 6, "BuildingHeight": 10., "BuildingArea": 300.}}
]
}
fs_buildings = FeatureSet(Text(fs_buildings))
//return fs_buildings
// actually use one of the FeatureSetBy*() functions:
//var p = Portal(...)
//var fs_buildings = FeatureSetByPortalItem(p, item, layer, ["BlockID", "BuildingID", "BuildingHeight", "BuildingArea"], false)
var statistics = [
{"name": "Count", "expression": "BuildingID", "statistic": "COUNT"},
{"name": "HeightMax", "expression": "BuildingHeight", "statistic": "MAX"},
{"name": "HeightMin", "expression": "BuildingHeight", "statistic": "MIN"},
{"name": "HeightMean", "expression": "BuildingHeight", "statistic": "AVG"},
{"name": "AreaMax", "expression": "BuildingArea", "statistic": "MAX"},
{"name": "AreaMin", "expression": "BuildingArea", "statistic": "MIN"},
{"name": "AreaMean", "expression": "BuildingArea", "statistic": "AVG"},
]
var fs_grouped_buildings = GroupBy(fs_buildings, "BlockID", statistics)
return fs_grouped_buildings
... View more
05-19-2022
05:33 AM
|
1
|
2
|
3914
|
|
POST
|
If you're triggering on both Insert and Update, you have to either create 2 rules or take care of your current edit type. In your case, when you move a point, you both update the existing polygon's location and also create a new polygon. your updates array is wrong, I'm surprised that it actually works. For documentation on the Attribute Rule return keywords, go here: https://pro.arcgis.com/en/pro-app/latest/help/data/geodatabases/overview/attribute-rule-dictionary-keywords.htm You also have to think about what happens if you manually delete a buffer polygon. Then you will get ExceptionErrors, because your code doesn't find the feature, so bufferedFeature will be null, and then you try to call attributes on null, which doesn't work. So you have to include null checks, just like you did for the park feature. Personally, I find it much easier to create and fill the adds, updates, anad deletes array in my code and just use those arrays in the return dict. Makes it much more readable and also easier to write, because you don't have to care about the brackets that much. So, with all that (switch behavior dependent on edit mode, do null checks, fill the edit arrays inside the code blocks), we end up with something like this: // determine our edit mode ("INSERT", "UPDATE", or "DELETE")
var mode = $editcontext.editType
// return early if we're updating the $feature and the geometry didn't change
var geometry_is_unchanged = Equals(Geometry($feature), Geometry($originalfeature))
if(mode == "UPDATE" && geometry_is_unchanged) {
return
}
// get park feature
var fsPark = FeatureSetByName($datastore, "Parks", ["NAME", "ParkID"], false)
var fsParkIntersect = Intersects(fsPark, Geometry($feature))
var park = First(fsParkIntersect)
// return error if $feature doesn't intersect a park
if (park == null)
return {"errorMessage": "Point must be in Park."}
// create the result dict
// we do this here, because we need some of the fields in the edit arrays
var result = {
"attributes": {
"NAME": "Point " + park.NAME,
"ParkNAME": park.NAME,
"ParkID": park.ParkID
}
}
// initialize the edit arrays for adds, updates, and deletes
var adds = []
var updates = []
var deletes = []
// depending on edit type, fill the corresponding array
var bufferedGeometry = Buffer($feature, 500)
if(mode != "INSERT") {
// get the buffer polygon (we don't need that if we're inserting)
var globalId = $feature.GlobalID
var fsBuffers = FeatureSetbyName($datastore, "TestPolygons", ["GlobalID"], false)
var bufferedFeature = First(Filter(fsBuffers, "PointGuid = @globalId"))
if(mode == "UPDATE") {
if(bufferedFeature == null) {
// somehow, there is no buffer polygon (eg we deleted it).
// in that case, use the insert code
mode = "INSERT"
} else {
var update = {
"globalID": bufferedFeature.GlobalID,
"geometry": bufferedGeometry
"attributes": {"NAME": result.NAME}
}
Push(updates, update)
}
}
if(mode == "DELETE") {
if(bufferedFeature == null) {
// somehow, there is no buffer polygon (eg we deleted it).
// in that case, we don't need to edit the buffer polygons,
// we can just return
return
} else {
var delete = {"globalID": bufferedFeature.GlobalID}
Push(deletes, delete)
}
}
}
if(mode == "INSERT") {
var add = {
"geometry": bufferedGeometry,
"attributes": {
"PointGuid": $feature.GlobalID,
"NAME": result.NAME
}
}
Push(adds, add)
}
// return
return {
"result": result,
"edit": [
{
"className": "TestPolygons",
"adds": adds,
"updates": updates,
"deletes": deletes
}
]
}
... View more
05-19-2022
03:13 AM
|
2
|
2
|
9976
|
|
POST
|
You load a feature class from the database with FeatureSetByName($datastore, "Database.DataOwner.TableName") It's telling you that it can't find the table "GISdw.DCL.TaxParcelPoly" in the datastore. You should check: that the parcel feature class is in the same database as your points that the database name (GISdw) is correct that the data owner name (DCL) is correct that the feature class name (TaxParcelPoly) is correct
... View more
05-18-2022
10:39 PM
|
0
|
2
|
2491
|
|
POST
|
When I just use $feature.TextField, it works: When I use the label style tags, ArcGIS probably switches to HTML, where ampersand is a special character, so the expression breaks in these features (your code): "<FNT name = 'Arial' style = 'Regular' size = '12'>" + $feature.TextField + "</FNT>" You have to escape the ampersand as an HTML entity: "<FNT name = 'Arial' style = 'Regular' size = '12'>" + Replace($feature.TextField, "&", "&") + "</FNT>"
... View more
05-18-2022
10:27 PM
|
2
|
1
|
6002
|
|
POST
|
Arcade expressions are only evaluated on command, e.g. when you open a popup when you trigger an attribute rule when you use Arcade in the CalculateField when you show a feature with Arcade in its label or symbology on the map That means: You can get and set Arcade expressions with the CIM module. You cannot get the expressions' outputs with Python. For example, Genus, species, common name are all separate fields but are often concatenated for display. I don't need it concatenated in my main data, but for this particular workflow (labelling things), I'd like to have that information. If this is just for labelling, you can just use an expression in the Label Class. You can only access teh $feature, for performance reasons the Arcade Labeling Profile doesn't allow the FeatureSetBy*() functions. But what you want could be as simple as this: var genus = "Genus"// $feature.Genus
var species = "Species"// $feature.Species
var name = "Common Name"// $feature.CommonName
return `${genus} ${species} (${name})`
... View more
05-18-2022
10:16 PM
|
0
|
1
|
2870
|
|
POST
|
Intersect But if you are using ArcGIS Pro and have write access to the property feature class, you can also do this with CalculateField. Use Arcade as Expression Type and use this expression (change "TestPolygons" to the name of your forest feature class): // load the forest fc
var forests = FeatureSetByName($datastore, "TestPolygons")
// get all forests intersecting the current feature
var intersecting_forests = Intersects($feature, forests)
// calculate the sum of all forest areas in the current feature
var forest_area = 0
for(var forest in intersecting_forests) {
forest_area += Area(Intersection($feature, forest))
}
// return that sum
return forest_area
... View more
05-18-2022
02:23 AM
|
1
|
0
|
5832
|
|
POST
|
Oof. Yeah, arcpy (and in extension the desktop geoprocessing tools) don't play well with web content. You can interact with hosted layers using the ArcGIS API for Python, but I don't know anything about that. So, you have two options: Download the hosted layers, run my script in the desktop environment, overwrite the hosted layer with the result Figure out how to do it in the Python API. There are probably multiple community members who can help you.
... View more
05-18-2022
01:51 AM
|
0
|
0
|
5665
|
|
POST
|
When you test your Arcade expression, it only checks one feature (I think it's the first). So if that feature doesn't intersect a feature of your filtered layer, you will get an empty intersect feature set. Your loop will run 0 times and then the expression will return null. If you call First() on an empty feature set, the result is null, which is why you get the ExecutionError when you try to return null.Field Something like this should do the trick: var filtered_parcels = Intersects(FeatureSetByName($map,"Name of layer with subset of all tax parcels"), $feature);
var parcel = First(filtered_parcels) // get the first feature
// if filtered_parcels is empty, parcel is null
// in that case, return a default value
if(parcel == null) {
return "No intersecting subset parcel found."
}
// else return the field value
return parcel.NameOfField When you test that expression, it should show the default result. When you actually open a popup, it should show either the default result or the field of the subset layer, depending on whether there is a subset parcel intersecting the queried feature.
... View more
05-18-2022
01:27 AM
|
0
|
3
|
6183
|
|
POST
|
Please share a screenshot of your tool parameters, that might make troubleshooting easier. certain point features Do you mean feature classes, as in "feature class 1 works, feature class 2 does not"? Or do you mean actual features as in "this point works, but this point in the same feature class does not"? Things to check off the top of my head: Do you have write access to the feature class? CheckGeometry and, if applicable, RepairGeometry
... View more
05-17-2022
04:37 AM
|
0
|
1
|
4176
|
| 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
|