|
IDEA
|
When you validate an Arcade expression, Pro takes a feature (the first?) from the table, applies the expression to it, and returns errors it encounters. This validation does not take into account definition queries. For example: I have a text field with date values that I wanto to convert into actual dates. In the layer, I have a definition query that filters out null values. The Arcade validation doesn't honor that query and validates the expression with an empty value, giving an error. The actual tool does honor the definition query, leading to the absurd situation that the tool runs successfully although the expression failed to validate. Also, it makes debugging really difficult, because there's nothing wrong with the expressions or the (visible) values in the table. Please make the Arcade validation honor definition queries.
... View more
10-25-2022
04:17 AM
|
8
|
3
|
2167
|
|
POST
|
Here's your error: IndexOf searches for an element in an array and returns its index. It returns -1 if the element is not in the list. So you searched for 0, 1, and 2 in ["1", "1", "1987"]. These elements are not in the array, so IndexOf returns -1. To get a certain element of an array by index, use bracket notation: var test_array = [1, 2, 3]
Console(test_array[0]) // 1
Console(test_array[1]) // 2
Console(test_array[2]) // 3
Console(test_array[-1]) // 3
Console(test_array[-2]) // 2
Console(test_array[-3]) // 1
Console(test_array[3]) // index error
Console(test_array[-4]) // index error
... View more
10-25-2022
02:10 AM
|
0
|
0
|
1762
|
|
POST
|
var date_array = Split("01/01/1987","/",-1);
// Date(year, month day)
// month is zero indexed -> January is 0
return Date(date_array[2], date_array[1] - 1, date_array[0])
... View more
10-25-2022
02:05 AM
|
0
|
0
|
1765
|
|
IDEA
|
the reason you cannot do this in Field Calculator is because this problem requires the iteration of the table, in order to sum all of the Shape_Area fields, prior to performing the final calculation; and Field Calculator lacks that functionality. This is true for Python. In Python, things like this are easiest done with an arcpy.da.UpdateCursor. You can do it with Arcade: $feature.Shape_Area / Sum($featureset, "Shape_Area")
... View more
10-24-2022
11:03 PM
|
0
|
0
|
3440
|
|
POST
|
You need to save the project. aprx.save() If you're running this in the project you want to change, use "current" instead of the project path, that way you will see the updates in the project. aprx = arcpy.mp.ArcGISProject("current")
... View more
10-24-2022
10:40 PM
|
0
|
1
|
1718
|
|
POST
|
You probably won't find ESRI documentation for split(), as that's a basic Pythonj function, not something ESRI developed. split() takes a string and splits it at the given character. Optionally, you can tell it how many splits to do. It outputs a list. "this is a string".split(" ")
# ['this', 'is', 'a', 'string']
"this is a string".split(" ", 1)
# ['this', 'is a string'] The official documentation is here (scroll to str.split): 4. Built-in Types — Python 3.3.7 documentation An easier documentation is here: Python String split() Method (w3schools.com) A list is a collection of elements that you can address by using their position in the collection (their index). Examples can be found here: Python Indexing and Slicing for Lists and other Sequential Types | Railsware Blog As for your problem: Yes, do field calculations for the two fields. For the field that contains the road type: !Street_Name!.split(" ")[-1] This will get the last element of the split name. For the field that contains the name: " ".join(!Street_Name!.split(" ")[:-1]) This gets all elements of the split name, up to (excluding) the last. Then it joins those elements together into a single string (the opposite of split()). "San Marino Dr".split(" ")[-1]
# 'Dr'
" ".join("San Marino Dr".split(" ")[:-1])
# 'San Marino'
... View more
10-24-2022
10:14 PM
|
4
|
2
|
2419
|
|
POST
|
open the Python window Copy and paste the script edit the variables at the start of the script run with Enter
... View more
10-24-2022
09:49 PM
|
0
|
0
|
7311
|
|
POST
|
// load the polygons
var polygons = FeaturesetByName($datastore, "PolygonFeatureclass")
// get all intersecting polygons (instead of the first one)
polygons = Intersects(polygons, $feature)
// loop through the intersecting polygons and extract the names into an array
var names = []
for(var poly in polygons) {
Push(names, poly.Name)
}
// concatenate and return
return Concatenate(names, ", ")
... View more
10-24-2022
05:33 AM
|
1
|
0
|
13338
|
|
POST
|
Great, glad I could help. Please mark my answer as solution, so that this question is shown as solved.
... View more
10-23-2022
11:00 PM
|
1
|
2
|
13354
|
|
POST
|
If you modify the rule, you can make it so that if it doesn't find an intersecting polygon in the first FC, it tries the second Polygon FC: // load the polygons
var polygons = FeaturesetByName($datastore, "PolygonFeatureclass")
// get the polygon that intersects the current point
var i_polygon = First(Intersects(polygons, $feature))
// if no polygon is intersecting, try the second polygon fc
if(i_polygon == null) {
var polygons = FeaturesetByName($datastore, "PolygonFeatureclass_2")
var i_polygon = First(Intersects(polygons, $feature))
// if there is no0 intersecting polygon here, too, return null
if(i_polygon == null) { return null }
}
// return the name of the Polygon
return i_polygon.Name Is that what you're trying to do? Also, if this is a task you have to do often, you might want to consider making this expression into an Attribute Rule for each of the point fcs. Attribute Rules can be executed when a feature is inserted or edited. This way, the name would be updated automatically every time you edit a point.
... View more
10-23-2022
10:39 PM
|
0
|
4
|
13361
|
|
POST
|
var arr = Split($feature.JAPAN_NAME, " ");
var output = `<FNT size = '20'>${arr[0]}</FNT>`;
if (Count(arr) > 1) {
output += ` <FNT size = '12'> ${arr[1]}</FNT>`;
}
output += TextFormatting.NewLine
output += `<FNT size = '12'>${$feature.NAME}</FNT>`;
return output;
... View more
10-23-2022
10:07 PM
|
1
|
1
|
1355
|
|
POST
|
Arcade, the script language developed by ESRI for the ArcGIS infrastructure, is perfect for that. Use the Calculate Field tool on the point feature class, change the language to Arcade. Use this expression, edit the polygon feature class's name (first line) and the name field (last line): // load the polygons
var polygons = FeaturesetByName($datastore, "PolygonFeatureclass")
// get the polygon that intersects the current point
var i_polygon = First(Intersects(polygons, $feature))
// return a default value if no polygon is intersecting
if(i_polygon == null) { return null }
// return the name of the Polygon
return i_polygon.Name
... View more
10-23-2022
10:04 PM
|
4
|
8
|
13365
|
|
POST
|
Calculate Field, use Arcade var km = Length($feature)/1000
return Text(km, "#.0") + "km"
... View more
10-21-2022
05:28 AM
|
2
|
1
|
2318
|
|
POST
|
My guess: The time of Descriptio is 00:00:00, but Date(year, month, day) has a time according to your time zone (eg. 02:00:00 for CEST, UTC+2) Don't trust the automatic conversion, do it yourself: var d = Text($feature.Descriptio, "MM/DD/Y")
var s = Split(d, "/")
var revegDate = Date(s[2], s[0] - 1, s[1]) PS: If you want to change the periods, you're going to have a hard time. A more flexible approach would be something like this: var start_date = Date(1945, 0, 19)
var period_length = 7
var period_num = 5
// convert the date
var s = Split($feature.TextField, "/")
var d = Date(s[2], s[0] - 1, s[1])
// calculate and return the period
for(var i = 0; i < period_num; i++) {
var end_date = DateAdd(start_date, period_length - 1, "days")
if(d >= start_date && d <= end_date) {
return Text(start_date, "MM/DD/Y") + " - " + Text(end_date, "MM/DD/Y")
}
start_date = DateAdd(start_date, period_length, "days")
}
// date outside chosen periods
return "Other period"
... View more
10-21-2022
03:17 AM
|
3
|
0
|
1051
|
|
POST
|
ListFeatureClasses only lists feature classes in the current workspace. So to get to the shape files in the subfolders, you have to change your workspace. workspaces = ap.ListWorkspaces("*", "Folder")
print(workspaces)
# Listing datasets in workspaces
for ws in workspaces:
arcpy.env.workspace = ws
fc = ap.ListFeatureClasses("*", "Polygon")
print(fc)
... View more
10-20-2022
11:00 PM
|
0
|
0
|
1561
|
| 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
|