|
POST
|
Can you post this as code instead of an image? It's easier to do checking when we can copy the code to the Playground
... View more
02-14-2025
06:56 AM
|
0
|
3
|
1869
|
|
POST
|
Use the When function instead of the ternary operator var borough = $feature['BoroughCode'];
When(borough == "M", 'Manhattan',
borough == "X", 'Bronx',
borough == "B", 'Brooklyn',
borough == "Q", 'Queens',
borough == "S", 'Staten Island',
'n/a')
... View more
02-13-2025
05:50 AM
|
2
|
0
|
613
|
|
POST
|
That line should be Push(address_list, addr.Address_Full)
... View more
02-12-2025
12:28 PM
|
1
|
1
|
2223
|
|
POST
|
It's giving you only the beginning vertex since you have a return function when you get an intersecting contour. You want to save that value and use it later. This shows two different outputs to select from, only the slope or the start elevation, the end elevation, and the slope. It also included breaks so you don't have to loop through all the contours. //Start vertex (upper elevation) of line used for slope
var paths = Geometry($feature).paths;
var line = paths[0][0];
var begin = 0;
var end = 0;
//Selecting the elevation of the contour that is intersected by the start vertex
var x = featuresetbyname($datastore, "Homer_2ft_contour_Lidar_Gen");
for (var f in x) {
if (intersects(line, f)) {
begin = f.Contour;
break;
}
}
//End vertex of line used for slope
var p = paths[0][1];
//End vertex (lower elevation) of line used for slope
var y = featuresetbyname($datastore, "Homer_2ft_contour_Lidar_Gen");
for (var g in y) {
if (intersects(p, g)) {
end = g.Contour;
break;
}
}
//Equation to return slope of line
return (begin - end) / $feature.Shape_Length * 100;
//or if you want all values, you can use this return
return `Start elevation: ${begin}
End elevation: ${end}
Slope: ${(begin - end) / $feature.Shape_Length * 100}`;
... View more
02-11-2025
08:35 AM
|
1
|
2
|
1325
|
|
POST
|
You can use Arcade to conditionally show text. Read through that blog and other articles (their links are at the bottom) about how to use it
... View more
02-11-2025
08:03 AM
|
1
|
1
|
1245
|
|
POST
|
A Data Expression must always return a FeatureSet, not a text string. // Cargar las capas desde el datastore
var intervenciones = FeatureSetByPortalItem(
Portal("https://gadmilagro-cpuot.maps.arcgis.com"),
"dc16b23068eb4c58bd6624cf1d3a4c3c",
0,
["Costo_Total"]
);
var ejes_viales = FeatureSetByPortalItem(
Portal("https://gadmilagro-cpuot.maps.arcgis.com"),
"6031351b836f461e823f8571e60cf840",
0,
["Costo_Visible"]
);
var output = 0;
// Validar si ambas capas están vacías
if (IsEmpty(intervenciones) && IsEmpty(ejes_viales)) {
Console("Ambas capas están vacías.");
//return 0;
} else {
// Calcular la suma de los valores en cada capa
var suma_intervenciones = 0;
var suma_ejes = 0;
if (!IsEmpty(intervenciones)) {
var costo_total_values = Filter(intervenciones, "Costo_Total IS NOT NULL");
suma_intervenciones = DefaultValue(
Sum(costo_total_values, "Costo_Total"),
0
);
Console("Suma de intervenciones: " + suma_intervenciones);
}
if (!IsEmpty(ejes_viales)) {
var costo_visible_values = Filter(ejes_viales, "Costo_Visible IS NOT NULL");
suma_ejes = DefaultValue(Sum(costo_visible_values, "Costo_Visible"), 0);
Console("Suma de ejes viales: " + suma_ejes);
output = suma_intervenciones + suma_ejes;
}
}
var theDict = {
fields: [{ name: "Suma", type: "esriFieldTypeDouble" }],
geometryType: "",
features: [{ attributes: { Suma: output } }]
};
return FeatureSet(theDict);
... View more
02-08-2025
01:12 PM
|
1
|
0
|
941
|
|
POST
|
No, you don't need to. The GroupBy function creates the new FeatureSet that you can use in your serial chart. In the code above, I added as the output both the original field and the calculated field with the 30% added, but just to compare the field. You could just include the calculated field without the original field.
... View more
02-07-2025
12:07 PM
|
0
|
1
|
1536
|
|
POST
|
You can use the GroupBy function to add 30% to a field. Here's an example from the Playground // Fetches features from a public portal item
var fs = FeatureSetByPortalItem(
Portal("https://www.arcgis.com"),
// portal item id
"6200db0b80de4341ae8ee2b62d606e67",
0, // layer id
["*"], // fields to include
true // include or exclude geometry
);
GroupBy(fs, 'BUILDINGID', [{ name: 'Base Elevation', expression: 'BASEELEV', statistic: 'MAX' },
{ name: 'New Base Elevation', expression: 'BASEELEV * 1.3', statistic: 'MAX' }])
... View more
02-07-2025
11:37 AM
|
1
|
1
|
1543
|
|
POST
|
Here's a script that splits lines at a set character length (maxLength) var maxlength = 15;
var myArray = split($feature["YourFieldNameHere"], " ");
var string;
var lineArray = [];
var lineLength = 0;
for (var k in myArray) {
if (count(myArray[k]) <= maxlength) {
if (lineLength <= maxlength) {
Push(lineArray, trim(myArray[k]))
lineLength += count(trim(myArray[k]) + (count(lineArray) - 1))
if (lineLength > maxlength) {
string += Concatenate(lineArray, " ") + TextFormatting.NewLine;
lineArray = [];
lineLength = 0;
}
}
} else {
if (lineLength > 0) {
string += Concatenate(lineArray, " ") +
TextFormatting.NewLine +
trim(myArray[k]) +
TextFormatting.NewLine;
lineLength = 0;
lineArray = []
} else {
string += trim(myArray[k]) + TextFormatting.NewLine;
}
}
}
if (lineLength > 0) string += Concatenate(lineArray, " ");
return string;
... View more
02-05-2025
07:16 AM
|
1
|
1
|
1192
|
|
POST
|
This shows the chart with your values using an Arcade element // Access related table
var portal = Portal("https://www.arcgis.com")
var relatedTable = FeatureSetByPortalItem(portal,
"558cb226d1cd403c9e9bfc5dacd8ea67", 1, ['station_id', 'record_date', 'E__coli'])
var station_id = Text($feature.station_id)
var relatedData = Filter(relatedTable, "station_id = @station_id")
// If no related records exist, return null
if (Count(relatedData) == 0) {
return null
}
// Sort records by date (ascending)
var sortedData = OrderBy(relatedData, 'record_date ASC')
// Prepare lists for charting
var dates = []
var ecoliValues = {}
//var chartColors = [] //use this to have a monocolor chart
for (var f in sortedData) {
// Convert date and E. coli values to the correct format
var formattedDate = Text(Date(f.record_date), 'MM/DD/YYYY')
var ecoliValue = Number(f.E__coli)
if (!IsEmpty(formattedDate) && !IsEmpty(ecoliValue)) {
Push(dates, formattedDate)
//Push(ecoliValues, ecoliValue)
ecoliValues[formattedDate] = ecoliValue
// Push(chartColors, [6,47,120])
}
}
return {
type: 'media',
title : 'Events per Decade',
description : 'Chart showing total events per decade',
attributes : ecoliValues,
mediaInfos: [{
type : 'columnchart', //linechart | barchart | piechart | columnchart
altText : 'bar chart showing events per decade', //altText will be read by screen readers
value : {
fields: dates,
// colors: chartColors
}
}]
}
... View more
02-04-2025
06:39 AM
|
1
|
0
|
922
|
|
POST
|
Unlike the Dashboard example you have in your initial question, the map doesn't get the color information from the Arcade expression for the symbology. It just gets the unique categories. For example, I have a map where I use an expression to classify the points based on the type of survey it is and whether it's been completed. if ($feature.TYPE == "PRIMARY") {
if ($feature.SURVEY == "FISH & BENTHIC") {
if ($feature.BenthicStatus == 0 && $feature.FishStatus == 0) {
return "Fish and Benthics";
}
} else if ($feature.SURVEY == "FISH ONLY") {
if ($feature.FishStatus == 0) {
return "Fish Only";
}
}
} else if ($feature.TYPE == "SECONDARY") {
return "Secondary Site";
} Then I go into the "Pick a style" section of the Styles dialog to select the symbol shape, color, outline, etc for each category. Note that if the attributes of the feature change, its symbololgy will be automatically updated according to your expression.
... View more
02-03-2025
09:58 AM
|
2
|
1
|
4901
|
|
POST
|
You use Arcade to set the outputs ("Active", "Inactive", "Failed", etc), but then you have to set the colors in the Styles dialog.
... View more
02-03-2025
08:54 AM
|
2
|
3
|
4919
|
|
POST
|
Yes, you'll need the Filter function to get the proper record. Use the proper field names for the common fields linking the table to the FeatureSet in lines 1 and 3. var asset = $feature.thecommonfield
var LotData= FeatureSetByName($datastore,"ParkingLots", ['*'], false)
var record = First(Filter(LotData, "thecommonfield = @asset)
if (IsEmpty(record)) return "No Record Found"
return record['lot_name']
... View more
02-03-2025
06:28 AM
|
0
|
1
|
1793
|
|
POST
|
Put those console lines between lines 4 and 5 so you can see how they're being evaluated for the if statement. Also, initialize "results" as a dictionary, not a null (line 2). var pattern = "com"; // Substring to match field names starting with "com"
var result = {};
Expects($feature, "*");
for (var field in $feature) {
console(Left(field, Count(pattern)), pattern, Left(field, Count(pattern)) == pattern, $feature[field])
if (Left(field, Count(pattern)) == pattern && !IsEmpty($feature[field])) {
result[field] = $feature[field];
}
}
Console(result);
return Text(result); This is an example of how I tested it in the Playground
... View more
01-29-2025
02:31 PM
|
0
|
1
|
2184
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 02-04-2025 06:39 AM | |
| 1 | 05-01-2026 08:26 AM | |
| 1 | 04-10-2026 12:01 PM | |
| 1 | 04-13-2026 09:11 AM | |
| 1 | 10-11-2023 06:18 AM |
| Online Status |
Offline
|
| Date Last Visited |
3 weeks ago
|