|
POST
|
Create a new Double field, then run Calculate Field with this Python expression (note the exclamation marks in line 2): # NewField =
convert(!OldField!)
# Code Block
def convert(x):
try:
return float(x)
except:
return None
... View more
08-15-2023
02:38 PM
|
2
|
0
|
3530
|
|
POST
|
Just do this in line 10: return result Be aware that the code in my answer is for an Arcade element, which needs to return the dictionary. In Arcade expressions, you can return a simple value, but they are limited in what they can display (eg they can't interpret HTML, which was the point of this question).
... View more
08-15-2023
02:28 PM
|
1
|
2
|
9740
|
|
POST
|
The tools don't use the Python Window console, you aren't able to see print() output. Instead, use arcpy.AddMessage(): # bla bla
arcpy.AddMessage("This is a debug message, all is well...")
# bla bla The messages will be visible in the tool's details:
... View more
08-11-2023
02:07 PM
|
3
|
0
|
6343
|
|
POST
|
Go to your profile page and click the search button: This will automatically lead you to the search for all the posts you authored. This gets set automatically. You can also do it manually with the "Author" dropdown in a normal search. You can sort the result. It doesn't show each of your posts right on this screen. You have 42 posts, but it only shows 19 results. That's because... It only shows the thread titles and summarizes all your posts in that thread.
... View more
08-11-2023
01:47 PM
|
1
|
0
|
1320
|
|
POST
|
Does anyone know why this is not working It's not working because you're searching for the literal string "UNIT", not the value of the field. Your query will filter out values like "123 UNIT", "UNIT 456", "abcUNIT123". You have to surround the UNIT field's value with '%'. Online search suggests using '+' or 'CONCAT'. These didn't work for me in a file gdb, but '||' did. UNIT IS NOT NULL AND FULLADDRESS NOT LIKE '%' + UNIT + '%'
UNIT IS NOT NULL AND FULLADDRESS NOT LIKE CONCAT('%', UNIT, '%')
UNIT IS NOT NULL AND FULLADDRESS NOT LIKE '%' || UNIT || '%'
... View more
08-11-2023
01:28 PM
|
1
|
1
|
2817
|
|
POST
|
To post code: I'm wondering if it is possible to do this with geometry Yep. Set the Field to "Shape" and return the other feature's geometry: // bla bla
return Geometry(First(relationship))
... View more
08-11-2023
01:03 PM
|
1
|
1
|
1615
|
|
POST
|
Haven't seen this error before, but it sounds like your field is an integer field? Try rounding the output: return Round(Angle(segment[0], segment[-1]))
... View more
08-11-2023
12:57 PM
|
1
|
1
|
4482
|
|
POST
|
The coordinates suggest that you are using a geographic coordinate system. For distance measurements, you should use a projected coordinate system.
... View more
08-10-2023
01:04 PM
|
0
|
0
|
2232
|
|
POST
|
var all_inspections = FeaturesetByName($map, "Inspections")
var hydrant_id = $feature.HydrantID
var hydrant_inspections = Filter(all_inspections, "HydrantID = @hydrant_id")
var sorted_inspections = OrderBy(hydrant_inspections, "InspectionDate DESC")
var latest_inspection = First(sorted_inspections)
if(latest_inspection == null) { return "No inspection found" }
return latest_inspection.InspectionDate
... View more
08-10-2023
12:57 PM
|
0
|
1
|
1570
|
|
POST
|
It's also worth to note that there are two ways to address a dictionary key or field value (the example uses both, which is ugly...) bracket notation with the dictionary key or field name as string: dict["key"] $feature["Field"] dot notation dict.key $feature.Field
... View more
08-10-2023
12:41 PM
|
0
|
0
|
1391
|
|
POST
|
To post code: var choicesDict = {
'fields': [
{'name': 'split_choices', 'type': 'esriFieldTypeString'},
],
'geometryType': '',
'features': []
} They are creating a Dictionary that is used to return the final Featureset. Featuresets are collections of features. They can be constructed from a Dictionary or from a JSON string (representing the dictionary). A Featureset has to have the following keys: fields: an Array of Dictionaries describing the fields of the Featureset. These dictionaries have the following keys: name: String, the field's name type: String, the field's type. The important types are: esriFieldTypeString esriFieldTypeInteger esriFieldTypeDouble esriFieldTypeDate alias (optional): String, the field's alias geometryType: String, the geometry type of the contained features. Possible values are esriGeometryPoint esriGeometryMultipoint esriGeometryPolyline esriGeometryPolygon empty string (no geometry) features: Array of Dictionaries describing the contained features In the snippet above, they are creating this structure. They are declaring the featureset to be a non-spatial table (geometryType = "") with one String field called split_choices. They leave the contained features empty. This is a common workflow. You create your dictionary and then fill in the features in a later step (see next snippet). The second snippet uses an old workflow, I'm going to update it here: for (var f in fs) {
var split_array = Split(f["Report_road_condition"], ',')
for(var i in split_arr){
var new_feature = {
'attributes': { 'split_choices': Trim(split_array[i]) }
}
Push(choicesDict.features, new_feature)
}
} Repeat the following block (until line 9) for each feature (f) in the input featureset (fs) Take the value in the field Report_road_condition and Split it by comma, creating an array of string values Repeat the following block (until line 😎 for each index in that array create a dictionary describing a feature these dictionaries have the following keys attributes: dictionary of the feature's attributes { field_name: field_value } geometry (optional): the feature's geometry Trim the current element of the array and use the output as value for the field split_choices Push the feature we just created into the features array of the output dictionary So in this step, they loop over each feature in the input featrueset, split a field value of that feature, and append each part to the output featureset. If the input featureset has one feature with the value "A, B, C", the output featureset will have three features with the values "A", "B", "C". The last step in these workflows is to return the Dictionary as Featureset: return Featureset(choicesDict)
... View more
08-10-2023
12:36 PM
|
0
|
1
|
1391
|
|
POST
|
Decode() is a switch/case statement, it matches the values exactly. You want When() , which is a nested if/else. Also, take a look at the logical operators. var cd25 = $datapoint["capdep25"
var color = When(
cd25 <= 0.25, "DE73FF",
cd25 > 0.25 && cd25 <= 0.5, "0070FF",
cd25 > 0.5 && cd25 <= 0.75, "38A800",
"E60000"
)
... View more
08-09-2023
03:45 AM
|
2
|
4
|
4101
|
|
POST
|
Ah, and the spatial join doesn't update, didn't know that. OK, then let's try doing it in Dynamic Text and Arcade. I've tried using Intersects() and the $map and $datastore profiles to lookup my plantation layer, but my understanding is the dynamic text doesn't recognise the $map profile and the $datastore profile only returns layers in a feature service. Correct, the Arcade Layout profile doesn't recognize the $map global (which is a bit weird, because you specify the map frame you want to extract the table attribute from). But $datastore will work as long as Plantations and Lots are in the same database / feature service. This will list all Lots numbers (TextField1 in my layer) intersected by Plantations (note that you insert a table attribute for the plantation layer): var lots = FeaturesetByName($datastore, "Lots")
var i_lots = Intersects($feature, lots)
var lot_names = []
for(var lot in i_lots) {
Push(lot_names, lot.TextField1)
}
return Concatenate(lot_names, ", ") This works fine if you have only one plantation: With multiple plantations on different lots, the lot numbers will be unsorted: With multiple plantations on the same lots, the lot numbers will be duplicated:
... View more
08-09-2023
03:26 AM
|
1
|
1
|
4279
|
|
POST
|
Aren't you describing a Spatial Join? add a Spatial Join to your Lots layer (intersect with Plantation layer, keep all features) This will add a column "Join_Count" in the layout, add a table frame for the joined Lots layer, filter by Join_Count
... View more
08-08-2023
03:55 PM
|
0
|
3
|
4303
|
|
POST
|
Hmm, I couldn't reproduce the error. But you need a null check after line 10: if(nearestPly == null) { return "No polygon found" } And right now you're returning a dictionary with the keys "coordinate" and "distance". You probably want to return one of those values instead.
... View more
08-08-2023
11:41 AM
|
1
|
0
|
2259
|
| 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
|