|
POST
|
Just checked, this error occurs when you try to do an Intersects() with null geometries. Check your feature classes for empty geometries, for example with this Arcade expression in Calculate Field: return IIf(Geometry($feature) == null, "NULL GEOMETRY", null)
... View more
05-04-2023
12:42 AM
|
0
|
0
|
2766
|
|
POST
|
var start_x = Geometry($feature).paths[0][0].x
var start_y = Geometry($feature).paths[0][0].y
var end_x = Geometry($feature).paths[-1][-1].x
var end_y = Geometry($feature).paths[-1][-1].y
... View more
05-02-2023
09:35 AM
|
1
|
3
|
5450
|
|
POST
|
// Popup Arcade expression for the Road Inventory layer
// load the Defects layer
var defects = FeaturesetByName($datastore, "Defects", ["*"], false)
// filter the defects by UniqueID, LaneID, and Meterage
var unique_id = $feature.UniqueID
var lane_id = $feature.LaneID
var start = $feature.StartLength
var end = $feature.EndLength
var query = "UniqueID = @unique_id AND LaneID = @lane_id AND Meterage >= @start AND Meterage <= @end"
var filtered_defects = Filter(defects, query)
// create and return the text output
var return_lines = [
Count(filtered_defects) + " defects on this lane.",
]
for(var d in filtered_defects) {
Push(return_lines, "Defect at " + d.Meterage + " meters")
}
return Concatenate(return_lines, Textformatting.NewLine)
... View more
05-02-2023
08:40 AM
|
0
|
0
|
2541
|
|
POST
|
# add the spatial join, store the result layer in a variable
joined_layer = arcpy.management.AddSpatialJoin("BuildingFootprintsCE", "landuse","JOIN_ONE_TO_ONE", "KEEP_ALL")[0]
# get the join name from the layer's attributes
join_name = joined_layer.connectionProperties["destination"]["dataset"]
print(f"join name: {join_name}")
# do the calculation
expression = f"!{join_name}.type!.title()"
print(f"expression: {expression}")
arcpy.management.CalculateField("BuildingFootprintsCE", "BuildingFootprintsCE.type", expression, "PYTHON3")
# remove the join
arcpy.management.RemoveJoin("BuildingFootprintsCE", join_name)
... View more
05-02-2023
07:54 AM
|
1
|
0
|
1787
|
|
POST
|
km = get_km(!hm!) Code Block count = len([row for row in arcpy.da.SearchCursor("CApa_hm_km", ["*"])])
last_full_km = int(count / 10)
current_km = 0
def get_km(hm):
global last_full_km
global current_km
current_km += hm / 1000
km = current_km + 1
if current_km < last_full_km:
km = int(km)
return km
... View more
05-02-2023
07:24 AM
|
1
|
1
|
1360
|
|
POST
|
Sorry to say that I have no clue. Try deleting the rule and creating it in 2.9.
... View more
05-02-2023
12:38 AM
|
0
|
0
|
2215
|
|
POST
|
The Intersects() function takes a Featureset and a Feature/Geometry and returns a Featureset of Features that intersect the input Feature. You're trying to intersect 2 Featuresets One of those (combinedDict) is actually a Dictionary, and even if it was a FS, it would have no features yet You have to do the intersect before the GroupBy, because grouped Featuresets don't have geometries. This is untested: // define your input layers and their output status
var p = Portal('https://mass-eoeea.maps.arcgis.com')
var layers = [
{
id: '12345x',
subid: 1,
query: "Point_Status = 'Stable'",
file_number: 'SV_CGP_File_Number',
out_status: 'Stable',
},
{
id: '12345x',
subid: 1,
query: "Point_Status = 'Unstable'",
file_number: 'SV_CGP_File_Number',
out_status: 'Unstable',
},
{
id: '12345x',
subid: 1,
query: "Point_Status = 'General Obs.'",
file_number: 'SV_CGP_File_Number',
out_status: 'General Observation',
},
{
id: '12345x',
subid: 3,
query: "R_Point_Status = 'Stable'",
file_number: 'R_CGP_File_Number',
out_status: 'Stable Revisit',
},
{
id: '12345x',
subid: 3,
query: "R_Point_Status = 'Unstable'",
file_number: 'R_CGP_File_Number',
out_status: 'Unstable Revisit',
},
]
// load the watersheds
var watersheds = FeatureSetByPortalItem(p, '4a7abb05f6eb42d78e31587b05e3ebec', 0, ['Label_Field'], false)
// create an empty feature array
var features = []
// iterate over the input layers
for(var i in layers) {
var layer = layers[i]
// load and filter
var fs = FeaturesetByPortalItem(p, layer.id, layer.subid, [layer.file_number], true)
var filtered_fs = Filter(fs, layer.query)
// iterate over the features
for(var f in filtered_fs) {
// get the intersecting watershed
var i_ws = First(Intersects(f, watersheds))
var i_ws_name = IIf(i_ws == null, "No watershed", i_ws.Label_Field)
// add the feature to the array
var new_f = {attributes: {
File_Number: f[layer.file_number],
Pt_Status: layer.out_status,
Watershed: i_ws_name,
}}
Push(features, new_f)
}
}
// create a Featureset with all these features
var combined_dict = {
fields: [
{name: "File_Number", type: "esriFieldTypeString"},
{name: "Pt_Status", type: "esriFieldTypeString"},
{name: "Num_Inspections", type: "esriFieldTypeInteger"},
{name: "Watershed", type: "esriFieldTypeString"},
],
geometryType: "",
features: features,
}
var combined_fs = Featureset(Text(combined_dict))
// GroupBy to get the counts
var grouped = GroupBy(
combined_fs,
["File_Number", "Pt_Status", "Watershed"],
[{name: "Num_Inspections", expression: "1", statistic: "COUNT"}]
)
return grouped
... View more
05-01-2023
02:22 PM
|
0
|
6
|
3498
|
|
POST
|
You named the field "created_date" (line 52), but in the features, you call it "created" (lines 23. 33, 34). They have to be the same.
... View more
05-01-2023
01:16 PM
|
1
|
1
|
2077
|
|
POST
|
Do you actually use this expression in 2.9? The expression should work for ArcGIS Pro 2.7+
... View more
05-01-2023
01:08 PM
|
0
|
2
|
2222
|
|
POST
|
You have to dive into the CIM for that. def get_min_max_scale(layer):
result = dict()
cim = layer.getDefinition('V3')
renderer = cim.renderer
try:
symbol_classes = renderer.groups[0].classes
except (AttributeError, IndexError):
print("Symbology not applicable!")
symbol_classes = []
for sc in symbol_classes:
result[sc.label] = [sc.symbol.minScale, sc.symbol.maxScale]
return result
lyr_with_unique_symbols = arcpy.mp.ArcGISProject("current").activeMap.listLayers("TestPoints")[0]
get_min_max_scale(lyr_with_unique_symbols)
#{'capital': [0.0, 0.0], 'city': [500000, 0.0], 'town': [100000, 0.0], 'village': [50000, 0.0]}
lyr_with_single_symbol = arcpy.mp.ArcGISProject("current").activeMap.listLayers("TestLines")[0]
get_min_max_scale(lyr_with_single_symbol)
#Symbology not applicable!
#{}
... View more
04-28-2023
02:29 PM
|
0
|
1
|
1913
|
|
POST
|
var fsJurisdiction = FeatureSetByName($datastore, "jurisdictions", ["Jurisdiction"])
var fsJurisdictionIntersect = Intersects(fsJurisdiction, $feature)
var intersected_jurisdictions = []
for(var j in fsJurisdictionIntersect) {
var jurisdiction = {
Jurisdiction: j.Jurisdiction,
Overlap: Area(Intersection(j, $feature))
}
Push(intersected_jurisdictions, jurisdiction)
}
function sort_by_overlap(j1, j2) { return j1.Overlap < j2.Overlap }
var jurisdiction = First(Sort(intersected_jurisdictions, sort_by_overlap))
if (jurisdiction == null) return {"errorMessage": "Not in a jurisdiction"}
return jurisdiction.Jurisdiction
... View more
04-27-2023
10:53 PM
|
0
|
4
|
2243
|
|
POST
|
To post code: However, the syntax is different when doing the code for pop-ups versus in the Dashboard List The main difference is that you have to return a Featureset for Dashboard elements. Let me start by saying this: If all you're doing is removing the underscores, you're making it much too complicated. Your popup expression could look like this: // replace underscore with space
return Replace($feature["WORKERS_ASSIGNED"], "_", " ") Now, a data expression that goes through your Survey layer and replaces the underscores in the WORKERS_ASSIGNED field could look like this: // this is my test data
//var fs = {geometryType:"",fields:[{name:"WORKERS_ASSIGNED",type:"esriFieldTypeString"}, {name:"X",type:"esriFieldTypeInteger"}],features:[{attributes:{WORKERS_ASSIGNED:"Joe_Biden", X:46}},{attributes:{WORKERS_ASSIGNED:"Donald_Trump", X:45}},{attributes:{WORKERS_ASSIGNED:"Barack_Obama", X:44}},{attributes:{WORKERS_ASSIGNED:"George_W_Bush", X:43}},{attributes:{WORKERS_ASSIGNED:"Bill_Clinton", X:42}},{attributes:{WORKERS_ASSIGNED:"George_H_W_Bush", X:41}},{attributes:{WORKERS_ASSIGNED:"Ronald_Reagan", X:40}}]}
//fs = Featureset(Text(fs))
// load your Layer
var fs = FeaturesetByPortalItem(...)
// Copy the schema of your layer into a new emppty Featureset
var fs_schema = Schema(fs)
var out_fs = {
geometryType: fs_schema.geometryType,
fields: fs_schema.fields,
features: []
}
// loop over your Layer's features
for(var f in fs) {
// get the attributes
var att = Dictionary(Text(f)).attributes
// replace underscores
att.WORKERS_ASSIGNED = Replace(att.WORKERS_ASSIGNED, "_", " ")
// append the edited feature to the output featureset
Push(out_fs.features, {geometry: Geometry(f), attributes: att})
}
// return the output featureset
return Featureset(Text(out_fs)) Be sure that you actually load your Layer in line 6. Using the FeaturesetByPortalItem function, you also can limit the fields you want to import. This is my test input And the output it created
... View more
04-26-2023
04:16 PM
|
0
|
0
|
791
|
|
DOC
|
I just tried it for my city. The given coordinates were way off. I then tried to get coordinates for specific addresses (basically using ChatGPT to geocode), and they also were completely wrong. Like, 15 kilometers away from the actual point. And when I regenerated answers, it gave me slightly different coordinates (ca. 50 meters difference). When I asked it to return a GeoJson with multiple geocoded addresses, it had this to say at the end: Somehow I doubt it really uses a geocoding API, or at least a very bad one.
... View more
04-26-2023
07:30 AM
|
0
|
0
|
7544
|
|
POST
|
Yes, the geometry has to be included in this case. But Stefan's code didn't even get to that point, because the Includes function doesn't work for inner array:
... View more
04-26-2023
06:52 AM
|
0
|
0
|
1898
|
| 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
|