|
POST
|
Filter() uses a SQL expression. In SQL, the test for unequal is "<>". var fs_filt = Filter(fs, 'AGS_Schule <> AGS_Herkunft')
... View more
08-22-2022
07:30 AM
|
1
|
1
|
1440
|
|
POST
|
It should be in your content. I don't know about AGOL, but this is how it looks in Portal: Each service you publish is automatically published as Map Image Layer, optionally you can also publish a Feature Service.
... View more
08-22-2022
03:02 AM
|
1
|
0
|
4385
|
|
POST
|
Is this a Feature Service? These services will simplify the geometries on the fly for viewing at great scales. Maybe the dataset is so big that it takes a while to completely load. If waiting doesn't solve it, try using the corresponding Map Image Layer.
... View more
08-22-2022
01:33 AM
|
1
|
2
|
4398
|
|
POST
|
Try removing the asterisk in line 5. I'd be careful with using dictionary.get() here. If it doesn't find the specified key, it will return None by default, which will remove the value from the field. I don't think that is intended behavior. Instead, I'd do a try-except. Didn't see you were updating another field, where None values don't mean data loss. I'd still do it with a try-except to get a printout of the erroneous rows, if any. Also, row is a tuple, which is immutable, so assigning to row[2] will raise an exception. Nope, I was thinking of SearchCursor. UpdateCursor returns a list. Thanks @Anonymous User for the headsup. import arcpy
fc = 'C:/Temp/permits.gdb/test'
assignName = {"BP" : "BuildingPermit", "FMEA" : "FEMA_LOMAR", 'PLAT': "Plat"}
with arcpy.da.UpdateCursor(fc,["OBJECTID", "Type", "Type2"]) as cursor:
for oid, t, t2 in cursor:
if t is None: # skip is no Type value
continue
if 'PLAT' in t: # Type == 'PLAT*'? -> Type = 'PLAT'
t = 'PLAT'
try:
t2 = assignName[t]
except KeyError:
print(f'KeyError for OBJECTID {oid}: Can't find {t} in assignName')
t2 = None
cursor.updateRow([oid, t, t2])
... View more
08-22-2022
01:16 AM
|
0
|
0
|
2298
|
|
POST
|
Related: Use IDE for writing Arcade expressions - Esri Community Tips for debugging Arcade scripts in VSCode/Node.j... - Esri Community You can use external IDEs to get a nice syntax highlighting, but you probably won't be able to really debug it, since many Arcade functions (especially the FeatureSetBy*() functions) are specific to the ArcGIS environment. For me, the best way to test and debug is either the Playground | ArcGIS Arcade | ArcGIS Developers or a testing dashboard loaded with the data I actually work with.
... View more
08-22-2022
12:02 AM
|
0
|
0
|
1716
|
|
POST
|
Glad to help. Please accept the answer as solution, so that this question gets shown as resolved.
... View more
08-21-2022
11:47 PM
|
0
|
0
|
4111
|
|
POST
|
Just posted an Idea about this, feel free to add your support: Arcade: Allow Date() values in date fields (esriFi... - Esri Community
... View more
08-21-2022
11:37 PM
|
2
|
0
|
4116
|
|
IDEA
|
In things like Dashboards or Popups, it is common to create your own FeatureSet in the Arcade code. These FeatureSets often have date columns, these are defined with the field type "esriFieldTypeDate". If you input a feature with a Date() attribute, the FeatureSet will be empty: var fs_dict = {
fields: [
{name: 'DateField', type: 'esriFieldTypeDate'}
],
features: [
{attributes: {DateField: Now()}}
],
geometryType: ''
}
return FeatureSet(Text(fs_dict)) To insert a date, you have to convert to Number() first (line 6): var fs_dict = {
fields: [
{name: 'DateField', type: 'esriFieldTypeDate'}
],
features: [
{attributes: {DateField: Number(Now())}}
],
geometryType: ''
}
return FeatureSet(Text(fs_dict)) This is absolutely not a behavior users expect and it leads to confusion regularly. Please change the FeatureSet creation to allow Date() values in esriFieldTypeDate fields.
... View more
08-21-2022
11:35 PM
|
28
|
9
|
7012
|
|
POST
|
To post formatted code: You have a date field in your feature set. For whatever stupid design reason, you can't input Date() values into date fields, you have to convert them to Number() first. I took the opportunity to make your for loop shorter. var periods = [p1, p2, p3, p4, p5];
var features = [];
for (var cnt in periods) {
var period = periods[cnt];
for (var p in period) {
// get the original attributes
var copy_attributes = Dictionary(Text(p))['attributes']
// cast the date to number
copy_attributes['sample_date'] = Number(copy_attributes['sample_date'])
// calculate the period
copy_attributes['period'] = 'p' + (cnt + 1)
// push into array
Push(features, {'attributes': copy_attributes})
}
}
//return features;
var samples = {
'fields': [
{'name': 'objectid', 'type': 'esriFieldTypeInteger'},
{'name': 'assetid', 'type': 'esriFieldTypeString'},
{'name': 'wzonename', 'type': 'esriFieldTypeString'},
{'name': 'reservoir_id', 'type': 'esriFieldTypeString'},
{'name': 'sp_type', 'type': 'esriFieldTypeString'},
{'name': 'sample_date', 'type': 'esriFieldTypeDate'},
{'name': 'sample_year', 'type': 'esriFieldTypeString'},
{'name': 'test_description', 'type': 'esriFieldTypeString'},
{'name': 'result', 'type': 'esriFieldTypeDouble'},
{'name': 'izparea', 'type': 'esriFieldTypeString'},
{'name': 'period', 'type': 'esriFieldTypeString'}
],
'geometryType': 'esriGeometryPoint',
'features': features
};
//return samples;
return FeatureSet(Text(samples));
... View more
08-21-2022
11:18 PM
|
3
|
2
|
4124
|
|
POST
|
Glad you got it (mostly) working. Off the top of my head, possible reasons for the missing polygons: make sure you don't have a selection in the table make sure the coordinates are correct (are the missing rows correctly converted to points with Display XY Data?) make sure there are values in the bearing and distance fields
... View more
08-21-2022
10:34 PM
|
1
|
0
|
3504
|
|
POST
|
You probably have to publish the TestNeighbors in the same service, too. If this doesn't work, then I don't know, the whole service thing is very trial-and-error for me. You could try doing both fields in their own rule. Just select the field and change the return to return neighbor_attributes[0]["NearestNeighbor"] and return neighbor_attributes[0]["Distance"] respectively.
... View more
08-19-2022
03:54 AM
|
0
|
1
|
2624
|
|
POST
|
Is this expression actually {expression/expr0}? Have you actually applied the popup config? The popup only changes after you click OK in the configuration window.
... View more
08-19-2022
01:31 AM
|
0
|
1
|
1866
|
|
POST
|
After line 10, you have to check is dist < minDistance. If yes, update minDistance and name. At the end, return minDistance. Easier way: // Attribute Rule
// field: empty!
var NeighborLayer = FeatureSetByName($datastore, "TestNeighbors", ["NAME"]);
var searchDistance = 10000;
var NeighborIntersect = Intersects(NeighborLayer, Buffer($feature, searchDistance, "feet"));
// return early if nothing nearby, this saves you from all the indentation
if(First(NeighborIntersect) == null) {
return
}
// create an array of dictionaries
var neighbor_attributes = []
for(var neighbor in NeighborIntersect) {
var dist = Distance(neighbor, $feature, "feet")
var att = {"NearestNeighbor": neighbor.Name, "Distance": dist}
Push(neighbor_attributes, att)
}
// sort the array by distance
function sort_by_distance(a, b) {
return a["Distance"] - b["Distance"]
}
neighbor_attributes = Sort(neighbor_attributes, sort_by_distance)
// return the nearest neighbor's name and distance in one go
return {
"result": {"attributes": neighbor_attributes[0]}
}
... View more
08-19-2022
01:11 AM
|
1
|
3
|
2630
|
|
POST
|
Create your Arcade expression. This expression returns the mailto url. note the expression's name, in this case {expression/expr0}. Use that expression name as link url. Where to find images: Upload a picture to a publicly available url. Copy the picture's url and use it to insert a graphic into the popup.
... View more
08-19-2022
12:54 AM
|
0
|
0
|
1398
|
|
POST
|
This is expected behaviour. There are different "profiles", contexts in which Arcade can be used in the ArcGIS environment. Some of those profiles forbid certain globals and functions, mostly for technical or performance reasons. The different profiles and their allowed globals can be found here: Profiles | ArcGIS Arcade | ArcGIS Developers Each Arcade function is documented with the profiles in which it can be used. The function documentation is here: Function Reference | ArcGIS Arcade | ArcGIS Developers In a dashboard, $feature is replaced with $datapoint.
... View more
08-19-2022
12:29 AM
|
1
|
0
|
1152
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 01-30-2023 09:57 AM | |
| 1 | 05-18-2023 12:51 AM | |
| 1 | 03-05-2023 12:46 PM | |
| 1 | 12-07-2022 07:01 AM | |
| 1 | 06-21-2022 08:27 AM |
| Online Status |
Offline
|
| Date Last Visited |
02-03-2024
06:14 PM
|