|
POST
|
Just out of curiosity: When looking at the Kudos of a post, there is a tab for users and a tab for experts. From How to use Kudos: Click Experts to see Kudos given by high-ranking members of the community. Experts are usually moderators and other members who had a kudos weight of more than 1 when they gave the post kudos. Just skimming over some kudoed posts: MVP users, ESRI staff, and Community Managers aren't counted as experts. So, is this feature used at all? Who are these elusive experts?
... View more
06-08-2022
06:32 AM
|
2
|
2
|
1225
|
|
POST
|
Disclaimer: I haven't worked with Validation Rules yet, only Calculation. AFAIK, you can't directly write from validation rules. You just return true or false and ArcGIS creates the error feature automatically, in your case that would be a polygon. Of course, telling your editors that there's a duplicate vertex, but not which of the 1000's of vertices is not really helpful... You could try adding points to the point error class using a return dictionary: return {
"result": false,
"edit": [
{
"className": "GDB_ValidationPointErrors",
"adds": [
{"geometry": Geometry($feature).rings[0][0]}
]
}
]
} I don't think that will work though, as these feature classes are special and thus probably protected. You could also try to create a new point feature class and add the duplicate vertices to that fc. That could work, but your editors would have to manually remove the points when they are finished correcting the feature.
... View more
06-08-2022
05:56 AM
|
0
|
0
|
1783
|
|
BLOG
|
Good find, excellent write-up! From the shortcuts you listed, I'm most excited for the regex search and replace, that's going to be helpful (even though I'll probably spend longer trying to figure out the regex syntax than just doing it manually...) The article you linked made me aware of the fold marks next to the line numbers, with these you can hide multi-line code blocks (eg function bodies, if and for blocks, list and dictionary declarations). Pretty basic IDE stuff, but I didn't notice it in the editor before. With shortcuts, you can even fold arbitrary lines, though that is probably not going to help with readability... Sadly, the theme setting only applies to the editor window. That makes the editor look kinda out of place next to the unchanged Globals/Functions/Constants view:
... View more
06-08-2022
05:37 AM
|
1
|
0
|
1610
|
|
POST
|
It's hard to tell what the error could be, because there is no code in line 9 in your code. Please try the code below and post the error message if you get one. Things I noticed: You're using IIf() wrong. The signature is IIf(condition, value_if_true, value_if_false). Apparently, you're manually entering IDs for the site, which leads to the need for checking for duplicates. You should consider using a database sequence and assigning the ID automatically with NextSequenceValue(). For this problem, you don't need to guard against null values. A) because if Intersects() or Filter() don't find any entries, they will return an empty feature set with a Count() of 0. B) because you will find at least 1 feature (the current $feature) with both Intersects() and Filter(). At least, you don't need the cjecks you tried to implement. Your error suggests that there is an empty geometry somewhere (probably the Intersects()), could be that you have to guard against that. You do need to guard against null when you do something like this: First(empty_featureset).Attribute Calling First() on an empty featureset returns null, and trying to call an attribute of null will result in an error. // reference the sites database
var existing_ahims_sites = FeatureSetByName($datastore, "gdb.owner.fd_nsw_ch_cultural_heritage_site_point", ["niche_id"])
var new_ahims_id = $feature.niche_id
//check for intersects
var intersect_count = Count(Intersects(existing_ahims_sites, $feature))
//query the output of the intersect check and set the result variable
var intersection_result = IIf(intersect_count > 1, "Site intersects existing point", "Site does not intersect existing point")
//check for duplicate site IDs
var duplicate_count = Count(Filter(existing_ahims_sites, "niche_id = @new_ahims_id"))
//query the output of the duplicate check and set the result variable
var id_check = IIf(duplicate_count > 1, "Site id already in database.", "site ID not found in database")
//combine the results
var site_validation_result = Concatenate([id_check, intersection_result], "; ")
return site_validation_result
... View more
06-08-2022
04:50 AM
|
0
|
0
|
3106
|
|
IDEA
|
Please add your support to this idea: Arcade Community - Esri Community
... View more
06-08-2022
01:10 AM
|
0
|
0
|
1299
|
|
POST
|
It's because you iterate over tbl, not over the filtered inspections. Your expressions returns the date of the last entry in the inspection table. var tbl = FeatureSetByName($datastore,"TestPoints", ['UNIQUE_ID', 'Inspection_Date'])
var uniqueid = $feature["Unique_ID"]
var sql = "UNIQUE_ID= @uniqueid"
Console(sql)
// Filter by UNIQUE_ID and sort the result by date
var inspections = OrderBy(Filter(tbl, sql), "Inspection_Date")
var cnt = Count(inspections)
// return early if there are no inspections
if(cnt == 0) {
return "No inspections"
}
// get all inspections in a list
var history = [
`${cnt} inspections`
]
for (var inspection in inspections) {
var insp_date = Text(inspection.Inspection_Date, 'MM/DD/YYYY')
Push(history, `Inspected: ${insp_date}`)
}
// return the concatenated list
return Concatenate(history, TextFormatting.NewLine) If you only want to return the latest inspection, you can do it like this: var tbl = FeatureSetByName($datastore,"TestPoints", ['UNIQUE_ID', 'Inspection_Date'])
var uniqueid = $feature["Unique_ID"]
var sql = "UNIQUE_ID= @uniqueid"
Console(sql)
// Filter by UNIQUE_ID and sort the result by date DESCENDING
var inspections = OrderBy(Filter(tbl, sql), "Inspection_Date DESC")
var cnt = Count(inspections)
// return early if there are no inspections
if(cnt == 0) {
return "No inspections"
}
// get the last inspection date
var insp_date = Text(First(inspections).Inspection_Date, 'MM/DD/YYYY')
var history = [
`${cnt} inspections`,
`Last inspection: ${insp_date}`
]
return Concatenate(history, TextFormatting.NewLine)
... View more
06-08-2022
01:01 AM
|
1
|
2
|
2114
|
|
POST
|
Documentation for polygons and polylines: Type System | ArcGIS Arcade | ArcGIS Developer Polygons have a rings attribute, polylines have a paths attribute. These are three-dimensional lists of numbers, representing point coordinates of multiple line segments / rings. // get the number of vertices in a polygon
var rings = Geometry($feature).rings
var vertex_count = 0
for(var i in rings) {
vertex_count += Count(rings[i])
// for polygons, the first and last point of a ring are the same, so we have to subract 1
vertex_count -= 1
}
return vertex_count // get number of points on vertices
var rings = Geometry($feature).rings
var point_fc = FeatureSetByName($datastore, "TestPoints", ["OBJECTID"], true)
var points_on_vertices = 0
for(var i in rings) {
for(var j in rings[i]) {
var vertex = rings[i][j]
points_on_vertices += Count(Intersects(vertex, point_fc))
}
}
return points_on_vertices
... View more
06-08-2022
12:21 AM
|
0
|
0
|
1407
|
|
POST
|
It's because Python sorts the counts as strings (because they are), not as numbers. And in string sorting, "7" is greater than "17". To solve that, you have to cast the string to int in the sorted() call. lst = [['Rabbit', '7'], ['Dog', '3'], ['Bird', '17'], ['Cat', '0']]
rnk_lst = ['Cat', 'Bird', 'Dog', 'Rabbit']
sorted_output = sorted(lst, key=lambda r: (int(r[1]), rnk_lst.index(r[0])), reverse=True)
print(f"sorted output: {sorted_output}")
most_significant_output = sorted_output[0]
print(most_significant_output[0]) sorted output: [['Bird', '17'], ['Rabbit', '7'], ['Dog', '3'], ['Cat', '0']]
Bird
... View more
06-07-2022
11:12 PM
|
0
|
1
|
3746
|
|
POST
|
To find multiples of a number, you can use the modulo operator. X modulo Y means "divide X by Y and return the rest". If the modulo is zero, X is divisible by Y, so it's a multiple. So you could do something like this: var cngmetros = $feature.cngmetros
// if value is zero or divisible by 5
// % is the modulo operator in many languages
if(cngmetros == 0 || cngmetros % 5 == 0) {
return cngmetros
}
... View more
06-07-2022
10:52 PM
|
2
|
0
|
1066
|
|
POST
|
OK. Now, for the address question, use your old code: var lookupValue = Trim($feature.OldMeterNumber);
var meter = Mid(lookupValue, 3, 9);
var d = Dictionary(
"314421199", "69944 SUNNYFIELD RD");
if (hasKey(d, meter)) {
console(" >>> " + meter + " was found! " + "Address: " + d[meter]);
return d[meter];
} else {
console(" >>> The meter was NOT found!");
return "Unknown";
}; For the Old meter number question, use the short code: var lookupValue = Trim($feature.OldMeterNumber);
var meter = Mid(lookupValue, 3, 9);
return meter Or, if you can't add code to that question, create a new question ("Old Meter Short Code" or something like that).
... View more
06-02-2022
08:06 AM
|
1
|
1
|
4753
|
|
POST
|
Ah, ok. As I said, completely unfamiliar with Field Maps, so I'm probably not going to be a huge help here. But still: var lookupValue = Trim($feature.OldMeterNumber);
var meter = Mid(lookupValue, 3, 9);
return meter Try that as expression on OldMeterNumber (if it will let you do that). If that doesn't work, try creating a new field (that isn't populated by any other means) and use the expression on the new field. If that still doesn't work, I'm out.
... View more
06-02-2022
07:43 AM
|
0
|
5
|
4760
|
|
POST
|
I'm unfamiliar with FIeld Maps. Do you implement the code as Attribute Rule on a feature class (that's what I'm assuming)? Try creating a new Attribute Rule, leaving the field empty (forgot that in my first answer). If that fails, do it in 2 rules: In the first rule (field "Address"), use your old code. In the second rule (field "OldMeterNumber"), copy the first two lines and then return meter.
... View more
06-02-2022
06:44 AM
|
0
|
7
|
4772
|
|
POST
|
For what you want to do, this would be a starting point: // load all addresses
var addresses = FeatureSetByName($datastore, "AddressTableName", ["MainProvider"], false)
// filter the addresses for the main provider of the active feature
var provider = $feature.MainProvider
var filtered_addresses = Filter(addresses, "MainProvider = @provider")
// count and return error message
if(Count(filtered_addresses) > 25) {
return {"errorMessage": "A provider can't supply more than 25 addresses!"}
}
// if we land here, the provider has <= 25 addresses
// rest of your code
... View more
06-02-2022
06:21 AM
|
1
|
0
|
1423
|
|
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 t... 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
06-02-2022
06:17 AM
|
2
|
0
|
1425
|
| 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
|