|
POST
|
In the FeatureSetByName() function, the "drop" is in the wrong place. Is this a field or is this the value of Cable_Category you want to count? Also, trying to return "error" (a string) for an integer field will give you an error. If your field is a string field, it will work, though. if you want to reject the edit when there are no intersecting lines, you can return a dictionary with the key errorMessage. So, assuming "Drop" is the value you want to filter and you want to reject the edit if the point doesn't intersect any lines: var cable = FeatureSetByName ($datastore, "CableDD", ["Cable_Category"], true)
var cableDrop = Filer(cable, "Cable_Category = 'Drop'")
var intersectLayer = Intersects(cableDrop, $feature)
var cnt = Count(intersectLayer)
if (cnt > 0) {
return cnt
}
return {"errorMessage": "No intersecting lines"}
... View more
10-06-2022
12:51 AM
|
0
|
1
|
1580
|
|
POST
|
IsEmpty returns a boolean value (true or false). ! is the symbol for "not", it reverses the boolean output. !IsEmpty(value) returns true if the value is not empty. Booleans can be converted to numbers (true = 1, false = 0). Arcade can do that implicitly, without needing the explicit instruction to do so. So this code declares a variable c and sets its value to 0. Then it goes through the array of values. For each of those values, it adds the numeric equivalent (0 or 1) of "This value is not empty" to c. So if the value is empty, it adds 0, if the value is not empty, it adds 1. It basically counts the non-empty elements in the array.
... View more
10-05-2022
12:46 AM
|
1
|
1
|
1381
|
|
POST
|
That's it, I'm calling in backup! @jcarlson , any ideas?
... View more
10-04-2022
12:25 PM
|
1
|
3
|
3235
|
|
POST
|
intersect the points with each polygon layer join each output to the points export to a new feature class, delete unneccessary fields -> now you have a point feature class with 3 codes per point Calculate Field calculate 3 text fields: "Code1 -> Code2" or "No change" for 60s/90, 90s/2020s, and 60s/2020s For each of those fields, use Summary Statistics to get the count of points multiply with your point area to get the total area for each change
... View more
10-04-2022
08:32 AM
|
0
|
0
|
1857
|
|
POST
|
Huh... No idea. Does it work if you take care of the formatting yourself? var where = `GUID = '${$feature.GLOBALID}'`
var p1 = FeatureSetByName($map,"parcel (LogTest )")
var p1_filter = Filter(p1, where)
if(Count(p1_filter) > 0) {
return First(p1_filter).Address
}
var p2 = FeatureSetByName($map,"building (LogTest )")
var p2_filter = Filter(p2, where)
if(Count(p2_filter) > 0) {
return First(p2_filter).Address
}
var p3 = FeatureSetByName($map,"facilities (LogTest)")
var p3_filter = Filter(p3, where)
if(Count(p3_filter) > 0) {
return First(p3_filter).Address
}
return null
... View more
10-04-2022
06:28 AM
|
0
|
5
|
3241
|
|
POST
|
You have to declare the variable outside of When(). When() doesn't change any variables, it only returns a value. var quarter = when (theMonth < 3, 1,
theMonth < 6, 2,
theMonth < 9, 3,
theMonth < 12, 4,
"Fail");
... View more
10-04-2022
06:10 AM
|
1
|
1
|
1189
|
|
POST
|
selection_lines = "SelectLines" # path or layer name of the lines used to select
test_lines = "TestLines" # path or layer name of the lines to test for perpendicularity
angle_bounds = [70, 110] # what angles do you consider to be perpendicular?
distance = 200 # what's your search range?
output_location = "memory" # where do you want to save the result?
output_name = "PerpendicularLines" # what do you want to call the result?
import arcpy, math
def get_longest_segment(polyline):
"""Returns an arcpy.Polyline object representing the longest segment
of the input arcpy.Polyline
"""
# get line segments
sr = polyline.spatialReference
segments = []
for part in polyline:
for v1, v2 in zip(part, part[1:]):
segment = arcpy.Polyline(arcpy.Array([v1, v2]), spatial_reference=sr)
segments.append(segment)
# sort by length
segments.sort(key=lambda s: s.length)
# return last (longest) segment
return segments[-1]
def get_angle_between_lines(line1, line2):
"""Returns the angle between two arcpy.Polylines.
angle in degrees between 0° and 180°
"""
# get start and end points of both lines
fp1, lp1 = line1.firstPoint, line1.lastPoint
fp2, lp2 = line2.firstPoint, line2.lastPoint
# convert lines to vectors [dx, dy]
v1 = [lp1.X - fp1.X, lp1.Y - fp1.Y]
v2 = [lp2.X - fp2.X, lp2.Y - fp2.Y]
# get dot product and magnitudes
dp = v1[0] * v2[0] + v1[1] * v2[1]
m1 = math.sqrt(v1[0]**2 + v1[1]**2)
m2 = math.sqrt(v2[0]**2 + v2[1]**2)
# get the angle in radians
a = math.acos(dp/(m1 * m2))
# convert to degrees, cap to (0, 180) and return
return math.degrees(a) % 180
# create output table
arcpy.env.addOutputsToMap = True
output_table = arcpy.management.CreateTable(output_location, output_name)
arcpy.management.AddField(output_table, "FID_Selection", "LONG")
arcpy.management.AddField(output_table, "FID_Test", "LONG")
arcpy.management.AddField(output_table, "Angle", "FLOAT")
arcpy.env.addOutputsToMap = False
# create buffer around the selection lines
selection_buffer = arcpy.analysis.Buffer(selection_lines, "memory/SelectionBuffer", distance)
# intersect that buffer with the test lines
selection_test_intersect = arcpy.analysis.Intersect([selection_buffer, test_lines], "memory/SelectionTestIntersect", "ONLY_FID")
# read the pairs of (selection_OID, test_OID) from that intersection
selection_test_pairs = list({row[-2:] for row in arcpy.da.SearchCursor(selection_test_intersect, ["*"])})
arcpy.env.addOutputsToMap = True
# read lines as dictionaries {oid: geometry}
selection_shapes = {oid: shp for oid, shp in arcpy.da.SearchCursor(selection_lines, ["OID@", "SHAPE@"])}
test_shapes = {oid: shp for oid, shp in arcpy.da.SearchCursor(test_lines, ["OID@", "SHAPE@"])}
# start writing into the output table
with arcpy.da.InsertCursor(output_table, ["FID_Selection", "FID_Test", "Angle"]) as cursor:
# loop through the selection-test pairs
for sel_oid, test_oid in selection_test_pairs:
# get longest segments of both lines
sel_segment = get_longest_segment(selection_shapes[sel_oid])
test_segment = get_longest_segment(test_shapes[test_oid])
# get angle between segments
angle = get_angle_between_lines(sel_segment, test_segment)
# if perpendicular, write into the output table
if angle_bounds[0] <= angle <= angle_bounds[1]:
cursor.insertRow([sel_oid, test_oid, angle]) This script will output a table with the following fields: FID_Selection: the OBJECTID of the line in your selection layer FID_Test: the OBJECTID of the line in your test layer Angle: the angle between the longest segments of those lines To run it: Open the Python Window Copy and paste the script into the Python Window Edit the variables at the start If you use layers for selection_lines and test_lines, make sure there is no selection. Use forward slashes for paths output_location = "C:/SomeFolder/Database.gdb" using "memory" writes into RAM, which is faster (especially for large datasets), but the data is lost when you close ArcGIS. Don't forget to export the table! Hit Enter twice.
... View more
10-04-2022
06:01 AM
|
0
|
1
|
2794
|
|
POST
|
// get an array of the $feature's values
var values = [$feature.GewässerID, $feature.BescheidID, $feature.EinzugsgebietID, $feature.KontaktID, $feature.ASVNummer]
// get the count of non-empty values
var c = 0
for(var i in values) {
c += !IsEmpty(values[i])
}
// return true if 2 or more values are non-empty
return c >= 2
... View more
10-04-2022
02:47 AM
|
1
|
3
|
1414
|
|
POST
|
You need to use a variable with the @ notation in the Filter() function. You already created that variable, but then you try to use $feature in the sql statement, which doesn't work. You're trying to return from the wrong featuresets for p1 and p2. It should be faster to do the loading, filtering and returning for each layer before going to the next layer. This way, you don't unneccessarily load data. You don't need all those else's. If you return from a function, everything after that return statement isn't executed anymore. var GUID = $feature.GLOBALID
var p1 = FeatureSetByName($map,"parcel (LogTest )")
var p1_filter = Filter(p1, "GUID = @GUID")
if(Count(p1_filter) > 0) {
return First(p1_filter).Address
}
var p2 = FeatureSetByName($map,"building (LogTest )")
var p2_filter = Filter(p2, "GUID = @GUID")
if(Count(p2_filter) > 0) {
return First(p2_filter).Address
}
var p3 = FeatureSetByName($map,"facilities (LogTest)")
var p3_filter = Filter(p3, "GUID = @GUID")
if(Count(p3_filter) > 0) {
return First(p3_filter).Address
}
return null
... View more
10-01-2022
01:56 PM
|
0
|
7
|
3248
|
|
POST
|
Date Functions | ArcGIS Arcade | ArcGIS Developers Week(Today())
... View more
09-30-2022
05:34 AM
|
0
|
1
|
4667
|
|
POST
|
You could of course also include the lab in the text by using your label expression instead of parameter. And you could also color the text by applying the color expression to the whole symbol instead of only to the symbol element:
... View more
09-30-2022
05:19 AM
|
0
|
2
|
5760
|
|
POST
|
One possible way: set the layer's definition query to remove all parameters you don't want to show create a symbol that shows text next to a colorable symbol, save to style apply that symbol to your layer enable symbol property connections change to the text element, set the text string to the parameter field change to the symbol element, set the color to the Arcade expression var status = $feature.submissionstatus
if(status == "complete") { return "green" }
if(status == "rejected") { return "red" }
return "grey" change to the complete symbol, set the y offset to the Arcade expression var offsets = {
"Chlorinated Hydrocarbons": 0,
"Inorganics": -10,
"PAH": -20,
"PCB": -30,
"PBDE": -40,
"Pyrethroid": -50,
// and so on
}
return offsets[$feature.parameter] apply
... View more
09-30-2022
05:17 AM
|
0
|
0
|
5760
|
|
POST
|
Intersects() finds all intersecting features. In the next step, you have to get the actual Intersection() and find the longest one. // find intersecting streets
var streetLayer = FeaturesetByName($datastore, "baseStreetCenterline", ["ST_NAME"], true)
var streetIntersect = Intersects(streetLayer, $feature);
// find the street with the longest intersection
var name = null
var max_length = -1
for (var street in streetIntersect) {
// get the intersection
var segment = Intersection($feature, street)
// get the intersection's length
// if the line and polygon only touch at one vertex, segment will be null
var segment_length = IIF(segment == null, 0, Length(segment))
// compare to max_length, set name
if(segment_length > max_length) {
max_length = segment_length
name = street.ST_NAME
}
}
return name
... View more
09-30-2022
12:44 AM
|
2
|
1
|
2398
|
|
POST
|
Try this: var self = $feature["service_date"];
if($originalFeature == null) {
return self
}
var oServiceNumber = $originalFeature["service_number"];
var cServiceNumber = $feature["service_number"];
... View more
09-30-2022
12:00 AM
|
0
|
1
|
1811
|
|
POST
|
First one is wrong column names. Second one tries to sort empty date values. Can you send me a small subset of your points, either here or in a private message? In most cases, it's easier to troubleshoot that way.
... View more
09-28-2022
12:34 PM
|
1
|
3
|
5082
|
| 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
|