|
POST
|
Glad it worked. Please accept the answer, so that your question shows up as answered.
... View more
10-29-2021
12:32 AM
|
0
|
0
|
2449
|
|
POST
|
Something like this? var fs = FeatureSetByName(...)
var last_date = First(OrderBy(fs, "data_date DESC")).data_date
return Filter(fs, "data_date= @last_date")
... View more
10-28-2021
02:09 AM
|
1
|
2
|
2466
|
|
POST
|
https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/select-layer-by-location.htm
... View more
10-27-2021
04:59 AM
|
0
|
0
|
2901
|
|
POST
|
There is no way to return multiple values. You probably have to copy the expression:
... View more
10-26-2021
11:48 PM
|
1
|
1
|
1774
|
|
POST
|
Create a new integer field in your event fc. Do not join the tables. Calculate the new field, switch to Arcade, edit and use this code. var people_fc = FeatureSetByName($datastore, "PeopleFeatureclass", ["ObjectID"], true)
return Count(Intersects(Buffer($feature, 5), people_fc))
... View more
10-25-2021
02:20 AM
|
3
|
3
|
8739
|
|
POST
|
Option 1: select your "wrong" polygon Replace Geometry (ArcGIS Pro: Edit -> Tools) Trace the "correct" polygon Option 2: select both polygons !IMPORTANT! edit and run this code in the python window source_layer = "Layer with the correct shape"
destination_layer = "Layer with the wrong shape"
correct_shape = [row[0] for row in arcpy.da.SearchCursor(source_layer, ["SHAPE@"])][0]
with arcpy.da.UpdateCursor(destination_layer, ["SHAPE@"]) as cursor:
for row in cursor:
cursor.updateRow([correct_shape])
... View more
10-25-2021
01:05 AM
|
1
|
1
|
2264
|
|
POST
|
If popdiff is the label, not the data, you can use this var popdiff = Text(tot20 - tot10, '#,###')
... View more
10-25-2021
12:47 AM
|
1
|
0
|
4162
|
|
POST
|
Sadly, the code-button is pretty well hidden... You're repeating a lot of stuff. Your code can be considerably shortened by separating data (your paths) and logic (what to do with them). Also, your GDB path is the same for all layers, so you should just concatenate the feature class names to that path. You weren't doing anything with the blank group layer, so I omitted that part. If you tell me what you want to do with it, I can insert it again. Nevermind, I'm stupid. import arcpy
import os
# Change your path here, only once
gdb_path = r'C:\Users\Stak1\Documents\ArcGIS\Projects\20211015-20211022\20211015-20211022.gdb'
# Define your output groups
# {group_layer_name: [[fc_name, layer_name]]}
# You name the layers exactly as the feature classes, so this is a little
# overkill/too abstacted, but this way, you have the ability to name your
# layers independently from the fc in the future.
model_output_groups = {
"UHF": [
["UHF_SINGLE", "UHF_SINGLE"],
["UHF_MULTI", "UHF_MULTI"],
["UHF_ELLIPSES_SINGLE", "UHF_ELLIPSES_SINGLE"],
["UHF_ELLIPSES_MULTI", "UHF_ELLIPSES_MULTI"],
],
"VHF": [
["VHF_SINGLE", "VHF_SINGLE"],
["VHF_MULTI", "VHF_MULTI"],
["VHF_ELLIPSES_SINGLE", "VHF_ELLIPSES_SINGLE"],
["VHF_ELLIPSES_MULTI", "VHF_ELLIPSES_MULTI"],
],
"LBand": [
["Lband_SINGLE", "Lband_SINGLE"],
["Lband_MULTI", "Lband_MULTI"],
["Lband_ELLIPSES_SINGLE", "Lband_ELLIPSES_SINGLE"],
["Lband_ELLIPSES_MULTI", "Lband_ELLIPSES_MULTI"],
],
"XBand": [
["Xband_SINGLE", "Xband_SINGLE"],
["Xband_MULTI", "Xband_MULTI"],
["Xband_ELLIPSES_SINGLE", "Xband_ELLIPSES_SINGLE"],
["Xband_ELLIPSES_MULTI", "Xband_ELLIPSES_MULTI"],
]
}
aprx = arcpy.mp.ArcGISProject('CURRENT')
m = aprx.listMaps('*')[0]
blank_group_layer = arcpy.mp.LayerFile(r"C:\Users\Stak1\Documents\ArcGIS\Projects\Layer_Symbology_Reference\RFGeo_Folder.lyrx") #created previously in ArcPro and exported as lyrx file
m.addLayer(blank_group_layer, "TOP")
for group in model_output_groups:
group_layer = m.listLayers(group)[0]
print(group_layer)
for model_output in model_output_groups[group]:
fc = os.path.join(gdb_path, model_output[0])
layer = arcpy.management.MakeFeatureLayer(fc, model_output[1]).getOutput(0)
print(layer)
m.addLayerToGroup(group_layer, layer)
... View more
10-25-2021
12:26 AM
|
2
|
0
|
949
|
|
POST
|
The final code is the popup's html. For each of your equipment types, you need one of these: <div style="display: {expression/show_bike};">Content</div> If you have "bike" in your equipment field, this will evaluate to <div style="display: block;">Content</div> In HTML, "display: block" means that the element (the div in this case) will be shown on screen. If "bike" is not in your equipment field, the HTML will evaluate to <div style="display: none;">Content</div> which will hide the element. So if you only have "bike" in the field, the div elements for "car" and "boat" should be hidden. If that is not the case, you probably need to check the expression names. Could be that your expressions aren't named "expression/show_car", but "expression/expr0" or "expression/expression0" or similar.
... View more
10-22-2021
04:13 AM
|
1
|
1
|
3954
|
|
POST
|
New Map Viewer - Loss of HTML Pop UP Builder - Cha... - Esri Community IT seems like custom HTML popups aren't supported yet, but they are working on it.
... View more
10-22-2021
01:45 AM
|
0
|
0
|
14276
|
|
POST
|
// SortField: Field to sort the feature set by, e.g. ObjectID
var sort_val = $feature.SortField
var fs = FeatureSetByName($datastore,"YourFeatureset", ["SortField", "ValueField"])
fs = Filter(fs, "SortField < @sort_val")
if(Count(fs) == 0) {
return $feature.ValueField
}
return First(OrderBy(fs, "SortField DESC")).ValueField
... View more
10-22-2021
01:17 AM
|
0
|
0
|
1142
|
|
POST
|
So one point of the cutting line is defined and it should cut the polygon into equal areas. I doubt there's a tool for that (though I could be wrong). This seems like a job for Python, so I took a stab at it. I can get it to work with very small relative differences between the polygon parts, but the computation time is still quite high... import datetime
def cut_equally(polygon, point, max_increment=1, rel_err=0.01):
"""Cuts a polygon into equal parts, with one point of the cutting line predefined.
Returns a list of arcpy.PolygonGeometry, or an empty list if the target error
is too small or the maximum increment too big.
How it works:
1.) Create a buffer around the point, create a 1-dimensional intersection
of that buffer with the polygon.
1.a) If there is no such intersection, the buffer is too big, return an empty list.
2.) For each of the intersection of polygon and buffer, create a line between
that intersection and the point and cut the polygon.
3.) Calculate the relative error with
rel_err = abs(1 - area_1/area_2)
3.a) If rel_err is smaller than the target error, return the cut polygons.
4.) Increase the buffer distance. Small target errors need a very small
increment, which affects computing time massively. To alleviate that, the
increment is dynamic: it is the maximum of the current relative error and
a specified value.
5.) Repeat.
polygon: arcpy.PolygonGeometry, the polygon to be cut
point: arcpy.Point or arcpy.PointGeometry, the start point of the cutting line, must be on the polygon's edge
max_increment: the maximum increment to the buffer distance (see step 4)
rel_err: the target relative error (see step 3)
"""
# change point to point geometry
if not isinstance(point, arcpy.PointGeometry):
point = arcpy.PointGeometry(point)
# set start values for dist and curr_rel_err
dist = max_increment
curr_rel_err = max_increment
# loop
start_time = datetime.datetime.now()
while True:
# create a buffer and intersect with the polygon
point_buffer = point.buffer(dist)
intersect_points = polygon.intersect(point_buffer, 1)
# no intersection means the buffer is too big, return an empty list
if len(intersect_points) == 0:
print("Could not cut the polygon with the specified parameters.")
return []
for ip in intersect_points:
# create the cutting line
cut_line = arcpy.Polyline(arcpy.Array([point.firstPoint, ip]))
try:
# cut
poly_cuts = polygon.cut(cut_line)
# get the relative error
curr_rel_err = abs(1 - poly_cuts[0].area/poly_cuts[1].area)
# return if target error is met
if curr_rel_err <= rel_err:
print("area_1: {}, area_2: {}, rel_err: {}, time: {} seconds".format(int(poly_cuts[0].area), int(poly_cuts[1].area), curr_rel_err, (datetime.datetime.now() - start_time).seconds))
return poly_cuts
# these errors occur when the buffer is too small, ignore them
except (RuntimeError, ZeroDivisionError):
pass
# increase the buffer distance
dist += min(curr_rel_err, max_increment)
... View more
10-21-2021
08:18 AM
|
1
|
0
|
2560
|
|
POST
|
You can't do it in one expression. For each of your equipment types, you create an expression that shows or hides the div block in the popup. // show_car
var lines = Split($feature.Equip, ",")
for(var i in lines) {
if(lines[i] == "car") { return "block" }
}
return "none" // show_bike
var lines = Split($feature.Equip, ",")
for(var i in lines) {
if(lines[i] == "bike") { return "block" }
}
return "none" // show_boat
var lines = Split($feature.Equip, ",")
for(var i in lines) {
if(lines[i] == "boat") { return "block" }
}
return "none" <!--
display: block; shows the div
display: none; hides the div
in the expressions, you return either "block" or "none", depending on whether the equipment type is in the field.
-->
<div style="display: {expression/show_car};"><a href="https://luxe.digital/lifestyle/cars/fastest-cars">These are the fastest cars</a></div>
<div style="display: {expression/show_bike};"><a href="https://.../coolest_bikes">These are the coolest bikes</a></div>
<div style="display: {expression/show_boat};"><a href="https://..../biggest-ships">These are the biggest cruise ships</a></div>
... View more
10-21-2021
04:28 AM
|
1
|
3
|
3961
|
|
POST
|
When you configure your popup, there is an option to switch to the HTML source. ArcGIS Pro: Map Viewer Classic:
... View more
10-21-2021
03:10 AM
|
1
|
5
|
3965
|
|
POST
|
Basic code would be something like this: # read all attributes you want to copy, not just Subcat_3! Especially Shape, else you won't see the feature.
fields = ["SHAPE@", "Subcat_2", "Subcat_3"]
# use an SQL query ("Subcat_3 IS NOT NULL" or "Subcat_3 <> 'Nothing'")
values = [list(row) for row in arcpy.da.SearchCursor(social_layer, fields, "Subcat_3 IS NOT NULL")]
# I don't understand why you would want to have unique values?
# According to your question, you want to copy _every_ row with values in Subcat_3.
with arcpy.da.InsertCursor(social_layer, fields) as cursor:
for row in values:
# replace Subcat_2 with Subcat_3, delete Subcat_3
row[-2] = row[-1]
row[-1] = None
# insert
cursor.insertRow(row)
... View more
10-20-2021
11:14 PM
|
1
|
0
|
3452
|
| 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
|