|
POST
|
Does the code generate features, you just can't see them? Then you probably still work with the 25832 as your coordinate system. That was my coordinate system for testing, you should replace that with the well-known id of your coordinate system. If that doesn't work, please post the csv, either here or in a private message.
... View more
08-19-2022
12:23 AM
|
0
|
2
|
3524
|
|
POST
|
Yes. OID@ is a placeholder for an ObjectID field. If you load a csv, you probably don't have that. Even though I see it in your table. Did you just name your field "OBJECTID*" or is that a real ObjectID? You actually don't need the ObjectID. It was just a way to be able to join the polygons to the observation table via Observations.OBJECTID = Polygons.FID If you're creating the table with Excel, just create a field ID (or some other name) and let the values in that column increment automatically. In line 35, change "OID@" to "ID".
... View more
08-17-2022
09:37 AM
|
1
|
2
|
3559
|
|
POST
|
does this tell me what I'm going wrong? Kind of. It tells you what problem it encountered (can't open "Observations") and where the error is (line35), from that you have to deduce what you did wrong. In this case, it couldn't open the table "Observations". This is probably because your table has a different name. Either rename your table (click on it in the table of contents, press F2) or change the function call to reflect your table's name. Seeing these kinds of capabilities on ArcGIS is both intimidating and exciting! Yeah, I know that feeling... The neat part is, that doesn't really stop. The more you learn, the more specific your problems and questions get. Google and of course the Community are a big help in my ArcGIS journey...
... View more
08-17-2022
07:49 AM
|
1
|
4
|
3566
|
|
POST
|
A very basic implementation: wkid = 25832 # coordinate system
x_range = [423000, 423100, 10] # start, stop, step
y_range = [5970000, 5970100, 10]
z_range = [1, 10, 1]
points_3d = arcpy.management.CreateFeatureclass("memory", "points_3d", "POINT", has_z="YES", spatial_reference=wkid)
with arcpy.da.InsertCursor(points_3d, ["SHAPE@"]) as cursor:
for x in range(*x_range):
for y in range(*y_range):
for z in range(*z_range):
p = arcpy.Point(x, y, z)
g = arcpy.PointGeometry(p, wkid)
cursor.insertRow([g])
... View more
08-17-2022
05:45 AM
|
0
|
1
|
4366
|
|
POST
|
Hmm... That seems like a very rare error. Either you used some wrong inputs or there's something funky with your data. This is not the place to get into this, though. If you want to create relationship classes (they can be useful but are rarely (never?) really neccessary), I suggest asking for help in the Data Management - Esri Community You can also just use the filter you already have in place, I updated the code in my other anser.
... View more
08-17-2022
04:30 AM
|
0
|
0
|
2803
|
|
POST
|
So, assuming you have a table like this: Display the locations right-click the table in the table of contents, "Display XY Data" Choose where you want to save the point feature class, choose the appropriate coordinate fields and your coordinate system, click OK. Display the view polygons This is a little more complicated. You could probably do that using a combination of geoprocessing tools, but I didn't find an easy one. This is a case where a small Python script gets the job done faster. Open the Python window Copy/Paste these functions and hit enter twice def circle_section(x, y, start, end, radius, wkid):
"""Creates a circle section.
x, y: float, coordinates of the center
start, end: int, start and end of the section in degrees, Nort=0°, East=90°
radius: float, radius of the section
wkid: int, well-known id of the coordinate system
returns an arcpy.Polygon in the chosen coordinate system
"""
start = int(start)
end = int(end)
center = arcpy.Point(x, y)
center_geo = arcpy.PointGeometry(center, wkid)
angles = range(start, end, 1)
if start > end:
angles = list(range(start, 360, 1)) + list(range(0, end, 1))
arc_geos = [center_geo.pointFromAngleAndDistance(angle, radius, "PLANAR") for angle in angles]
points = [center] + [ag.firstPoint for ag in arc_geos] + [center]
return arcpy.Polygon(arcpy.Array(points), spatial_reference=wkid)
def create_view_sheds(in_table, out_features, x_field, y_field, bearing_left_field, bearing_right_field, distance_field, wkid):
"""Creates a polygon feature class with circle sections.
in_table: str, path to the input table or name of the table in the active map
out_features: str, path to the output feature class
*_field: str, names of the fields in the input table
wkid: int, well-known id of the coordinate system
"""
# create output feature class
from pathlib import Path
folder = str(Path(out_features).parent)
name = str(Path(out_features).name)
arcpy.management.CreateFeatureclass(folder, name, "POLYGON", spatial_reference=wkid)
arcpy.management.AddField(out_features, "FID", "LONG")
with arcpy.da.InsertCursor(out_features, ["SHAPE@", "FID"]) as i_cursor:
with arcpy.da.SearchCursor(in_table, ["OID@", x_field, y_field, bearing_left_field, bearing_right_field, distance_field]) as s_cursor:
# for each table row
for oid, x, y, bearing_left, bearing_right, distance in s_cursor:
# create a circle section
poly = circle_section(x, y, bearing_left, bearing_right, distance, wkid)
# write the polygon and the table row's objectid into the feature class
i_cursor.insertRow([poly, oid]) Call the function create_view_sheds("Observations", "memory/Viewsheds", "X", "Y", "BearingLeft", "BearingRight", "Distance", 25832)
... View more
08-17-2022
04:16 AM
|
1
|
5
|
3580
|
|
POST
|
You can use Sum() for that. // get the related table
var related = FeatureSetBy*(...)
// build the popup lines
var popup_lines = [
"Bulky Waste Items: " + Sum(related, "BWCnt"),
"Recyclables: " + Sum(related, "RecCnt"),
]
// conacatenate and return
return Concatenate(popup_lines, TextFormatting.NewLine)
... View more
08-17-2022
12:51 AM
|
0
|
0
|
1110
|
|
POST
|
Hmmm... No idea what the error message means. This is probably something specific to AGOL (I tested in Pro) or to your data. Is your data publicly available so I could take a look?
... View more
08-16-2022
06:33 AM
|
0
|
0
|
2598
|
|
POST
|
See, I tried to use the SQL expression, but I tried things like CASTing to Date or using YEAR(created_Date), MONTH, and DAY, and they all failed. Didn't try EXTRACT. Glad to see that it does work, if you take the right approach.
... View more
08-16-2022
06:28 AM
|
0
|
1
|
5877
|
|
POST
|
If you want to do this for just a few features, you can do it manually. Activate the Merge tool Select the features you want to merge Click on the feature whose attributes you want to keep You can edit these attributes Click Merge If you have to do it more often, you'll probably have to write a short Python script.
... View more
08-16-2022
06:22 AM
|
0
|
0
|
1093
|
|
POST
|
// Calculation Attribute Rule on Addresses
// field: empty
// triggers: Insert, Update, Delete
// Exclude from application Evaluation
// if we're updating the address, but not changing the Number field, abort
if($editcontext.editType == "UPDATE" && $feature.Number == $originalfeature.Number) { return }
// get the related distribution box
var box_name = $feature.box
var box_featuredataset = FeatureSetByName(...)
var box = First(Filter(box_featuredataset, "name = @box_name"))
if(box == null) { return } // no related box found, abort
// get the current Apartment count and calculate the new one, according to our edit mode:
// Insert: add
// Delete: subtract
// Update: subtract old, add new
var apartments = box.Number_Apartments
var change = When(
$editcontext.editType == "INSERT", $feature.Number,
$editcontext.editType == "DELETE", -$feature.Number,
$editcontext.editType == "UPDATE", -$originalfeature.Number + $feature.Number,
0 // default value
)
// instead of returning a value, we return a dictionary that follows certain rules, see
// https://pro.arcgis.com/en/pro-app/2.9/help/data/geodatabases/overview/attribute-rule-dictionary-keywords.htm
return {
"edit": [{
"className": "Addresses",
"updates": [{
"globalID": box.GlobalID,//or "objectID": box.OBJECTID
"attributes": {"Number_Apartments": apartments + change}
}]
}]
}
... View more
08-16-2022
06:06 AM
|
0
|
0
|
2840
|
|
POST
|
That is absolutely possible. Question: How do you get the distribution box that belongs to an address? Do you have a foreign key field? Have you built a relationship class? Do you use spatial relationship?
... View more
08-16-2022
05:48 AM
|
1
|
3
|
2854
|
|
POST
|
# you can turn asset into a layer:
asset_layer = arcpy.management.MakeFeatureLayer(asset, "asset_layer")
# and then you can call the selection on the layer.
# But, much easier: MakeFeatureLayer takes an optional SQL where clause. So:
asset_layer = arcpy.management.MakeFeatureLayer(asset, "asset_layer", '"COORDINATE_VALID_DATE" = CURRENT_DATE' )
arcpy.SpatialJoin_analysis(asset_layer, polygonLayer01, "asset_join_poly01", "JOIN_ONE_TO_MANY", "KEEP_COMMON", "", "INTERSECT")
... View more
08-16-2022
05:34 AM
|
0
|
1
|
2649
|
|
POST
|
GroupBy() takes an SQL92 expression, not an Arcade expression. There are ways to group by day in SQL, but Arcade didn't like any of them, Group By seems to be very limited. Here's what I came up with in the end: // load feature set
var fs = FeatureSetByPortalItem(Portal(url), id, layer, ["created_date"], false)
// Convert datetime to date
var fs_date = {
geometryType: "",
fields: [
{name: "DateShort", type: "esriFieldTypeDate"},
],
features: []
}
for(var f in fs) {
var d = f.created_date
var date_short = Number(Date(Year(d), Month(d), Day(d)))
Push(fs_date.features, {attributes: {DateShort: date_short}})
}
// group by and order by DateShort
var fs_grouped_by_date = GroupBy(FeatureSet(Text(fs_date)), "DateShort", {name: "Total", expression: "1", statistic: "COUNT"})
var fs_ordered_by_date = OrderBy(fs_grouped_by_date, "DateShort")
// get cumulative count
var fs_cumulative = {
geometryType: "",
fields: [
{name: "DateShort", type: "esriFieldTypeDate"},
{name: "Total", type: "esriFieldTypeInteger"},
{name: "Cumulative", type: "esriFieldTypeInteger"},
],
features: []
}
var cumulative = 0
for(var f in fs_ordered_by_date) {
cumulative += f.Total
var new_feature = {attributes: {DateShort: Number(f.DateShort), Total: f.Total, Cumulative: cumulative}}
Push(fs_cumulative.features, new_feature)
}
// return
return FeatureSet(Text(fs_cumulative)) It loads reasonably fast for my 4.5k features, your mileage may vary... If you publish from an enterprise gdb, it might be better to do the grouping in a database view with SQL and publish that view.
... View more
08-16-2022
05:29 AM
|
1
|
0
|
5889
|
|
POST
|
It's hard to give specific tips without knowing your data, but here are some general ones: Sand layer thickness Join the sampling results to the sites. The goal here is to have a point layer with a sand thickness attribute. Now convert this point layer into a polygon layer of areas with thickness >= 5m Either Create Thiessen Polygons, then select and delete all polygons where thickness < 5m or interpolate a raster of sand thickness with (for example) IDW, use the Raster Calculator to create a raster where all cells with sand thickness >= 5m get the same value and all other cells are null, then convert the Raster to Polygon These polygons are suitable according to the requirement. Neighboring a specific habitat Create a layer of forests with an area > 10 hectares Select the habitat(s) Select Layer By Location, using the habitat layer as selecting features and a relationship of "Intersects", "Within Distance", or "Boundary Touches", depending on your data. Check "Invert Spatial Relationship". The selected forest polygons are suitable according to the requirement.
... View more
08-16-2022
04:02 AM
|
1
|
0
|
1263
|
| 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
|