|
POST
|
The variable substitution sqlExpression in line 39 is not correct. You'd have to do something like this var globalId = p.globalid
var related = Filter(comments, "projectguid = @globalId");
... View more
a week ago
|
1
|
1
|
98
|
|
POST
|
You can add an Arcade Element to your popup with this code. It loops through each field in the feature and returns only the fields that contain a value. This also includes a variable (exceptedFields) that contains fields you don't want to show in the field list. Note that those field names are case sensitive. Expects($feature, "*");
var fields = Schema($feature).fields;
var attributes = {};
var fieldInfos = [];
var exceptedFields = ["OBJECTID", "GlobalID"]; //case sensitive!
for (var f of fields) {
if (!Includes(exceptedFields, f.name)) {
if (Trim($feature[f.name]) != "") {
attributes[f.alias] = $feature[f.name];
Push(fieldInfos, { fieldName: f.alias });
}
}
}
return { type: "fields", fieldInfos: fieldInfos, attributes: attributes };
... View more
a week ago
|
2
|
1
|
138
|
|
POST
|
You can use the GroupBy function to calculate this var fs = FeatureSetByPortalItem(
Portal("https://www.arcgis.com"),
"yourID",
0,
['County','Year', 'curr_enr','prev_enr'],
false
)
GroupBy(fs, ['County','Year','curr_enr','prev_enr'], {name: 'Change', expression: '(curr_enr - prev_enr)/prev_enr', statistic: 'Max'})
... View more
a week ago
|
1
|
1
|
131
|
|
POST
|
Also note that you can make the When statement more concise var tod = When(hour >= 0 && hour <= 5, "Night",
hour <= 8, "Morning",
hour <= 15, "Day",
hour <= 23, "Evening",
Null
);
... View more
a week ago
|
1
|
1
|
151
|
|
POST
|
Are you viewing this in Firefox? There have been reports of some issues with Firefox v145.0 That said, I'm seeing the Preview button on my machine using ExB DE 1.18 in both Firefox and Chrome.
... View more
2 weeks ago
|
0
|
2
|
246
|
|
POST
|
You can write a function that returns the color for the attribute passed in as a parameter. function bgColor(attribute) {
when (attribute <= 70, "red",
attribute <= 80, "orange",
attribute <= 90, "yellow",
attribute <= 95, "green",
"blue")
}
//in use
var theColor = bgColor($feature.attribute)
... View more
2 weeks ago
|
1
|
0
|
110
|
|
POST
|
It seems like there are some incompatibilities with the latest version of Firefox and Esri's products https://community.esri.com/t5/community-feedback/map-viewer-issues-when-using-firefox-version-145-0/m-p/1665688#M6016 https://community.esri.com/t5/arcgis-enterprise-portal-questions/issue-with-layer-widget-display-in-experience/m-p/1665001
... View more
2 weeks ago
|
0
|
1
|
299
|
|
POST
|
OK, this should give you what you're trying to do, but I haven't tested it. It loops through each tract, gets the intersecting lakes for that tract, then gets the intersecting area for each lake. Then it gets the total lake count. Note that the area is rounded to two decimal places. It will take a while to process. You could test whether "Memorizing" the tracts and lakes layers makes it any faster. var port = Portal("https://www.arcgis.com");
// Load layers
var tracts = FeatureSetByPortalItem(port, "b9fcbedac0384e32bc3dba6aec1a8cf6", 0);
var lakes = FeatureSetByPortalItem(port, "5564b2e702364aefba08df8c95216a1f", 0, ["OrgKeyID"]);
var lakesfilt = Filter(lakes, "OrgKeyID > 0");
var totalAcres = 0;
var arrTracts = [];
for (var tract in tracts) {
var intersectingLakes = Intersects(lakesfilt, tract);
Push(arrTracts, tract);
for (var intersectingLake in intersectingLakes) {
var lakePart = Intersection(tract, intersectingLake);
totalAcres += Area(lakePart, "acres");
}
}
var lakeCount = Count(Intersects(lakesfilt, Union(arrTracts)))
return FeatureSet(
{
fields: [
{ name: "LakeCount", type: "esriFieldTypeInteger" },
{ name: "Acres", type: "esriFieldTypeDouble" }
],
features: [
{ attributes: { LakeCount: lakeCount, Acres: Round(totalAcres, 2) } }
]
}
);
... View more
2 weeks ago
|
1
|
1
|
239
|
|
POST
|
I guess I'm not clear on the number you're expecting to get for the total area. Do you want to sum up the area of the portion of each lake that intersect the each tract? If so, then you'll have to loop through each tract and each lake to get the Intersection geometry and add its area to the total. However, the total count of the lakes will likely be incorrect, since a lake intersecting several tracts will be counted for each tract.
... View more
2 weeks ago
|
0
|
3
|
244
|
|
POST
|
You have the order of the DateDiff parameters reversed if the ExpDate is in the future. For those dates, your expression returns a negative number. Here's an easier way to write your expression, using the When function. This assumes that the ExpDate field is a date field. if (IsEmpty($feature.Expdate) return "Expiry Date Unavailable"
var diff = DateDiff($feature.Expdate, Now(), "days");
When(diff <= 0, "Expired",
diff <= 30, "Expires within 30 days",
diff < 100, "Expires between 30 to 100 days",
"Expires in more than 100 days"
);
... View more
2 weeks ago
|
1
|
0
|
136
|
|
POST
|
I've tested the code using some of my own data and it returned the expected data. I did make a change to line 17 to use the field type "esriFieldTypeInteger" since Count returns an integer, but keeping it as it is also works. The next step would be to put some debugging Console messages in the code at various places (like before and after line 11) and click the Run button in the editor window. This will give you a better idea where the code is crashing.
... View more
2 weeks ago
|
0
|
0
|
261
|
|
POST
|
Doing lots of intersects is a resource hog, since the code has to make external calls for each feature in the loop. @jcarlson wrote a good post about how to store the features in memory (using his Memorize function) to speed up this process. This would be good if you wanted to create a table showing how many lakes are in each tract. However, since you're looking to just get the sum off all the lakes in all the tracts, you can loop through the tracts FeatureSet to union them into a single feature, then use that feature in your Intersects function. You can get the count of that FeatureSet to see how many lakes there are and use the Area function to get the total area of all the lakes. var port = Portal("https://www.arcgis.com");
// Load layers with correct area field name
var tracts = FeatureSetByPortalItem(port, "b9fcbedac0384e32bc3dba6aec1a8cf6", 0, ["OBJECTID"], true);
var lakes = FeatureSetByPortalItem(port, "5564b2e702364aefba08df8c95216a1f", 0, ["OBJECTID"], true);
var arrTracts = [];
for (var tract in tracts) {
Push(arrTracts, tract);
}
var lakesFS = Intersects(lakes, Union(arrTracts));
return FeatureSet(
{
fields: [
{ name: "LakeCount", type: "esriFieldTypeSingle" },
{ name: "Acres", type: "esriFieldTypeDouble" }
],
features: [
{
attributes:
{
LakeCount: Count(lakesFS),
Acres: Area(lakesFS, "acres")
}
}
]
}
);
... View more
2 weeks ago
|
0
|
2
|
334
|
|
POST
|
You should start a new discussion when asking a question like this. Also, when posting code, use the "Insert/Edit code sample" button. It makes it easier to read and refer to specific lines. There are several problems in this line. var countLakes = Count(Filter(lakes, Intersects(Geometry(lakes), tractGeom))); You don't need to filter the results of the Intersects function and even if you did need it, you weren't providing the required sqlExpression. The Geometry function takes a feature as an input instead of a FeatureSet. And in the previous line, you don't need to cast t as a Geometry. Try this instead var countLakes = Count(Intersects(lakes, t));
... View more
2 weeks ago
|
1
|
0
|
104
|
|
POST
|
You can use the SQL CASE statement in the first GroupBy to bin the ages. This will also calculate the age group for the current year instead of 2025. The second GroupBy will count the number of each of the age groups var fs = FeatureSetByPortalItem(
Portal('https://www.arcgis.com/'),
'123456', 0,
['year_of_birth_please_write_full'],
false
);
var sql =
`Case
When year_of_birth_please_write_full > ${Year(Now()) - 18} Then '<18'
When year_of_birth_please_write_full > ${Year(Now()) - 30} Then '18-30'
When year_of_birth_please_write_full > ${Year(Now()) - 40} Then '31-40'
When year_of_birth_please_write_full > ${Year(Now()) - 50} Then '41-50'
When year_of_birth_please_write_full > ${Year(Now()) - 60} Then '51-60'
else '>60'
end`
;
var grouped = GroupBy(
fs,
'OBJECTID', // unique ID field
{ name: 'Age_years', expression: sql, statistic: 'MAX' }
);
GroupBy(
grouped,
"Age_years",
{ name: "Age_Groups", expression: "1", statistic: "COUNT" }
);
... View more
3 weeks ago
|
0
|
1
|
196
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | a week ago | |
| 2 | a week ago | |
| 1 | a week ago | |
| 1 | a week ago | |
| 1 | 2 weeks ago |
| Online Status |
Offline
|
| Date Last Visited |
a week ago
|