|
POST
|
Right, this was another question where Josh's very helpful blog post can help (for performance, not for your new problem). To return a Featureset, you first have to define it (what fields and geometry type does it have?), and then you have to fill it. Something like this should do the trick (Note the use of Memorize() for all loaded Featuresets, this should hopefully help with performance a lot.): // function to load a Featureset into RAM
function Memorize(fs) {
var temp_dict = {
fields: Schema(fs)['fields'],
geometryType: Schema(fs).geometryType,
features: []
}
for (var f in fs) {
var attrs = {}
for (var attr in f) {
attrs[attr] = Iif(TypeOf(f[attr]) == 'Date', Number(f[attr]), f[attr])
}
Push(
temp_dict['features'],
{attributes: attrs, geometry: Geometry(f)}
)
}
return FeatureSet(Text(temp_dict))
}
// load your Featuresets
var portals = ...
var mRamp = Memorize(FeaturesetByPortalItem(...))
var sql = "PassFail = 'Fail'"
var FailRamps = Filter(mRamp, sql)
var PriorityFeaturesets = [
Memorize(FeaturesetByPortalItem(...)),
// ...
]
var zoningLayer = Memorize(FeaturesetByPortalItem(...))
// define the output featureset
var out_fs = {
geometryType: "",
fields: [
{name: "GID", type: "esriFieldTypeString"},
],
features: []
}
// fill the featureset with all ramps that are near priority features or wihtin the zoning layer
for(var ramp in FailRamps) {
var zone = First(Intersects(zoningLayer, ramp))
if(zone != null) {
Push(out_fs.features, {attributes: {GID: ramp.GlobalID}})
continue
}
var rampBuffer = Buffer(ramp, 0.125, "miles")
for(var i in priorityFeaturesets) {
var priorityFeature = First(Intersects(priorityFeatures[i], ramp_buffer))
if(priorityFeature != null) {
Push(out_fs.features, {attributes: {GID: ramp.GlobalID}})
break
}
}
}
// return the output Featureset
return Featureset(Text(out_fs)) The way I wrote it, it should not count ramps that are near to multiple priority features multiple times. To be sure, you could just throw a Distinct() around the returned fs: return Distinct(Featureset(Text(out_fs)), ["GID"])
... View more
05-16-2023
11:22 AM
|
0
|
0
|
4069
|
|
POST
|
Huh. These are my default values, I didn't change anything: Raster and cell size seem to be dependent on another. Try inputting the column and row numbers of the original image, hopefully it will calculate the corresponding cell size.
... View more
05-16-2023
10:55 AM
|
1
|
0
|
1947
|
|
POST
|
You could use Remove Attachments and use the feature layer as both input table and match table.
... View more
05-16-2023
10:42 AM
|
0
|
1
|
6918
|
|
POST
|
Seems like myArray[f] is not equal to "332"... That's all we can tell you from that snippet. If you want more detailed help, you'll have to post the whole expression.
... View more
05-16-2023
04:36 AM
|
1
|
0
|
1625
|
|
POST
|
Your cell size and raster size parameters are wrong. If I use the default values, it works. If I use 1, I get the black image.
... View more
05-16-2023
03:50 AM
|
1
|
0
|
1970
|
|
POST
|
AFAIK, there is no version matrix available. ArcGIS Pro uses Python 3.X You can get the currently used Python version by running this script in your ArcGIS Pro Python Window: import sys
print(sys.version)
... View more
05-16-2023
02:20 AM
|
3
|
0
|
3281
|
|
POST
|
ListFeatureclasses() returns a list of fc names, but Rename expects complete paths. You have to construct the path from the workspace and the fc name. import arcpy, os
all_fc_names = arcpy.ListTables() + arcpy.ListFeatureClasses()
for ds in arcpy.ListDatasets():
all_fc_names += arcpy.ListFeatureClasses(feature_dataset=ds)
for name in all_fc_names:
fc_path = os.path.join(arcpy.env.workspace, name)
new_name = name.replace("_FG_GML", "").replace("_0001", "")
try:
arcpy.management.Rename(old_path, new_name)
except Exception as e:
print("Could not rename " + name + ": " + str(e))
... View more
05-16-2023
01:51 AM
|
1
|
1
|
1169
|
|
POST
|
Nope still waiting on that one. Related idea: https://community.esri.com/t5/arcgis-pro-ideas/add-error-handling-try-catch-to-arcade-language/idi-p/1047180
... View more
05-15-2023
12:34 PM
|
0
|
0
|
1246
|
|
POST
|
Hmm, I couldn't reproduce that behavior, the syntax does not differ. A possible explanation could be that your service contains values for which the expression fails, eg null values or strings without commas, strings where there is no space after the comma. Workarounds: don't split by ", ", just use the comma without space check the length of the split. if it's 1, return a default value (eg the whole string, or an error message) var f = Replace($feature.TextField2, " ", "")
var f_split = Split(f, ",")
if(Count(f_split) > 1) { return f_split[1] }
return f
... View more
05-15-2023
12:15 PM
|
0
|
2
|
1255
|
|
BLOG
|
I just helped a user with performance and tried your tip. I realized that you ignore geometries here. This means that you can't call geometry related functions like Intersects() on the memorized Featureset anymore, because (as I understand it) these would normally be evaluated on the server, but now have to be evaluated locally, and that doesn't give the correct results if there are no geometries. To remedy that, we can modify your function a little bit (lines 4 & 17): function Memorize(fs) {
var temp_dict = {
fields: Schema(fs)['fields'],
geometryType: Schema(fs).geometryType,
features: []
}
for (var f in fs) {
var attrs = {}
for (var attr in f) {
attrs[attr] = Iif(TypeOf(f[attr]) == 'Date', Number(f[attr]), f[attr])
}
Push(
temp_dict['features'],
{attributes: attrs, geometry: Geometry(f)}
)
}
return FeatureSet(Text(temp_dict))
} Care has to be taken to actually load the geometries: var fs = FeaturesetByPortalItem(some_portal, some_id, some_subid, ["*"], true)
fs = Memorize(fs) In your test script, I replaced line 41 with this: var the_state = First(Intersects(states, c)) I actually cancelled the execution with the "raw" featuresets after 5 minutes. Poor server... The script with the memorized featuresets took 5 seconds, so that is an amazing time saver.
... View more
05-15-2023
08:44 AM
|
3
|
0
|
6248
|
|
POST
|
Ah, I didn't realize that Josh ignored the geometries... Try this: function Memorize(fs) {
var temp_dict = {
fields: Schema(fs)['fields'],
geometryType: Schema(fs).geometryType,
features: []
}
for (var f in fs) {
var attrs = {}
for (var attr in f) {
attrs[attr] = Iif(TypeOf(f[attr]) == 'Date', Number(f[attr]), f[attr])
}
Push(
temp_dict['features'],
{attributes: attrs, geometry: Geometry(f)}
)
}
return FeatureSet(Text(temp_dict))
}
// ...
// change the false to true
var watersheds = Memorize(FeatureSetByPortalItem(p, '4a7abb05f6eb42d78e31587b05e3ebec', 0, ['Label_Field'], true))
... View more
05-15-2023
08:26 AM
|
1
|
2
|
3448
|
|
POST
|
This is a little hard to answer without knowing the datasets... Merge basically creates a new feature class and copies each feature from your input datasets into that new fc. So if your input fcs have points at the same locations, they will be inserted twice. If that's the case, a join might be a better option. Add Spatial Join creates a join based on location. If your points are overlapping / near each other, you can use that. If your points (somehow) aren't related spatially but have a common attribute, you can use Add Join to join the datasets on that attribute. The join only exists in the current map, the input datasets won't be affected. To permanently store the join, you can use Export Features. Is there a tool or spatial analysis method I have to do in ArcGIS Pro where it would allow me to filter the data points by specified regions in my country of interest If the points don't have a region attribute, you can get it by Intersecting or Spatial Joining the points with a polygon fc of your regions.
... View more
05-14-2023
10:45 AM
|
0
|
1
|
2182
|
|
POST
|
Switch to Arcade, it has those options. var a = Area($feature)
var p = Length($feature)
var v_num = Count(Geometry($feature).rings[0])
var v0 = Geometry($feature).rings[0][0]
var lines = [
v_num + " vertices",
"first vertex: " + Round(v0.x, 1) + " / " + Round(v0.y, 1),
"area: " + Round(a, 1) + " m²",
"perimeter: " + Round(p, 1) + " m",
]
return Concatenate(lines, TextFormatting.NewLine)
... View more
05-14-2023
10:34 AM
|
0
|
0
|
1130
|
|
POST
|
Ah. For that, you need two widgets: The Table Widget: Use your raw layer as input Set table type to "Grouped Values", group by sample type, define a count field The Category Selector Widget: can only be added to a Top/Sidebar Widget, so add that first set to "Grouped Values", use the same layer you used for the Table widget group by site add an action to filter the Table widget
... View more
05-13-2023
02:37 AM
|
1
|
0
|
1837
|
|
POST
|
Hey Erica, Josh raised a very interesting point in this blog. Basically, Featuresets aren't loaded into your local memory, so the Filter() and Intersects() are executed on the server (your portal/AGOL). This leads to many requests to the server, potentially slowing down the expression massively. Try the following: Copy Josh's Memorize function to the top of your script. in lines 41 & 50, use the Memorize function like so: var watersheds = Memorize(FeaturesetByPortalItem(...))
var fs = Memorize(FeaturesetByPortalItem(...))
... View more
05-13-2023
02:12 AM
|
0
|
4
|
3460
|
| 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
|