|
POST
|
OK, you could do that with the DateAdd function: var esri__measure = 63788415353
var as_date = DateAdd(Date("1900-01-01"), esri__measure * 10000000 / 10, "microseconds")
var only_time = Text(as_date, "HH:mm:ss")
Console(`esri__measure: ${esri__measure}`)
Console(`esri__measure as Date: ${as_date}`)
Console(`esri__measure as HH:mm:ss : ${only_time}`) esri__measure: 63788415353
esri__measure as Date: null
esri__measure as HH:mm:ss : Invalid DateTime But, as you see, Arcade can't handle your input. If you run your code in python, but return the whole date, you get a date in the year 3921, which is probably too big for Arcade. Are you sure about your Python code? esri__measure = 63788415353
datetime.datetime(1900,1,1) + datetime.timedelta(microseconds = (esri__measure * 10000000) /10)).isoformat()
#'3921-05-17T20:15:53'
... View more
06-13-2022
03:41 AM
|
0
|
0
|
1625
|
|
POST
|
You can use the GroupBy function for that: var test_data = {
geometryType: "",
fields: [
{name: "Borehole", type: "esriFieldTypeString"},
{name: "Visit", type: "esriFieldTypeString"},
{name: "WaterLevel", type: "esriFieldTypeDouble"},
],
features: [
{attributes: {Borehole: "BH101", Visit: "R1", WaterLevel: 2.6}},
{attributes: {Borehole: "BH101", Visit: "R2", WaterLevel: 2.4}},
{attributes: {Borehole: "BH101", Visit: "R3", WaterLevel: 3.2}},
{attributes: {Borehole: "BH101", Visit: "R4", WaterLevel: 2.5}},
{attributes: {Borehole: "BH101", Visit: "R5", WaterLevel: 3.2}},
{attributes: {Borehole: "BH101", Visit: "R6", WaterLevel: 2.9}},
{attributes: {Borehole: "BH102", Visit: "R1", WaterLevel: 1.8}},
{attributes: {Borehole: "BH102", Visit: "R2", WaterLevel: 1.6}},
{attributes: {Borehole: "BH102", Visit: "R3", WaterLevel: 1.6}},
{attributes: {Borehole: "BH102", Visit: "R4", WaterLevel: 1.3}},
{attributes: {Borehole: "BH102", Visit: "R5", WaterLevel: 1.9}},
{attributes: {Borehole: "BH102", Visit: "R6", WaterLevel: 1.5}},
]
}
var boreholes = FeatureSet(Text(test_data))
//return boreholes
var range_statistics = [
{
name: "Min",
expression: "WaterLevel",
statistic: "MIN"
},
{
name: "Max",
expression: "WaterLevel",
statistic: "MAX"
}
]
var boreholes_with_range = GroupBy(boreholes, "Borehole", range_statistics)
return boreholes_with_range
... View more
06-13-2022
03:24 AM
|
0
|
0
|
914
|
|
POST
|
Hi, welcome to the ESRI community! I'm not sure what you mean by "possibly in milliseconds", could you elaborate on that? In case you mean the UNIX epoch (milliseconds since 1970-01-01 00:00:00), you can do it by converting the number to a Date and then formatting that Date with the Text function: var x = 63788415353
var x_date = Date(x)
var x_date_formatted = Text(x_date, "HH:mm:ss")
Console(`x: ${x}`)
Console(`x as Date: ${x_date}`)
Console(`Date(x) as HH:mm:ss : ${x_date_formatted}`) x: 63788415353
x as Date: 1972-01-09T08:00:15.353+01:00
Date(x) as HH:mm:ss : 08:00:15
... View more
06-13-2022
02:20 AM
|
0
|
2
|
1716
|
|
POST
|
Yeah, I used that process too. My expression was something like Count(Geometry($feature).rings[0]) which counts the vertices in the first ring of the polygon. I tried (without any hope) to use a for loop: var ring = Geometry($feature).rings[0]
for(var p in ring) {
return ring[p]
} but very unsurprisingly that just returns the dictionary of the first vertex on all of the vertices. I don't think there is a way to evaluate a symbol expression for separate vertices, just for the whole polygon. I strongly believe that to do this in ArcGIS, you have to convert the vertices to points.
... View more
06-10-2022
04:44 PM
|
1
|
0
|
3435
|
|
POST
|
should have tested in a fresh environment... fixed it in my answer.
... View more
06-10-2022
04:32 PM
|
0
|
0
|
701
|
|
POST
|
Open your Python window in ArcGIS Pro Copy and Paste this script, execute def _get_perpendicular_line(line_geometry, point_geometry, half_length):
"""returns a line (arcpy.Polyline) that is perpendicular to the input line
line_geometry: arcpy.Polyline, the input line
point_geometry: arcpy.Point or arcpy.PointGeometry, the location of the returned line
half_length: length of the perpendicular line to each side of the input line
"""
# clip input line at input point
if isinstance(point_geometry, arcpy.Point):
point_geometry = arcpy.PointGeometry(point_geometry)
clip_extent = point_geometry.buffer(0.1).extent
clipped_line = line_geometry.clip(clip_extent)
# get angle of clipped line -> angle of input line at input point
fp = arcpy.PointGeometry(clipped_line.firstPoint)
lp = arcpy.PointGeometry(clipped_line.lastPoint)
line_angle = fp.angleAndDistanceTo(lp, "PLANAR")[0]
# construct nad return perpendicular line
new_line_points = arcpy.Array([
point_geometry.pointFromAngleAndDistance(line_angle + 90, half_length, "PLANAR").firstPoint,
point_geometry.pointFromAngleAndDistance(line_angle - 90, half_length, "PLANAR").firstPoint,
])
return arcpy.Polyline(new_line_points, spatial_reference=line_geometry.spatialReference)
def _get_buffer_with_flat_ends(line_geometry, buffer_distance):
"""returns a buffer (arcpy.Polygon) with flat ends around the input line
line_geometry: arcpy.Polyline, the input line
buffer_distance: distance of the line to each side of the buffer
"""
# create a normal buffer
buffer = line_geometry.buffer(buffer_distance)
# get perpendicular lines at the line end points
buffer_cutoffs = [
_get_perpendicular_line(line_geometry, line_geometry.firstPoint, buffer_distance),
_get_perpendicular_line(line_geometry, line_geometry.lastPoint, buffer_distance),
]
# cut the buffer with those lines, keep the largest part
for bc in buffer_cutoffs:
buffer_parts = buffer.cut(bc)
buffer = sorted(buffer_parts, key=lambda bp: bp.area)[-1]
return buffer
def buffer(in_features, buffer_distance, out_path, out_name):
"""creates a polygon feature class with flat-end-buffers
in_features: input Polyline feature class path or layer name
buffer_distance: distance of the line to each side of the buffer
out_path: path of the output feature class
out_name: name of the output feature class
"""
# read ObjectID and geometry of line fc
in_data = [row for row in arcpy.da.SearchCursor(in_features, ["OBJECTID", "SHAPE@"])]
# create output fc
out_fc = arcpy.management.CreateFeatureclass(out_path, out_name, "POLYGON")
arcpy.management.AddField(out_fc, "ORIG_FID", "LONG")
# buffer and insert
with arcpy.da.InsertCursor(out_fc, ["ORIG_FID", "SHAPE@"]) as cursor:
for oid, line in in_data:
try:
polygon = _get_buffer_with_flat_ends(line, buffer_distance)
cursor.insertRow([oid, polygon])
except Exception as e:
print(f"Could not buffer line {oid}: {e}") Call it like this buffer("TestLines", 200, "C:/Your/output/path", "FlatEndBuffer") This will probably throw all kinds of errors for complicated geometries, hopefully it helps.
... View more
06-10-2022
05:21 AM
|
0
|
3
|
3220
|
|
POST
|
Surprisingly, this isn't really straight forward... Maybe (hopefully) there's an easier way, but this works: Change your units to mm In the symbology tab, choose the circle shape Remove fill color and choose an appropriate outline color, set outline width to a good value (0.25 mm works fine) Allow symbol property connections Set the mapping of the Size parameter to this expression: 500000 / $view.scale * 2.83465 500000: circle size in mm $view.scale: current map scale 2.83465: magic number used to convert pt to mm Uncheck "Scale proportionally. Set the value of the size parameter, this will only affect how the symbol is shown in the legend. Duplicate the symbol layer change the duplicated layer's size expression to 1000000 / $view.scale * 2.83465 double the duplicated layer's size value You can change your units to pt again. This won't change how the symbol works. But if you change the expressions or size values, this will then use pts, so... don't do that.
... View more
06-10-2022
03:42 AM
|
4
|
2
|
4388
|
|
POST
|
I believe the line end option is only available with an Advanced license.
... View more
06-10-2022
02:42 AM
|
0
|
4
|
4740
|
|
POST
|
Arcade is perfect for that. // load the points
var points = FeatureSetByName($datastore, "Database.DataOwner.Intersection_Points", ["Road_Name"], true)
// get all points intersecting the current centreline
var points_on_feature = Intersects($feature, points)
// filter out all points that belong to this centreline
var road_name = $feature.Road_Name
var points_of_other_streets = Filter(points_on_feature, "Road_Name <> @road_name")
// maybe you want to sort?
points_of_other_streets = OrderBy(points_of_other_streets , "Road_Name")
// iterate through all remaining points and extract the road name
var road_names = []
for(var p in points_of_other_streets) {
Push(road_names, p.Road_Name)
}
// concatenate and return
return Concatenate(road_names, ",") You can use that expression in the Calculate Field tool. Or, to make it automatic, you could create a Calculation Attribute Rule that calculates the value each time you create (and/or update) a centreline.
... View more
06-09-2022
10:42 PM
|
1
|
0
|
1830
|
|
POST
|
Hey, welcome to the ESRI community! This indeed is the place to get answers to all things ESRI. Arcade can not be used to call stored procedures. It simply doesn't have any functions to do that (and I have no clue if it could theoretically be possible). Arcade can be used to read and write data to tables. These write processes also execute database triggers. Should/Can Arcade be used to develop the app You can't develop an App in Arcade, it isn't made for that. Arcade is a language ESRI created for interacting with data in many (all?) of their applications: For example, you can populate map popups make labels and symbology dependent on feature attributes build datasets for charts in Dashboards implement Attribute Rules (similar to database triggers and I think Batch Calculation Attribute Rules and Validation Rules function similar to stored procedures) So you can't develop an App in Arcade, but Arcade could play a role in your App, depending on what you want to do. I'm not certain how implement a mobile app Depends on what you want to do. Do you just want to show a map? Then a simple Webmap might suffice. Do you want to add some functionality around that map, e.g. feature filters, measuring tools, info graphics, bookmarks, sharing, splash screen, data editing, and then some more? Web AppBuilder can do that. Do you want even more, like multiple pages, embedded Dashboards, dynamic feature lists, completely free layout? Look no further than Experience Builder. If that isn't enough, you have to develop either widgets for a prebuilt ESRI App or your own custom App. I think most people do that with the ArcGIS API for JavaScript. Give the community a look! As for the role Arcade could play in all of this, maybe this blog can answer some of your questions: Your Arcade Questions Answered (esri.com) For better directions, it would be helpful to know more about what you want to do.
... View more
06-09-2022
10:29 PM
|
0
|
0
|
1104
|
|
POST
|
From the Glossary: [...] Each ring in a polygon contains an array of point coordinates, where the first and last point are the same. [...] To create a topologically correct polygon, exterior rings are oriented clockwise, and interior rings (holes) are oriented counter-clockwise. [...] And from the arcpy doc on Polygons: During the creation of a geometry object, a simplification process is performed to make the geometry topologically consistent according to its geometry type. For instance, it rectifies polygons that may be self-intersecting, or contain incorrect ring orientations. That suggests that the vertex order in ArcGIS and Oracle is different ArcGIS reverses the vertex order if you draw a counter-clockwise polygon (it does) the edit vertices tool hides the last vertex (it can be seen using Python or Arcade)
... View more
06-09-2022
01:07 AM
|
1
|
0
|
3489
|
|
POST
|
Doesn't seem that way. The label engine can only label the whole polygon. I thought I had something with symbology, but I only managed to get the vertex count to be displayed on each vertex. Sequential numbering isn't possible, because Arcade expressions aren't evaluated for each vertex, but for the whole feature. If you really need this feature, you'll have to extract the vertices to points and label those. To make it dynamic, you could create an Attribute Rule that creates and deletes those points when you edit the polygon geometry. Depending on your average vertex count, this might have a low to medium impact on edit performance.
... View more
06-09-2022
12:50 AM
|
2
|
0
|
3483
|
|
POST
|
You define inspection directly in the for loop declaration. That's what the var does: It creates a variable. It's a shortcut. You could also do it outside the loop. These two loops work exactly the same: var arr = [1, 2, 3]
var i
for(i in arr) {
Console(arr[i])
}
for(var j in arr) {
Console(arr[j])
}
... View more
06-08-2022
11:40 PM
|
0
|
0
|
2089
|
| 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
|