POST
|
Hi, Finally, I am trying to use the $layer global variable to loop through all features in order to sum acreage per cities. The Arcade expression makes an initial distinct list of cities in the $layer and then calculates acreage acreage accordingly for each $feature, as follow: var myArray = [];
var i = 0;
for(var z in $layer) {
Insert(myArray, i, z.City);
i = i + 1;
}
var myArrayDistinct = Distinct(myArray);
var myArrayDistinctSort = Sort(myArrayDistinct);
var acreage = 0;
for(var a in myArrayDistinctSort) {
for(var z in $layer) {
if (z.City == myArrayDistinctSort[a]) {
acreage = acreage + z.AreaGeodetic(z, 'acres');
}
}
}
return acreage; but I still get an: Invalid expression. Error on line 3. Object not found $layer For info, I am using this Arcade expression in Calculate field tool. Any guess?
... View more
08-17-2023
08:09 AM
|
0
|
1
|
522
|
POST
|
Fantastic! I will try that. I knew there was something easy. Appreciated
... View more
07-06-2023
09:00 AM
|
0
|
0
|
600
|
POST
|
Hi, I have an Arcade expression in which I would like to look through all features for calculation. I start my expression as: var Zoning = FeatureSetByName($layer,["City"],true); I would like to use the variable 'Zoning' to loop in order to calculate in each $feature using the 'City' attribute and the geometry (hence 'True') In Arcade, I though I could simply point to the current layer using $layer but it does not work! For info, I am using this Arcade expression in Calculate Field in Model Builder and I cannot easily reference the $datastore name as it is dynamic. Any help appreciated
... View more
07-05-2023
09:07 AM
|
0
|
4
|
673
|
POST
|
You think setting up a dialog box properties for the Python script with a parameter (sys.arg[1]) defined as Layer multiple value, is read as a String? Should I read this parameter in a loop and assign the values to the List? I though it may come from the script expecting a layer name only, and not the entire layer name with path... I will try to 'hard-code' the layer name making a list with a single entry...
... View more
07-04-2023
11:19 AM
|
0
|
1
|
2953
|
POST
|
Hi Johannes, I found your python script really interesting as there is no easy solution to export symbology labels to table or field. However, I still get an error when trying to run your script. I simply changed the first line in order to drag & drop layers from the current/active projects, using: layer_names = sys.argv[1] And I get the following error: layer = aprx.activeMap.listLayers(name)[0] IndexError: list index out of range It should be obvious to fix but I do not have much experience with the arcpy mp module and I am stuck. Any help would be appreciated. Thanks layer_names = sys.argv[1]
aprx = arcpy.mp.ArcGISProject("current")
for name in layer_names:
# get the layer
layer = aprx.activeMap.listLayers(name)[0]
# get the symbology fields and items
renderer = layer.symbology.renderer
fields = renderer.fields
items = renderer.groups[0].items
# create a dict {values: label}
item_dict = {tuple(i.values[0]): i.label for i in items}
# add a new field
arcpy.management.AddField(layer, "Unit", "TEXT")
# insert the label values
with arcpy.da.UpdateCursor(layer, ["Unit"] + fields) as cursor:
for row in cursor:
key = tuple([str(x) for x in row[1:]]) # item.values stores values as string
try:
row[0] = item_dict[key]
cursor.updateRow(row)
except KeyError: # no symbology found
pass
... View more
07-04-2023
08:50 AM
|
0
|
3
|
2960
|
POST
|
Are you looking at .dbf in particular? .dbf are old-fashioned and have perhaps some limitations... Using the Export Table Geoprocessing tool, you can explicitly specify the output file format with an extension. I would recommend trying simple .txt or .csv outputs and look if you problem is still here. https://pro.arcgis.com/en/pro-app/latest/tool-reference/conversion/export-table.htm
... View more
06-07-2023
07:12 AM
|
0
|
1
|
1292
|
POST
|
Hi, I have a recurrent error when trying to open portals items in ArcGIS Pro, the .pitemx files. It is a 'failed to open' error as attached. On same portals, ArcGIS Desktop .pitem files do open correctly. Initially, I suspected the .pitemx files to be corrupted but the same files do open from other networks. Now, my guess is something related to firewall! What are the specific ports ArcGIS Pro using to connect to portal to open .pitemx files? Thanks
... View more
06-07-2023
06:56 AM
|
0
|
5
|
914
|
POST
|
Fantastic! Good to know array values has to be casted to text for 'if' statments... Very useful.
... View more
05-17-2023
08:37 AM
|
0
|
1
|
517
|
POST
|
Hi, In an Arcade statment, I am losing patience on silly syntax in an 'if' statment, with condition to compare the first 3 digits of postal code with a variable stored in an array, as below: if (Left(city.postal_code,3) == myArray[f]) { The 'if' statment is simply ignored! But if I hard-code a value, that's works fine: if (Left(city.postal_code,3) == '332') { Any guess where the problem is?
... View more
05-16-2023
04:26 AM
|
0
|
4
|
589
|
POST
|
Instead of fiddling with cumbersome IIf arcade statment, I just ticked 'show values out of range' and it works. All features are displayed on the map, whether or not having 'null' values.
... View more
04-01-2023
03:30 AM
|
0
|
0
|
625
|
POST
|
Classes are set to 1 because only 1 value '0' is computed (or bugged). I cannot change classes to anything else because only '0' exists. Feature having 'null' values do display correctly on the map with the '0' graduated color... I just discovered that the Arcade IIf statement works correctly with 'Single Symbol' symbology. It looks like IIf custom statment in Symbology using Graduated Colors is not supported in ArcGIS Pro!
... View more
04-01-2023
03:26 AM
|
0
|
0
|
625
|
POST
|
Interestingly, if I reverse the logic, if the 'sector' attribute is 'null', keep the existing value, otherwise output 99. I get the same 0 value for the graduated symbology! IIf (IsEmpty($feature.Sector), $feature.Sector, 99);
... View more
04-01-2023
03:14 AM
|
0
|
0
|
633
|
POST
|
Hi, For symbology, I made a simple IIf statment in order to display 'null' values (empty) as 0 in a graduated color scheme. The Arcade if statment is fairly simple. If the 'sector' attribute is 'null', output 0 otherwise keep the existing value. IIf(IsEmpty($feature.Sector), 0, $feature.Sector); When the symbology is applied, only 'null' values are displayed as '0' in my graduated colors, but all existing values are ignored and do not display... just like if the 'else' is ignored. Is there anything wrong?
... View more
04-01-2023
02:53 AM
|
0
|
4
|
641
|
POST
|
Hi, Really nice, it works and I like the 'inverted' logic to avoid the else statment. Moreover, I have a similar Arcade code and it never go to the else statment! if($feature.Date != '2019'){
var census = ($feature.census);
var startDate = 2019;
var features = Filter($featureSet, "date = " + startDate + " AND census = " + census);
var featureFirst = First(features);
if(features != null){
var growth = (($feature.Totals_by_Tract_by_Sector/featureFirst.Totals_by_Tract_by_Sector)-1)*100;
}
return growth;
} else {
return '99';
} Strange
... View more
02-22-2023
01:02 AM
|
0
|
1
|
1485
|
POST
|
Thanks. I already tried the proper 'SQL' like AND, but still no luck! I included your 'null' logic to safeguard my Arcade code if($feature.Date != '2019'){
var census = Text($feature.census);
var startDate = '2019';
var features = Filter($featureSet, "date = @startDate AND census = @census");
var featureFirst = First(features);
if(dic == null){
return '0'} else {
var growth = (($feature.Totals_by_Tract_by_Sector/featureFirst.Totals_by_Tract_by_Sector)-1)*100;
}
} else {
return '0'
}
... View more
02-21-2023
09:02 AM
|
0
|
4
|
1544
|
Title | Kudos | Posted |
---|---|---|
1 | 12-15-2022 03:32 AM | |
1 | 05-24-2018 02:11 AM | |
1 | 12-12-2023 08:54 AM | |
1 | 11-22-2023 08:59 AM | |
1 | 10-03-2023 06:03 AM |
Online Status |
Offline
|
Date Last Visited |
10-08-2024
02:12 PM
|