|
POST
|
Hi Shahriar Rahman , Before jumping into code examples it might be good to understand the "why" you have to do what you are trying to do. So if you can elaborate on that, it would be great. Then the "when" and how often something should happen is also important. If directly after creating a new feature or updating an exiting feature a trigger should propagate that change into the other featureclass, this will have a large influence on the right solution. Maybe replicas would be the way to achieve this Geodatabase replication fundamentals—ArcGIS Pro | Documentation or otherwise Calculation Attribute Rules as I mentioned before: Calculation attribute rules—ArcGIS Pro | Documentation using the triggers Insert, Update and perhaps even Delete depending your requirements. Creating a script to reflect the changes into the other featureclass is an option, however, when should it run and how will it detect the changes to propagate into the other featureclass? You will want to avoid a full scan of the data and compare everything since this will become slow when the volume of data rises. Also, a script will not automatically trigger when you edit the data in one featureclass and will need to be started somehow.
... View more
10-23-2020
06:29 AM
|
1
|
0
|
5414
|
|
POST
|
Hi Shahriar Rahman , The error is indicating that you don't have a field called "Steet_ID" (a bit strange that it refers to line 5, since the error should have occurred before that line). Can you share the field names that you have in both the Street_Locations layer and the current layer where the Arcade expression is defined?
... View more
10-23-2020
06:10 AM
|
0
|
0
|
5669
|
|
POST
|
Hi Travis Anderson , The "False" parameter defines if you want to include the geometry in the result yes or no. In this case it doesn't. Here is a direct link to the documentation: https://developers.arcgis.com/arcade/function-reference/data_functions/#featuresetbyname [optional] indicates whether to include the geometry in the features. By default, this is true. For performance reasons, you should only request the geometry if necessary, such as for use in geometry functions. This can be little confusing, since after retrieving the featureset you use Intersects to get the meters in the DMA zone. Even with the include geometry option set to false you will be able to do the Intersects correctly. Only when you want to access the individual geometries and do spatial operations on them you will need to include them in the FeatureSetBy* function.
... View more
10-22-2020
12:46 PM
|
0
|
0
|
12253
|
|
POST
|
Hi Travis Anderson , You should be able to use the Sum function to do just that: // access the meters featureset, limiting the fields to Consumption
var meters = FeatureSetByName($map, "METERS", ["Consumption"], False);
// count the meters
var CountMeters = Count(Intersects(meters, $feature));
// Calculate consumption
var consumption = 0;
// check to see if there are meters in the zone
if (CountMeters > 0) {
// calculate the sum of the consumption
consumption = Sum(meters , "Consumption");
}
// return the result
Return consumption; You can also include the number of meters found in the resulting text if that is something you want: // access the meters featureset, limiting the fields to Consumption
var meters = FeatureSetByName($map, "METERS", ["Consumption"], False);
// count the meters
var CountMeters = Count(Intersects(meters, $feature));
// Calculate consumption
var consumption = 0;
var result = "";
// check to see if there are meters in the zone
if (CountMeters > 0) {
// calculate the sum of the consumption
consumption = Sum(meters , "Consumption");
result = consumption + " gallon (" + CountMeters + " meters in zone)";
} else {
result = "0 gallons (no meters in zone)";
}
// return the result
return result;
... View more
10-22-2020
11:36 AM
|
2
|
4
|
12252
|
|
POST
|
Hi Jeff Davis , For completeness I will add the answer also in this thread; It is not possible yo have access with Arcade in the label profile to related tables. You will need to add a field in the main featureset and fill it with the information of the related table(s) in order to show it as a label. The reason behind this is that wherever an Arcade expression needs to be executed for multiple features the functionality is limited (with the exceptions of the profiles field calculations and attribute rules) due to performance. Hopefully the Python code provided by Randy does not have a large impact on performance when moving around the map since it will need to executed for each label that will be shown in the map each time the map extent is changed.
... View more
10-22-2020
10:49 AM
|
0
|
3
|
6310
|
|
POST
|
Hi Jeff Davis and Randy Burton , Regarding the question "can Arcade create labels using data from related tables" I am afraid the answer is no... In the label profile Arcade has no access to related tables. You will need to add a field in the main featureset and fill it with the information of the related table(s) in order to show it as a label.
... View more
10-22-2020
09:43 AM
|
1
|
3
|
7435
|
|
POST
|
Hi sgl55 , Not sure if you did not include the complete expression, but at the end you should return the "popupString". That is the main reason you are not getting any result. // Write a script to return a value to show in the pop-up.
var portal = Portal("https://services.wygisc.org/portal");
var speciesRelate = FeatureSetByPortalItem(portal,
"6a0c8bcd1d164d99b76f162f140212f8", 0, ['Species', 'Taxa',
'Occurrence_Potential', 'BLM_Status',
'Texas_________________Status', 'Federal_Status', 'Habitat',
'Code']);
// Filter related features by using a common attribute
var HabCode = $feature.HabCode;
var codeStatement = 'Code = @HabCode';
//Related features as a variable
var relateData = Filter(speciesRelate, codeStatement);
//build popupString by iterating through all related features
var popupString = '';
for (var f in relateData){
popupString += "Species: " + Text(f.Species) +
TextFormatting.NewLine +
"Taxa: " + f.Taxa + TextFormatting.NewLine +
"Occurrence Potential: " + f["Occurrence_Potential"] +
TextFormatting.NewLine + TextFormatting.NewLine;
}
return popupString; I would also recommend to access fields that contain an underscore using feature["Field_Name"] and nor as feature.Field_Name (see line 22). Avoid on lines 4 to 6 to include fields that you are not using to increment performance.
... View more
10-22-2020
08:24 AM
|
2
|
0
|
2743
|
|
POST
|
Hi caleb melies , The screenshot is from the error when using the REST API as far a I understand. The json for the feature seems to be ok (at least I don't see what could be wrong with it). Can you capture an edit done in the web map over the same feature with the same attribute rule? My suggestion would be to compare those and see if the request is somehow formatted differently. I will also tag the Attribute Rules place. CC Attribute Rules
... View more
10-21-2020
03:27 PM
|
0
|
7
|
4600
|
|
POST
|
Hi srahman , Maybe you can try this: var StreetID = $feature["Street_ID"];
var Location = FeatureSetByName($datastore, "Street_Locations");
var sql = "STREET_ID = @StreetID AND (LOCATION_GROUP = 'RESERVE' OR LOCATION_GROUP = 'PARK')";
var related_ids = Filter(Location, sql);
var cnt_street = Count(related_ids);
var StreetName = "";
if (cnt_street == 1) {
// only 1 result, take street name from first
StreetName = First(related_ids)["STREET_NAME"];
} else {
// no result or multiple resuls, return empty string
StreetName = "";
}
Return StreetName;
... View more
10-21-2020
06:52 AM
|
1
|
2
|
5669
|
|
POST
|
Hi caleb melies , I would expect that when editing a service in Pro or in a Portal web map, you will still be using REST to make the edits. Can you share a screenshot or text of how you have structured your applyEdits? How you monitored the network traffic when editing a web map to see how the REST call is structured? No sure if there might be any restrictions on update a Shape field...
... View more
10-21-2020
06:08 AM
|
0
|
9
|
4600
|
|
POST
|
Hi Matt Tarkington , Have a look at the expression below, and see if this gets any close to what you are looking for: var Gun = $feature.Gun;
var Mount = $feature.Mount;
var result = "";
if (Gun != "nogun") {
result = Gun + " (" + Mount + ")";
} else {
result = "Remove Post";
}
return result; Some test results: var Gun = "7 Step";
var Mount = "Has Post"; Will result in: 7 Step (Has Post) var Gun = "Millennium";
var Mount = "Needs Post"; Will result in: Millennium (Needs Post) var Gun = "nogun";
var Mount = "Mount"; Will result in: Remove Post
... View more
10-20-2020
02:53 PM
|
0
|
0
|
1534
|
|
POST
|
Hi Stantosa , What happens if you parse the actual field values to be included in the url inside the Arcade expression, like this: function MetersToLatLon(x, y) {
// Converts XY point from Spherical Mercator EPSG:3857(Web Mercator Auxiliary Sphere) to lat/lon in WGS84 Datum (EPSG:4326).
// Source: http://www.maptiler.org/google-maps-coordinates-tile-bounds-projection/
var originShift = 2.0 * PI * 6378137.0 / 2.0;
var lon = (x / originShift) * 180.0;
var lat = (y / originShift) * 180.0;
lat = 180.0 / PI * (2.0 * Atan( Exp( lat * PI / 180.0)) - PI / 2.0);
return [lat, lon];
}
function CreateURLSurvey(lat, lon) {
var url = "arcgis-survey123://?itemID=<surveyid>";
url += "&field:name1=" + $feature["name1"] + "&field:name2=" + $feature["name2"];
url += "&field:name_new=" + $feature["name_new"] + "&field:rel_globalID=";
url += $feature["GlobalID"] + "&callback=https://collector.arcgis.app";
url += "¢er=" + lat + "," + lon;
Console(url);
return url;
}
var latlon = MetersToLatLon(Geometry($feature).X, Geometry($feature).Y);
var url = CreateURLSurvey(latlon[0], latlon[1]);
return url;
... View more
10-20-2020
02:32 PM
|
3
|
1
|
4286
|
|
POST
|
Hi adlukas1 , I'm glad that it works. Can you mark the answer as the correct answer? Thanks!
... View more
10-20-2020
06:30 AM
|
0
|
1
|
3567
|
|
POST
|
Hi Ari Lukas , The moment you submit the new feature, do you have values in the fields pilotpress, staticpress and respress? If not you will be performing the calculations with null values. It would be better to include a validation that checks if the values are null and avoids performing the calculation when not all values have been specified yet. Can you try this expression? // function to validate if any of the values have not been set yet
Function ContainsEmptyValue(arr) {
var validation = False;
for (var i in arr) {
if (IsEmpty(arr[i])) {
return True;
}
}
return validation;
}
// read values
var P = $feature.pilotpress;
var S = $feature.staticpress;
var R = $feature.respress;
// validate values
if (ContainsEmptyValue([P, S, R]) == False) {
// all value are available, calculate Q and RF
var Q = 167.0625 * Sqrt(P);
var RF = Q * Pow(((S - 20) / (S - R)), 0.54);
return RF;
} else {
// one or more values havve not been set, return null
return null;
}
... View more
10-19-2020
03:34 PM
|
1
|
3
|
3567
|
|
POST
|
Hi Tara Hunter , Dezso Lovicsek and Bracken Davis , Unfortunately, Attribute Rules currently only work in File Geodatabases and Enterprise Geodatabases and are not yet supported in ArcGIS Online.
... View more
10-19-2020
03:00 PM
|
3
|
0
|
2905
|
| 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
|