|
POST
|
Hi Khem Aryal , Another way would be to use a value renderer based on the severity and frequency of the events. See some sample code below (this will use some sample rating and try to create a numeric value from it based on a weight for severity multiplied by the frequency). Function Score(val) {
val = Upper(val);
var dct = {"0": 0, "1": 1, "2": 2, "3": 3, "4": 4, "5": 5,
"6": 6, "7": 7, "8": 8, "9": 9, "A": 10, "B": 15,
"C": 20, "D": 25, "E": 30, "F": 35, "G": 40, "H": 45,
"I": 50, "J": 55, "K": 60, "L": 65, "M": 70, "N": 75,
"O": 80, "P": 85, "Q": 90, "R": 95, "S": 100, "T": 105,
"U": 110, "V": 115, "W": 120, "X": 125, "Y": 130, "Z": 135};
if (HasKey(dct, val)) {
return dct[val];
} else {
return -1;
}
}
Function Severity(val) {
// should probably use different weights for severity 1 to 5
// var dct = {"0": 0, "1": 1, "2": 2, "3": 3, "4": 4, "5": 5};
var dct = {"0": 0, "1": 5, "2": 10, "3": 15, "4": 20, "5": 25};
if (HasKey(dct, val)) {
return dct[val];
} else {
return -1;
}
}
Function CalculateScore(val) {
if (Count(val) == 4) {
var sev1 = Severity(Left(val, 1));
Console("sev1: " + sev1);
var sco1 = Score(Mid(val, 1, 1));
Console("sco1: " + sco1);
var sev2 = Severity(Mid(val, 2, 1));
Console("sev2: " + sev2);
var sco2 = Score(Mid(val, 3, 1));
Console("sco2: " + sco2);
return sev1 * sco1 + sev2 * sco2;
} else {
return -1;
}
}
var rating = "5J3B";
Console("5J3B: " + CalculateScore(rating) + TextFormatting.NewLine); // 320 = 5 * 55 + 3 * 15
var rating = "3Z2Z";
Console("3Z2Z: " + CalculateScore(rating) + TextFormatting.NewLine); // 675 = 3 * 135 + 2 * 135
var rating = "5P4Z";
Console("5P4Z: " + CalculateScore(rating) + TextFormatting.NewLine); // 965 = 5 * 85 + 4 * 135
//return CalculateScore(rating);
return "OK"; This will write to the console: sev1: 25
sco1: 55
sev2: 15
sco2: 15
5J3B: 1600
sev1: 15
sco1: 135
sev2: 10
sco2: 135
3Z2Z: 3375
sev1: 25
sco1: 85
sev2: 20
sco2: 135
5P4Z: 4825
It all depends a lot on how you compare a severity 1 to 2 to 3 to 4 to 5... Also, in my example J is translated to 55, but maybe the coding does not include the character "I"? Having access to this type of data with the number of incidents per pipe, it would be nice to do some predictive analysis and include material, diameter, pressure, and other additional data.
... View more
11-09-2020
02:26 PM
|
2
|
0
|
685
|
|
POST
|
Hi [email protected]_stalbert , That is actually a simple thing to do assuming that each rating always has the same structure using 4 characters. Please try this: // read out rating code
var rating = $feature["Name of the field with the rating code"];
// compare with "3000"
if (rating >= "3000") {
return "Your description for red color";
} else {
return "Your description for blue color"
}
It compares the text in an alphabetic way (using the first character), assuming that "2Z2Z" is less than "3000".
... View more
11-09-2020
01:16 PM
|
2
|
2
|
4131
|
|
POST
|
Hi Khem Aryal , From the information you provided in the original post and screen shot you provided after this, I see two complete distinct things. Can you explain how the values ("352N", "3522", "342Z", etc) should be interpreted? I am sure something must be possible, but in order to help you further I need to understand how to interpret every possible value (and not just a subset of them).
... View more
11-09-2020
12:21 PM
|
0
|
2
|
4131
|
|
POST
|
Hi [email protected]_stalbert , See below an example of an expression that will assign a numeric sequential value: // read out rating code
var rating = $feature["Name of the field with the rating code"];
// dictionary with numeric values according to 3C>2A>1B>1A>15>00
var dct2 = {"00": 0, "15": 1, "1A": 2,
"1B": 3, "2A": 4, "3C": 5};
// check if rating is in dictionary and return the value
if (HasKey(dct2, rating)) {
return dct2[rating];
} else {
return -1;
}
You can change the values (0 to 5) in the dictionary defined on lines 5 and 6 with values representing a number in the range of the rating code if that is what you prefer. Is there are specific reason why you want the values to be numeric?
... View more
11-09-2020
10:42 AM
|
2
|
6
|
4131
|
|
POST
|
Hi KARIM LABIDI , Glad to hear that it works. Could you mark the post as the correct answer? If you need any additional explanation just let me now.
... View more
11-09-2020
09:25 AM
|
0
|
0
|
5121
|
|
POST
|
Hi KARIM LABIDI , I think this could do the trick: var township = FeatureSetByName($datastore, "GDB.SIGWRITER.FV_TRONC_L", ["NOM_VOIE"], True);
var intersectLayer = Intersects(township, $feature);
var cnt = Count(intersectLayer);
if (cnt > 0) {
var feat = First(intersectLayer);
var nomvoie = feat["NOM_VOIE"];
if (IsEmpty(nomvoie)) {
return "no NOM VOIE"; // or perhaps return null
} else {
var words = Split(nomvoie, " ");
var cnt2 = Count(words);
var lastword = words[cnt2-1];
if (cnt2 > 1) {
var otherwords = [];
for (var i = 0; i < cnt2-1; i++) {
otherwords[Count(otherwords)] = words[i];
}
return lastword + " (" + Concatenate(otherwords, " ") + ")";
} else {
return lastword;
}
}
} else {
return "No township found"; // or perhaps return null
}
I tested with this code: // RUE GEORGES BONNAC would be BONNAC (RUE GEORGES)
var nomvoie = "RUE GEORGES BONNAC";
if (IsEmpty(nomvoie)) {
return "no NOM VOIE"; // or perhaps return null
} else {
var words = Split(nomvoie, " ");
Console(words);
var cnt2 = Count(words);
var lastword = words[cnt2-1];
if (cnt2 > 1) {
var otherwords = [];
for (var i = 0; i < cnt2-1; i++) {
otherwords[Count(otherwords)] = words[i];
}
return lastword + " (" + Concatenate(otherwords, " ") + ")";
} else {
return lastword;
}
} ... which returned this: BONNAC (RUE GEORGES)
... View more
11-06-2020
09:11 AM
|
1
|
0
|
5121
|
|
POST
|
Hi kbm_admin , There are a couple of things that may be going wrong here: In you code example you don't return anything The error might be related to how you read the field value from the feature. When retrieving a value from a field that contains an underscore always use feature["Field_Name"] instead of feature.Field_Name Also it might be possible that no features where found with the intersect and when you try to take the first feature from a collection that has no feature it might fail. So always do a count to see if you have anything and continue accordingly Try this: var township = FeatureSetByName($datastore, "GDB.SIGWRITER.FV_TRONC_L", ["NOM_VOIE"], True);
var intersectLayer = Intersects(township, $feature);
var cnt = Count(intersectLayer);
if (cnt > 0) {
var feat = First(intersectLayer);
var nomvoie = feat["NOM_VOIE"];
if (IsEmpty(nomvoie)) {
return "no NOM VOIE"; // or perhaps return null
} else {
var words = Split(nomvoie, " ");
// define what to return, let's say you want to first word
return words[0];
}
} else {
return "No township found"; // or perhaps return null
}
... View more
11-06-2020
06:31 AM
|
0
|
2
|
5121
|
|
POST
|
Hi MKennedy-esristaff , I tried to include the conversion(s) in the expression (see lines 35, 36 where I read the input coordinates and lines 42 to 44 where the resulting coordinates are returned). I am pretty sure I am doing something completely wrong, since the results are very far off from what they should be. The "coords" dictionary on line 26 contains the input long and lat and output X and Y for 3 given points. You also mention an abridged Molodensky method. Would you have more info on that? 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 * PI / (180 * 3600) * Pow(10, -6); // (arcsecond to radian)
var ry = -0.2470 * PI / (180 * 3600) * Pow(10, -6); // (arcsecond to radian)
var rz = -0.8421 * PI / (180 * 3600) * 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[1] * (PI / (180 * 3600));
var Ya = crd[0] * (PI / (180 * 3600));
var Za = 0;
Console("Xa:" + Xa);
Console("Ya:" + Ya);
var osgb = WGS84toOSGB36(Xa, Ya, Za);
Console(osgb);
var Xb = osgb[0] * ((180 * 3600) / PI);
var Yb = osgb[1] * ((180 * 3600) / PI);
var Zb = osgb[2] * ((180 * 3600) / PI);
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";
... View more
11-05-2020
11:52 AM
|
0
|
1
|
3696
|
|
POST
|
Hi Melita Kennedy , Thanks for stepping in. Actually the source coordinates are expression in decimal degrees and I don't convert them in the process. Is that what is causing the huge errors that I am getting? Should I convert the input decimal degrees to radians?
... View more
11-05-2020
11:14 AM
|
0
|
3
|
3696
|
|
POST
|
Hi Kydyrov Meirambek and Emma Hatcher , Can you return HTML using Arcade in a Pop-up? Yes. Will you get something useful? No. To visualize the effect with the current and beta map viewer in ArcGIS Online: So HTML will be returned, but it will not give you the expected result in the pop-up. Returning HTML in the pop-up using Arcade is possible in ArcGIS Pro, but not in the web map. And ezhatcher , the reason the expression is not returning anything, is since you forgot to include the statement "return rList;" on the last line. However, when you work with a web map you will not get the result you are after.
... View more
11-05-2020
11:09 AM
|
0
|
0
|
8672
|
|
POST
|
Hi Paul Sweeney , Sorry for the late reply but I was attending the IMGIS conference and yesterday was a national holiday. I just changed your code slightly, but it is still not very convincing. A couple of comments: In your code do you have the layerID when you use FeatureSetByPortalItem for poles and chambers? The validation of the count is before you do the loop for both poles and chambers I am not convinced with the final When, since there are a number of cases that in theory can occur that are probably not accounted for. See lines 88 to 98 in the code below. Are those correct? // does you code include the layerID for poles?
var LayerIdPoles = 0; // what is the layerID for poles?
var polesLayer = FeatureSetByPortalItem(Portal('my portal'), 'xxxxxxxx', LayerIdPoles);
Console('polesLayer ' + polesLayer);
// does you code include the layerID for chambers?
var LayerIdChambers = 0; // what is the layerID for chambers?
var chambers = FeatureSetByPortalItem(Portal('my portal'), 'xxxxxxxx', LayerIdChambers);
Console('chambers ' + chambers);
// create buffer around feature of 0.1 meter
var buff = Buffer($feature, 0.1, 'meters');
// intersect buffer with poles
var poles = Intersects(buff, polesLayer);
var cnt = Count(poles);
Console('cnt ' + cnt);
// intersect buffer with chambers
var chambers = Intersects(buff, chambers);
var cntchambers = Count(chambers);
Console('cntchambers' + cntchambers);
var popupResult = '_'; // why is this an underscore?
// validate count before the loop
if (cnt>0) {
for (var f in poles) {
popupResult += f.barcode + " to pole ";
}
// only if you have poles, the following is relevant
var strLenght = Count(popupResult) - 8;
Console('strLenght ' + strLenght);
var note = Left(popupResult, strLenght);
Console('note ' + note)
var popup = IIf(cnt==1,
Replace(
"install subduct " + DomainName($feature, "sub_size") + " from pole " + note,
'to pole',
''),
"install subduct " + DomainName($feature, "sub_size") + " from pole " + note);
Console('popup '+popup);
} else {
popupResult = "There is no Link required here";
var popup = "";
}
Console('popupresult ' + popupResult);
var ChambResult = '_';
if (cntchambers>0) {
for (var f in chambers) {
ChambResult += f.label + " to chamber " ;
}
// only if you have chambers, the following is relevant
var strLenght2 = Count(ChambResult) - 15;
Console('strLenght2 ' + strLenght);
var note2 = Left(ChambResult,strLenght2);
Console('note2 '+note2);
var popup2 = IIf(cntchambers==1,
Replace(
"install subduct " + DomainName($feature,"sub_size")+ " from chamber " + note2,
'to chamber',
''),
"install subduct " + DomainName($feature,"sub_size") + " from chamber " + note2);
Console('popup2 ' + popup2);
} else {
ChambResult = "There is no Link required here";
var popup2 = "";
}
Console('ChambResult ' + ChambResult);
var popup3 = "install subduct " + DomainName($feature,"sub_size") +
" from the chamber " + ChambResult + " to the pole " + popupResult;
Console('popup3 ' + popup3);
var popup3 = Replace(popup3,' to pole ', "");
Console('popup3 ' + popup3);
var popup3 = Replace(popup3,' to chamber ',"");
Console('popup3 '+popup3);
var finalresult = When(cnt <= 2 && cntchambers==0, popup,
cnt == 0 && cntchambers==2, popup2,
cnt == 1 && cntchambers==1, popup3,
'n/a');
Console('finalresult ' + finalresult);
return finalresult;
// 0 poles and 0 chambers -> 'n/a'
// 1 pole and 0 chambers -> popup
// 2 poles and 0 chambers -> popup
// 3 poles and 0 chambers -> 'n/a'
// 0 poles and 1 chambers -> 'n/a'
// 0 poles and 2 chambers -> popup2
// 0 poles and 3 chambers -> 'n/a'
// 1 pole and 1 chambers -> popup3
// 1 pole and 2 chambers -> 'n/a'
// 2 poles and 1 chambers -> 'n/a'
// 2 poles and 2 chambers -> 'n/a'
It is strange that if you only have a single feature, the expression works correctly but the field calculation fails. how are you filtering the featureset? Did you create a new source? It is possible that the pop-up validator is more forgiving than the one used in the field calculation...
... View more
11-03-2020
02:44 PM
|
0
|
2
|
4953
|
|
BLOG
|
Hi Anne Santa Maria , I understand what you are looking for. Thanks for the additional explanation. However, at this moment, this is not possible. It would be great to have this option and reduce time defining the symbology. There are a couple of things I notice based on your screenshots. You are using symbols provided in the Utility Network foundation, but you are symbolizing on Asset Group when we normally symbolize on Asset Type. You also have the field compatibleunits selected. Are you trying to symbolize the features based on CU's? Are you trying to incorporate this into the design editing to store the CU's of the assets you are editing?
... View more
11-03-2020
01:31 PM
|
2
|
0
|
11123
|
|
BLOG
|
Hi Jussi Lehtonen , According to the help, Intersects requires the FeatureSet to be the first parameter, so your example should not work (if the documentation is correct). It should be: var IntersectClose = Intersects(FeatureSetById($map, /* population */ "population"), Buffer($feature, 2000, 'meters'));
var cnt = Count(IntersectClose);
return cnt; To calculate the sum of the population of the returned features in the featureset called "IntersectClose", you can use the Sum function like this (assuming that the population field is called "Population"): var IntersectClose = Intersects(FeatureSetById($map, /* population */ "population"), Buffer($feature, 2000, 'meters'));
return Sum(IntersectClose, "Population");
To optimize the part where you access the featureset, you may want to include the array with the field name and set the return geometry to false (still assuming that your field name with the population is called "Population"): var IntersectClose = Intersects(FeatureSetById($map, /* population */ "population", ["Population"], False), Buffer($feature, 2000, 'meters'));
return Sum(IntersectClose, "Population");
... View more
11-03-2020
01:21 PM
|
0
|
0
|
4741
|
|
POST
|
Hi Shahriar Rahman The original questions extracts points from polylines (contours), but you want to extract points from a polygon? This is possible, but how should these points be distributed? Extract points from the outline of the polygon, generate random points inside the polygon, generate points at a certain distance inside the polygon?
... View more
11-03-2020
01:12 PM
|
0
|
0
|
2034
|
|
POST
|
Hi jborgion , Unfortunately, that is correct. Attribute Rules live on the data side and the relational datastore of AGOL is not yet supported.
... View more
10-28-2020
12:21 PM
|
4
|
0
|
4199
|
| 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 |
Friday
|