POST
|
I'm getting an "Error on line 9. String type expected" message when I try this method. Is trying to use "$feature" on a standalone table an issue (i.e., does the data source have to be a feature layer)? I tried whittling my list down to just one field to be sure that wasn't the problem.
... View more
04-07-2022
09:25 AM
|
0
|
1
|
2794
|
POST
|
Thanks, Johannes! While my brain doesn't quite comprehend your method as well as it does Josh's above, I can see how this method works too.
... View more
04-07-2022
06:52 AM
|
1
|
2
|
2803
|
POST
|
Thanks, Josh! This seems to be the way my brain was thinking about it but clearly didn't have the syntax quite right.
... View more
04-07-2022
06:51 AM
|
1
|
0
|
2803
|
POST
|
I'm attempting to create an Attribute Rule Calculation that counts the number of occurrences of a given value ("x") in a number of fields in a dataset. I want to update a different field ("IssuesCount") in the said dataset with that number. In total, there are 15 fields that I need to check. My thought was that I would start with a list of fields names that I want to check then dynamically generate the field names, check to see if they contained "x", then count up the occurrences. But I'm struggling to dynamically generate the field names from the list. Here's the list of fields : var fieldList = ['IssueAdjacentProperty', 'IssueCultivation',
'IssueFoodPlots', 'IssueHaying', 'IssueTimberHarvestCutting',
'IssueBurning', 'IssueNewExpandedTrail', 'IssueNewExpandedRoad',
'IssueParkedEquipment', 'IssueNewBuildings', 'IssueGrazingLivestock',
'IssueCommercialSeed', 'IssueUtilities', 'IssueMining', 'IssueImpervious',
'IssueHydrology', 'IssueUnauthorizedEasement', 'IssueWaste', 'IssueMowing',
'IssueOther', 'IssueExpandedYard', 'IssueFencing', 'IssueErosion',
'IssueStormwater', 'IssueYardWaste'] And here's me trying to dynamically generate the field names to check the values: // Dynamically generate field name
for (var f in fieldList){
// Doesn't work as it returns the literal string of '$feature.0'
var fieldName = "$feature." + f
// Return the value in the field.
// This part doesn't work because 'fieldName' equals
// '$feature.0' at this point and Arcade is looking
// for a field called 'fieldName' here.
var checkValue = $feature.fieldName
// Then do something like loop through fields checking for 'x'
// (unless there is a more efficient way to do that too)
var counter = 0
if (checkValue == 'x') {
counter++;
}
}
// Return the count
return counter; I think once I get this field name piece figured out I have, I know what to do on the rest of the Attribute Rule side of things. Thanks for any help! Todd Lusk, Senior GIS Specialist Dakota County, MN
... View more
04-07-2022
04:44 AM
|
0
|
7
|
2861
|
POST
|
Thanks so much! That was just about perfect but got me headed in the right direction. Here was is my final implementation: var fs = FeatureSetByPortalItem(
Portal('https://dakotacounty.maps.arcgis.com'),
'3f1ab7bbf9674ccc851176de9d922450',
5,
['OBJECTID', 'NO_LOSS_TYPE1', 'NO_LOSS_TYPE2'],
false
);
// summary FeatureSets
var no_loss_type_1 = Filter(fs, 'NO_LOSS_TYPE1 IS NOT NULL');
var no_loss_type_2 = Filter(fs, 'NO_LOSS_TYPE2 IS NOT NULL');
// Grouped statistics
var group_type_1 = GroupBy(no_loss_type_1,
[
{name: 'Category',expression:'NO_LOSS_TYPE1'}
],
[
{ name: 'FeatureCount', expression: 'OBJECTID', statistic: 'COUNT' }
]
);
var group_type_2 = GroupBy(no_loss_type_2,
[
{name: 'Category', expression:'NO_LOSS_TYPE2'}
],
[
{name: 'FeatureCount', expression: 'OBJECTID', statistic: 'COUNT' }
]
);
// This is ugly, but it works
var count_dict = {} // dict of {Category: FeatureCount}
var cat_array = [] // to keep track of the dict keys
var fs_array = [group_type_1, group_type_2] // FeatureSets to combine
for(var i in fs_array) {
for(var f in fs_array[i]) {
// get category and feature count
var cat = f.Category
var cnt = f.FeatureCount
if(Includes(cat_array, cat)) {
// cat already in dict? -> add the dict's value to cnt
cnt += count_dict[cat]
} else {
// new cat? -> append cat to cat_array
Push(cat_array, cat)
}
// add/update the count in count_dict
count_dict[cat] = cnt
}
}
// Create output FeatureSet
var out_fs = {
"fields":[
{"name":"Category","type":"esriFieldTypeString"},
{"name":"FeatureCount","type":"esriFieldTypeInteger"},
],
"geometryType":"",
"features":[]
}
// add features
for(var i in cat_array) {
var cat = cat_array[i]
var f = {"attributes": {"Category": cat, "FeatureCount": count_dict[cat]}}
Push(out_fs.features, f)
}
return FeatureSet(Text(out_fs))
... View more
12-15-2021
06:24 AM
|
0
|
0
|
439
|
POST
|
Greetings all- I need to merge two summary results together to use in a serial chart in Dashboard. The summary tables/results look like the following: Summary 1 - NO_LOSS_TYPE1 Category FeatureCount FID A - No Impact 35 0 B - Material Excavation 2 1 D - Habitat Restoration 3 2 E - Stormwater Excavation 8 3 F - Utilities 2 4 H - Temporary Impact 14 5 Summary 2 - NO_LOSS_TYPE2 Category FeatureCount FID B - Material Excavation 1 0 E - Stormwater Excavation 3 1 F - Utilities 1 2 H - Temporary Impact 2 3 As you can see, sometimes the "Category" value matches. If it matches the two result sets, I want to add the "FeatureCount" values together. If the "Category" value doesn't exist, I want to append/add it to the output results. So I'd ultimately like to end up with something like the following: Category FeatureCount FID A - No Impact 35 0 B - Material Excavation 3 (i.e., 2 + 1) 1 D - Habitat Restoration 3 2 E - Stormwater Excavation 11 (i.e,. 8 + 3) 3 F - Utilities 3 (i.e., 3 + 1) 4 H - Temporary Impact 16 (i.e., 14 + 2) 5 I've managed to get the summary results okay, but am struggling with where to go next. I've added those summary results to a dictionary, but then have trouble finding the corresponding keys in either of the dictionaries while trying to "merge" the two of them together. I've been looping through one dictionary and using "HasKey()" to see if it has a corresponding key from the second dictionary, but that hasn't been finding the keys. My "input" dictionaries look like this: Dictionary 1 {"fields":[{"name":"Category","type":"esriFieldTypeString"},{"name":"FeatureCount","type":"esriFieldTypeInteger"}],"geometryType":"","features":[{"attributes":{"Category":"A - No Impact","FeatureCount":35}},{"attributes":{"Category":"B - Material Excavation","FeatureCount":2}},{"attributes":{"Category":"D - Habitat Restoration","FeatureCount":3}},{"attributes":{"Category":"E - Stormwater Excavation","FeatureCount":8}},{"attributes":{"Category":"F - Utilities","FeatureCount":2}},{"attributes":{"Category":"H - Temporary Impact","FeatureCount":14}}]} Dictionary 2 {"fields":[{"name":"Category","type":"esriFieldTypeString"},{"name":"FeatureCount","type":"esriFieldTypeInteger"}],"geometryType":"","features":[{"attributes":{"Category":"B - Material Excavation","FeatureCount":1}},{"attributes":{"Category":"E - Stormwater Excavation","FeatureCount":3}},{"attributes":{"Category":"F - Utilities","FeatureCount":1}},{"attributes":{"Category":"H - Temporary Impact","FeatureCount":2}}]} Any help is greatly appreciated!
... View more
12-14-2021
01:15 PM
|
0
|
2
|
471
|
POST
|
Awesome, thank you so much! I had the "logic" right in my head but couldn't quite figure out the syntax.
... View more
12-09-2021
03:04 AM
|
0
|
0
|
2433
|
POST
|
I have two dictionaries that I would like to merge into a combined one with the "values" added together (see below). The dictionaries are the results of "Summary Counts" of two different columns of data in a hosted feature layer. Here are the dictionaries: d1 = {"A":10, "B":20, "C":30} d2 = {"A":1, "B":14, "D":3, "E":5} I would like to end up with something like: d3 = {"A":11, "B":34, "C":30, "D":3, "E":3} As you can see, the dictionary "keys" may not be the same between the two summaries every time. Ultimately, I want to use the combined summary (i.e., the data in"d3") in a Serial Chart in a Dashboard. I'm struggling with how to compare the two dictionaries and check for corresponding keys in each.
... View more
12-08-2021
02:07 PM
|
0
|
2
|
2482
|
IDEA
|
It would be helpful to have something like this for charting cumulative and new daily COVID-19 cases on one chart.
... View more
06-15-2020
11:56 AM
|
2
|
0
|
4345
|
POST
|
No, ArcCatalog. We turned the services pointing at this feature class off, added the fields in SDE through ArcCatalog, then refreshed the service.
... View more
03-23-2018
11:58 AM
|
0
|
1
|
969
|
POST
|
Running into this exact same issue. It does seem like it's only the "Edit" widget is the only one that has the problem "seeing" the new field. Several of the other widgets ("Smart Editor", "Filter", "Attribute Table", etc.) seem to be able to see the new field just fine.
... View more
02-26-2018
06:58 AM
|
2
|
2
|
2170
|
POST
|
When I flip a centerline I often need to flip several other attributes (municipality, postal city, zip code, response area keys/values) as well. Would there be an easy way to set this up to do that too? Granted, that probably requires that the code "know" all the different values that need to be checked and what the corresponding fields are called. When I was thinking of developing something similar to this, I was heading down the path of checking the values on the left and right "sides" of the street to see if they were different then swapping them if they were. For example, if CITY_L <> CITY_R, swap them. Just for fun, here's a list of the all fields we have to check if we're flipping the direction of a line: CITY_L & CITY_R ZIP_L & ZIP_R PCITY_L & PCITY_R To_Elevation & From_Elevation ESZ_L & ESZ_R PSAP_L & PSAP_R COUNTY_L & COUNTY_R F_EXT_KEY_L & F_EXT_KEY_R L_EXT_KEY_L & L_EXT_KEY_R RD_L & RD_R OneWay (If "F", change to "T" or if "T", change to "F")
... View more
01-17-2017
09:05 AM
|
0
|
0
|
542
|
POST
|
LEFT_FROM_ADD LEFT_TO_ADD RIGHT_FROM_ADD RIGHT_TO_ADD
... View more
01-17-2017
08:48 AM
|
0
|
0
|
542
|
POST
|
I think you have to check the "relative paths" option then "reload" the script so that the tool picks up on the new relative path.
... View more
08-12-2014
12:23 PM
|
0
|
0
|
759
|
Title | Kudos | Posted |
---|---|---|
1 | 04-07-2022 06:52 AM | |
1 | 04-07-2022 06:51 AM | |
2 | 06-15-2020 11:56 AM | |
2 | 02-26-2018 06:58 AM |
Online Status |
Offline
|
Date Last Visited |
07-19-2023
08:15 PM
|