|
POST
|
Hi Shahriar Rahman , If your data resides in an enterprise geodatabase, your best option is using a Calculation Attribute Rule. This could do this automatically on creating. Calculation attribute rules—ArcGIS Pro | Documentation Attribute Rules
... View more
10-19-2020
01:50 PM
|
1
|
0
|
5444
|
|
POST
|
Hi C McDonald , I see from your expression that the field is called "STOP_SHELT". This might require some small adjustments in the expression like shown below. A field that contains an underscore sometimes causes some problems when retrieving the information like $feature.Field_Name and it is better to use $feature["Field_Name"] . // using "STOP_SHELT" as name of the field in the code below
// get the bus layer with only the field that contains the facility type
var bus_fs = FeatureSetByName($map, "Bus Facilities", ["STOP_SHELT"], False);
// Intersect the bus featureset with the current data zone ($feature)
var bus_facilities = Intersects(bus_fs, $feature);
// count al bus facilities
var cnt = Count(bus_facilities);
// validate if there are bus facilities
var result = "";
if (cnt > 0) {
// there are bus facilities found
// apply groupby to create a count per facility type
var stats = GroupBy(bus_facilities, "STOP_SHELT", [{name: "FacilityCount", expression: "STOP_SHELT", statistic: "COUNT" }]);
// loop through the statistics to create the result
result = cnt + " bus facilities found:";
for (var stat in stats) {
result += TextFormatting.NewLine + " - " + stat["STOP_SHELT"] + " (" + stat["FacilityCount"] + ")";
}
} else {
// there are NO bus facilities found
result = "No bus facilities found";
}
return result; Your code will not do a count per bus facility type but will just return the count of the bus stop. If that is what you want, don't use the expression above, but in a previous post you mentioned that you wanted to get a count per facility type and that is why I provided this expression. You you want to get the count per facility type and run into problems, it would be a possibility to create a group, share the web map and data with that group and invite me to that group using my ArcGIS Online username: "xbakker.spx".
... View more
10-19-2020
01:21 PM
|
2
|
1
|
10751
|
|
POST
|
Hi amohammadalimaddi_NYCDOT , Have a look at the expression below. You returned the dictionary, but you need to retrieve the color group from the dictionary based on an attribute of the feature: // create the dictionary
var dct = {'Bollard': 'Red','Residential Mailbox': 'Red',
'USPS Mailbox': 'Red','Sidewalk Shed': 'Red',
'Sign': 'Red','Transit Elevated Structure': 'Red',
'Building Vault':'Blue','Catch Basin':'Blue',
'Survey Monuments':'Blue','Utility Access':'Blue',
'Transit Subway Vent':'Blue',
'Pedestrian Walkway':'Purple','Steps':'Purple',
'Trees':'Purple','Wall':'Purple',
'Fence':'Purple','Landscape':'Purple','Other':'Purple',
'No obstacle in travel path':'Green'};
// read out the value of the feature from the attribute
var yourvalue = $feature["NameOfTheField"];
// have a result when the value is not in the dictionary or is null
var colorgroup = "Unknown";
// check if the value is in the dictionary
if (HasKey(dct, yourvalue)) {
// the atribute is in the dictionary
colorgroup = dct[yourvalue];
}
// return the resulting color group (not he dictionary)
return colorgroup;
... View more
10-19-2020
01:03 PM
|
2
|
0
|
1747
|
|
POST
|
Hi Jeff Ward , If you look at the profile information (Profiles | ArcGIS for Developers ) for Attribute Rule Calculations you will see that you can only use the $datastore to access the data. I thought that maybe the FeatureSetByPortalItem could be a valid alternative, but it can only be used with Field Calculations and in the Popup. So, unfortunately it is not possible to do this with Attribute Rules. Attribute Rules live in the database and I guess that this is the reason for not allowing information that is not in the same $datastore to be used in the Attribute Rule. Attribute Rules
... View more
10-16-2020
10:49 AM
|
3
|
1
|
9820
|
|
POST
|
Hi C McDonald , That is indeed something you could do, using the GroupBy function. Have a look at the expression below: Please note that I am using a name "FacilityType" for the field that contains the facility type, this should be replaced by the actual name of the field. (changes are required on lines 4, 17 and 22) The script starts the same, accessing the bus facilities on line 4 and reducing the number of field o only the facility type field. On line 7 the facilities are intersected with the data zone ($feature) and on line 10 a count is done of the facilities On line 14 the this count is used to define how to proceed. If there are no bus facilities, it will not do the GroupBy and simply return a message "No bus facilities found" (see line 26 When you have bus facilities, the groupby is performed on line 17 with the COUNT statistics type grouping the facility types On line 20 the first line of the result is generated which will show the total number of bus facilities found in the data zone The loop on lines 21 to 23 will add a line for each facility type, showing the facility type description and the count the result is returned on line 29 // replace "FacilityType" with the real name of the field!
// get the bus layer with only the field that contains the facility type
var bus_fs = FeatureSetByName($map, "Bus Facilities", ["FacilityType"], False);
// Intersect the bus featureset with the current data zone ($feature)
var bus_facilities = Intersects(bus_fs, $feature);
// count al bus facilities
var cnt = Count(bus_facilities);
// validate if there are bus facilities
var result = "";
if (cnt > 0) {
// there are bus facilities found
// apply groupby to create a count per facility type
var stats = GroupBy(bus_facilities, "FacilityType", [{name: "FacilityCount", expression: "FacilityType", statistic: "COUNT" }]);
// loop through the statistics to create the result
result = cnt + " bus facilities found:";
for (var stat in stats) {
result += TextFormatting.NewLine + " - " + stat.FacilityType + " (" + stat.FacilityCount + ")";
}
} else {
// there are NO bus facilities found
result = "No bus facilities found";
}
return result; Not sure if this will work for you, since I don't have the data to test the expression against.
... View more
10-15-2020
07:45 AM
|
2
|
3
|
10751
|
|
POST
|
Hi C McDonald , Let me try to provide some explanation on what you have created: The first line assigns to variable "bus" the featureset (layer) that is accessed using the FeatureSetByName function. This function in your case will find a layer called "Bus Facilities" in your map ($map). In addition you optimize the expression by limiting the fields and not requesting the geometry. The second line, has two nested functions. The Intersects will intersect the bus facilities featureset stored in variable "bus" obtained on line 1 and intersect it with the current feature (the data zone the user clicked on). This will return all the bus facilities in the current polygon. The Count function will then count the number of bus facilities found in the data zone. Line 3 returns the number of bus facilities in the data zone determined on line 2. Later on you might want to extend the expression and list some details of each bus facility found. This is also possible with Arcade.
... View more
10-15-2020
06:22 AM
|
2
|
5
|
10751
|
|
POST
|
MKennedy-esristaff any thoughts and/or recommendations?
... View more
10-14-2020
07:05 AM
|
0
|
0
|
3750
|
|
POST
|
Hi Stuart Moore , I also had a look yesterday and played with the expression below and 3 points of interest: function WGS84toOSGB36(Xa, Ya, Za) {
// source: https://digimap.edina.ac.uk/webhelp/digimapgis/projections_and_transformations/converting_between_osgb36_and_wgs84.htm
// source: https://en.wikipedia.org/wiki/Helmert_transformation
// source: https://www.ordnancesurvey.co.uk/documents/resources/guide-coordinate-systems-great-britain.pdf
// parameters (from WGS84 to OSGB36):
var cx = -446.448;
var cy = 125.157;
var cz = -542.06;
var s = 20.4894 * Pow(10, -6); // (ppm)
var rx = -0.1502 * 4.84813681 * Pow(10, -6); // (arcsecond to radian)
var ry = -0.247 * 4.84813681 * Pow(10, -6); //(arcsecond to radian)
var rz = -0.8421 * 4.84813681 * Pow(10, -6); // (arcsecond to radian)
// Xb = cx + (1 + s * 10-6) * (Xa - rz * Ya + ry * Za)
// Yb = cy + (1 + s * 10-6) * (rz * Xa + Ya - rx * Za)
// Zb = cz + (1 + s * 10-6) * (-ry * Xa + rx * Ya + Za)
var Xb = cx + (1 + s) * (Xa - rz * Ya + ry * Za);
var Yb = cy + (1 + s) * (rz * Xa + Ya - rx * Za);
var Zb = cz + (1 + s) * (-ry * Xa + rx * Ya + Za);
return [Xb, Yb, Zb];
}
// example coords WGS84 in and OSGB36 A20H1 out
var coords = {"Edinburgh Castle": [-3.2004710, 55.9485273, -179913.35, 844672.45],
"Cardiff Castle": [-3.1820435, 51.4814364, -187026.17, 347567.19],
"Big Ben London": [-0.1245993, 51.5006821, 25274.73, 350718.17]};
for (var place in coords) {
Console("");
Console(place);
var crd = coords[place];
var Xa = crd[0];
var Ya = crd[1];
var Za = 0;
Console("Xa:" + Xa);
Console("Ya:" + Ya);
var osgb = WGS84toOSGB36(Xa, Ya, Za);
Console(osgb);
var Xb = osgb[0];
var Yb = osgb[1];
var Zb = osgb[2];
Console("Calculated Xb:" + Xb);
Console("Calculated Yb:" + Yb);
var realXb = crd[2];
var realYb = crd[3];
Console("Real Xb:" + realXb);
Console("Real Yb:" + realYb);
var deltaX = realXb - Xb;
var deltaY = realYb - Yb;
Console("delta X:" + deltaX);
Console("dalta Y:" + deltaY);
var dist = Sqrt(Pow(deltaX, 2) + Pow(deltaY, 2));
Console("Error dist:" + dist);
}
return "OK"; The results are however nowhere near to what they should be so I am sure I am doing something completely wrong...
... View more
10-14-2020
07:04 AM
|
0
|
6
|
3749
|
|
POST
|
Hi jgrossman_VHB , Glad to hear that it was helpful!
... View more
10-14-2020
06:57 AM
|
0
|
0
|
8090
|
|
POST
|
Hi dummyaccount , Is the account that you are using to access the map, the same account used to create the map? If not, did you share the map? If so, is it shared with a group (is the user that tries to have access a member of that group?), with your organization or the public?
... View more
10-13-2020
02:31 PM
|
3
|
1
|
1830
|
|
POST
|
Hi Stuart Moore , According to this site: Converting between osgb36 and wgs84 you should be able to use the Helmert transformation to convert between WGS84 and OSGB36 (Helmert transformation - Wikipedia ), which should provide results within 5 meter precision.
... View more
10-13-2020
02:15 PM
|
0
|
8
|
3751
|
|
POST
|
Hi eric.gurney , Not sure if I understand your question completely, since the link you provided points to content that is not public. So the Arcade expression uses the wind force to convert it to a URL that points to an image on wikimedia. To center something in the pop-up you need to use the customize HTML pop-up options to format it any way you need. This is not part of the Arcade expression.
... View more
10-13-2020
06:58 AM
|
0
|
0
|
962
|
|
POST
|
Hi Brian Coward , I am looking at the screenshots you attached to your question but I don't see an example of you getting the street name as a result.
... View more
10-13-2020
06:47 AM
|
0
|
0
|
2080
|
|
POST
|
Hi srahman , It is possible to get the start point of a line using its json definition and intersect that point with your polygons. Have a look at the expression below: // get the geometry of the line
var line = Geometry($feature);
// the json of the first point can be accessed like this:
var json = line["paths"][0][0];
//{"spatialReference":{"latestWkid":3857,"wkid":102100},"x":-8406060.52628989,"y":674888.746493517}
// create a point from this first point json
var pnt = Point(json);
// access the polygon layer
var pols = FeatureSetByName($map,"Colombia Censo 2018 Población a Nivel de Municipio");
// intersect the polygon layer with the point and take the "first" polygon
var pol = First(Intersects(pols, pnt));
// get the name of the polygon using the field name
var startmuni = pol["MPIO_CNMBR"];
// return the result
return startmuni;
... View more
10-13-2020
06:27 AM
|
2
|
1
|
1892
|
|
POST
|
Hi ButterfieldLECP , Find below the expression that was used to get a list of organizations per venue and sum the number of participants. The "CorrectValue" function was written to translate the text field with the number of participants to a numeric value and accounts for a couple of known situations. This however, is no guarantee that in the future other exceptions will be handled correctly. Function CorrectValue(participants) {
Console(participants);
if (IsEmpty(participants)) {
Console("case IsEmpty");
return 0;
}
if (IsNan(participants)) {
Console("case IsNan");
return 0;
}
participants = Upper(participants);
Console(participants);
if (Left(participants, 3) == "N/A") {
Console("case N/A");
return 0;
}
if (Left(participants, 3) == "MIN") {
Console("case Min...");
return 250;
}
participants = Replace(participants, "+", "");
Console(participants);
participants = Replace(participants, ",", "");
Console(participants);
if (Find(" TO ", participants) > -1) {
Console("case to");
var arr = Split(participants, " ");
return (Number(arr[0]) + Number(arr[2]))/2;
}
if (Find("ANNUALLY", participants) > -1) {
Console("case annually");
var arr = Split(participants, " ");
return Number(arr[0]);
}
if (Find("-", participants) > -1) {
Console("case -");
var arr = Split(participants, "-");
return (Number(arr[0]) + Number(arr[1]))/2;
}
return Number(participants);
}
// use venue name to link to organization information
var venname = $feature["org_venue"];
// access the organization featureset
var fsorgs = FeatureSetByName($map,"Organization Info", ["org_name", "org_type", "org_address", "org_number_participants"], False);
// create a SQL query to get the related organizations
var sql = "org_venue = @venname";
// filter organizations on venue name
var orgs = Filter(fsorgs, sql);
// count organizations
var cnt = Count(orgs);
// loop through organizations and create result
var result = "";
var tot_part = 0;
if (cnt > 0) {
// there are organizations found, loop through orgs
result = cnt + " organization(s) found:"
for (var org in orgs) {
// add org information to the result
var participants = CorrectValue(org["org_number_participants"]);
tot_part += participants;
result += TextFormatting.NewLine + TextFormatting.NewLine + org["org_name"];
result += TextFormatting.NewLine + org["org_type"];
result += TextFormatting.NewLine + org["org_address"];
result += TextFormatting.NewLine + "participants: " + participants;
}
result += TextFormatting.NewLine + TextFormatting.NewLine + "Total participants: " + tot_part;
} else {
// no organizations found
result = "no organizations found...";
}
return result;
... View more
10-07-2020
02:07 PM
|
0
|
0
|
1137
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 01-09-2020 09:26 AM | |
| 6 | 12-20-2019 08:41 AM | |
| 1 | 01-21-2020 07:21 AM | |
| 2 | 01-30-2020 12:46 PM | |
| 1 | 05-30-2019 08:24 AM |
| Online Status |
Offline
|
| Date Last Visited |
a week ago
|