|
IDEA
|
I don't know... Seems like a quite narrow use case to make a function for. Plus, you can easily do it yourself: function explode_polyline(geo) {
var segments = []
for(var p in geo.paths) {
for(var q = 1; q < Count(geo.paths[p]); q++) {
var point0 = paths[p][q-1]
var point1 = paths[p][q]
Push(segments, Polyline({"paths": [[point0, point1]], "spatialReference": geo.spatialReference}))
}
}
return segments
}
Console(explode_polyline(Geometry($feature)))
... View more
03-21-2022
07:34 AM
|
0
|
0
|
2385
|
|
POST
|
Arcade doesn't evaluate HTML. Maybe what you want to do is possible, but it will be a little complicated. I suggest posting a new question for this, as this goes far beyond the scope of the original question, and you'll get more views and potential answers.
... View more
03-21-2022
04:02 AM
|
0
|
0
|
3202
|
|
POST
|
When you do it manually, you open the tool XY Table To Point (Data Management)—ArcGIS Pro | Documentation. To automate the process, you could use a script like this: csv_files = [
"H:/test.csv",
# etc.
]
import os
wkid = 25832 # the wkid of your coordinate system
x = "X"
y = "Y"
z = None
gdb = None # path to the database where you want to save the feature class. None: default gdb of your project
for csv in csv_files:
print(csv)
name = os.path.basename(csv).split(".")[0]
if gdb is not None:
name = os.path.join(gdb, name)
arcpy.management.XYTableToPoint(csv, name, x, y, z, wkid)
... View more
03-21-2022
02:57 AM
|
0
|
0
|
1879
|
|
POST
|
Hmmm. Try adding this at the start of your script: if(IsEmpty($feature.IDARRET)) {
return "null"
}
... View more
03-21-2022
02:32 AM
|
0
|
0
|
3208
|
|
IDEA
|
var geo = Geometry($feature)
var vertices = []
for(var p in geo.rings) {
for(var q in geo.rings[p]) {
Push(vertices, geo.rings[p][q])
}
}
Console(vertices[0].type)
Console(vertices) Point
[{"x":-9812667.6540304,"y":5129910.50665289,"spatialReference":{"wkid":102100}},
{"x":-9812667.66625145,"y":5129910.50667924,"spatialReference":{"wkid":102100}},
// ...
{"x":-9812667.6540304,"y":5129910.50665289,"spatialReference":{"wkid":102100}}]
... View more
03-21-2022
12:10 AM
|
0
|
0
|
1059
|
|
IDEA
|
Yes, a snap function would be great. In the meantime, you can do it yourself (this is in multiple of my Calculation Attribute Rules): function closest_feature(test_feature, compare_feature_set) {
// returns the feature of compare_feature_set that is closest to test_feature
var min_distance = 9999999
var closest_feature = null
for(var f in compare_feature_set) {
var d = Distance(test_feature, f)
if(d < min_distance) {
min_distance = d
closest_feature = f
}
}
return closest_feature
}
function project_orthogonally(point_geometry, line_geometry) {
// returns a projection of the point_geometry onto the line_geometry
// only start and end point of the line_geometry are considered!
// https://de.wikipedia.org/wiki/Orthogonalprojektion
// https://en.wikibooks.org/wiki/Linear_Algebra/Orthogonal_Projection_Onto_a_Line
var p = point_geometry
var r0 = line_geometry.paths[0][0]
var r1 = line_geometry.paths[0][-1]
var ux = r1.x - r0.x
var uy = r1.y - r0.y
var lambda = ((p.x-r0.x)*ux + (p.y-r0.y)*uy) / (ux*ux + uy*uy)
var new_p = Point({"x": r0.x + lambda * ux, "y": r0.y + lambda * uy, "spatialReference": p.spatialReference})
// if new_p is on the line defined by r0 and r1 but not on the actual line_geometry, snap it to the closest end point
if(Disjoint(new_p, line_geometry)) {
new_p = IIF(Distance(r0, p) < Distance(r1, p), r0, r1)
}
return new_p
}
function snap_point_to_polyline(point_geometry, polyline_geometry) {
// returns a point that is snapped to the polyline_geometry
// create feature set of the polyline's segments
var sr = point_geometry.spatialReference
var vertices = polyline_geometry.paths[0]
var fs_segments = {"fields": [], "spatialReference": sr, "geometryType": "esriGeometryPolyline", "features": []}
for(var s=0; s<Count(vertices)-1; s++) {
var p0 = vertices[s]
var p1 = vertices[s+1]
Push(fs_segments.features, {"geometry": {"paths": [[ [p0.x, p0.y], [p1.x, p1.y] ]], "spatialReference": sr}})
}
fs_segments = FeatureSet(Text(fs_segments))
// project point_geometry onto the closest segment
var closest_segment_geo = Geometry(closest_feature(point_geometry, fs_segments))
return project_orthogonally(point_geometry, closest_segment_geo )
}
var fs_lines = FeatureSetByName($datastore, "Lines")
// optionally, buffer
fs_lines = Intersects(fs_lines, Buffer($feature, 100))
var closest_line_geometry = Geometry(closest_feature($feature, fs_lines))
return snap_point_to_polyline(Geometry($feature), closest_line_geometry)
... View more
03-20-2022
11:46 PM
|
0
|
0
|
2445
|
|
POST
|
I'll just copy my answer from your idea: In case you don't know: You can use negative numbers to index arrays from the end. While array[0] returns the first element, array[-1] returns the last element, array[-2] returns the second to last element and so on. So you can get the last point of a polyline by jumping to the last point of the last line segment: Geometry($feature).paths[-1][-1]
... View more
03-20-2022
11:31 PM
|
2
|
0
|
2356
|
|
IDEA
|
Add your support to this idea (Under Consideration): Attribute rule arcade expression calling webservic... - Esri Community
... View more
03-20-2022
11:19 PM
|
0
|
0
|
3558
|
|
IDEA
|
In case you don't know: You can use negative numbers to index arrays from the end. While array[0] returns the first element, array[-1] returns the last element, array[-2] returns the second to last element and so on. So you can get the last point of a polyline by jumping to the last point of the last line segment: Geometry($feature).paths[-1][-1]
... View more
03-20-2022
11:11 PM
|
0
|
0
|
3187
|
|
POST
|
Your "build out popup" code is wrong. If you only want to return the first entry of relateData: var firstRelateData = First(relateData)
if(firstRelateData == null) { // no related data
return "null"
}
return firstRelateData.num_arret If you want to return all related features: if(Count(relateData) == 0) { // no related data
return "null"
}
var all_num_arrets = []
for(var f in relateData) {
if(f.num_arret != null) {
Push(all_num_arrets, f.num_arret)
}
}
return Concatenate(all_num_arrets, ", ")
... View more
03-20-2022
11:03 PM
|
0
|
0
|
3217
|
|
POST
|
Like Dan said, you are connecting things in your code that aren't connected in your feature. This is the faulty part of your code: pt_list = []
# Step through each part of the feature
for part in row[1]:
for pnt in part:
if pnt:
pt_list.append((pnt.X, pnt.Y)) You go though all parts of a multiplart polyline and append all points into a single array. But that introduces connections ( => line segments => additional length) that aren't there in your feature. Take the northern part of your polyline (I exploded it into single parts): This is part 5: This is part 6: This is part 7: The red vertices are the ends of the line parts. In your code, you loop through the line parts and append the points from start to end of the line part. That means that you suddenly have a virtual line from the end of part 6 to the start of part 7: This accounts for 36.5 meters of your error. Add in the other virtual lines you introduced and you got your difference.
... View more
03-18-2022
05:45 AM
|
0
|
1
|
2908
|
|
POST
|
Are you married to doing it with ModelBuilder? Because that seems like an easy job for Python (untested): import os
parcels = [
"path:/to/Parcel_Dataset_1",
"path:/to/Parcel_Dataset_2",
"path:/to/Parcel_Dataset_3",
]
apn = "path:/to/APN_Dataset"
# read the parcel data
parcel_data = dict()
for parcel in parcels:
parcel_name = os.path.basename(parcel)
join_field_values = [row[0] for row in arcpy.da.SearchCursor(parcel, ["JoinField"])]
parcel_data[parcel_name] = join_field_values
# parcel_data looks like this:
#parcel_data = {
# "Parcel_Dataset_1": [1, 2, 3, 4, 5, 6],
# "Parcel_Dataset_2": [7, 8, 9],
# "Parcel_Dataset_3": [1, 2, 5, 8, 10, 11],
# }
# open an UpdateCursor on APN, filter only features where TargetField is empty
with arcpy.da.UpdateCursor(apn, ["JoinField", "TargetField"], "TargetField IS NULL") as cursor:
# loop throguh the APN features
for join_value, parcel_name in cursor:
# loop through the parcel datasets
for p in parcel_data:
if join_value in parcel_data[p]:
# there is a match in this parcel dataset
parcel_name = p
# stop looping through the rest of the parcel datasets
break
# write the parcel dataset name to the APN dataset
# note: if no match was found in all of the parcel datasets, parcel_name
# will be null
cursor.updateRow([join_value, parcel_name]) Then the problem would be simply how to sort your parcel datasets. You can input them in the correct order manually, but if they have a date or version number or something similar in their name, you can also do it automatically
... View more
03-18-2022
05:02 AM
|
0
|
0
|
1149
|
|
IDEA
|
You can do that. Simple view: SELECT Shape, BauwerkID, CONCAT('I am building ', BauwerkID) AS "TextID"
FROM database.dataowner.Bauwerke Popup Arcade expression: var view_fs = FeatureSetByName($datastore, "database.dataowner.TestView")
var bw_id = $feature.BauwerkID
var v = First(Filter(view_fs, "BauwerkID = @BW_id"))
if(v == null) { return "nothing here" }
return v.TextID Popup: You just can't use FeatureSetByRelationshipName(), because that relies on Relationship Classes, which you can't create for a view.
... View more
03-18-2022
03:26 AM
|
0
|
0
|
1562
|
|
POST
|
If you call First() on an empty feature set, it will return null. So when you then call null.assetid, this will fail. As Kim said, you have to check if transf_FS contains any features. You could do that by using Count(), but that is expensive for large feature sets. It's easier to check if t is null: var t = First(transf_FS)
if(t == null) {
return "Some default value"
}
// continue with your code
if(IsEmpty(t.assetid)){
...
... View more
03-18-2022
02:53 AM
|
0
|
0
|
2049
|
| 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
|