|
POST
|
I also have a legend in the layout I would like to change according to the layer as well. How will I be able to do this? Make sure that your legend synchronizes with visible layers: JohannesLindner_0-1658746688101.png Do you have a link to this documentation for editing and exporting layouts specifically as well? You can manipulate layouts with the arcpy.mp (mapping) module: Introduction to arcpy.mp—ArcGIS Pro | Documentation In the link's table of contents, expand the "Classes" tab to see the documentation for all classes of that module. Here, I used Layout, MapFrame, Map, Layer, and TextElement.
... View more
07-25-2022
04:05 AM
|
2
|
5
|
7210
|
|
POST
|
A big limitation of Attribute Rules is that they only know about their own database. With eg Popups, you can access external data using the $map global or FeatureSetByPortalID(). None of these work in Attribute Rules, you are limited to $datastore. A possible workaround seems to be to create a cross-database view of the external feature class in the database backend and register that view with the geodatabase. This way, you could use it in Attribute Rules. I haven't tested this and I doubt this is a supported workflow, so maybe try it in a test environment... Solved: Access a field value in a layer that is outside th... - Esri Community An easier solution would be to copy the districts to your database. Districts should be fairly static, so it shouldn't be too much work to keep the copy current. Just have an automated script recopying every night or do it manually every month or so. But of course, this approach clutters your database and introduces data redundancy, which is generally bad...
... View more
07-25-2022
01:20 AM
|
0
|
1
|
1610
|
|
POST
|
This also handles group layers, even nested ones: from pathlib import Path
def export_layout_for_each_layer(layer_list, layout, save_folder):
save_folder = Path(save_folder)
# turn all layers off
for layer in layer_list:
layer.visible = False
# while there are still layers in the list
while layer_list:
# remove the first layer from the list and make it visible
layer = layer_list.pop(0)
layer.visible = True
# special treatment for group layers
if layer.isGroupLayer:
# recursively call this function on its sub layers (this exports all the sub layers on their own
export_layout_for_each_layer(layer.listLayers(), layout, save_folder)
# make the sub layers visible (so we can export the group layer) and remove the sub layers from the master layer list (because we already exported them)
for sub_layer in layer.listLayers():
layer_list.remove(sub_layer)
sub_layer.visible = True
# set title and export, then make layer invisible
print(f"Exporting layout for {layer.name}")
layout.listElements("TEXT_ELEMENT")[0].text = layer.name
layout.exportToPDF(save_folder/f"{layer.name}.pdf")
layer.visible = False
# define your save location
save_folder = Path(arcpy.env.workspace).parent
# get the elements you need
aprx = arcpy.mp.ArcGISProject("current")
layout = aprx.listLayouts("Layout")[0]
map_frame = layout.listElements('MAPFRAME_ELEMENT')[0]
layers = map_frame.map.listLayers()
# run it
export_layout_for_each_layer(layers, layout, save_folder)
... View more
07-25-2022
12:33 AM
|
2
|
1
|
7220
|
|
POST
|
from pathlib import Path
# define your save location
save_folder = Path(arcpy.env.workspace).parent # 'C:/Users/xxx/Documents/ArcGIS/Projects/Testing'
# get the elements you need
aprx = arcpy.mp.ArcGISProject("current")
layout = aprx.listLayouts("Layout")[0]
title = layout.listElements("TEXT_ELEMENT")[0]
map_frame = layout.listElements('MAPFRAME_ELEMENT')[0]
layers = map_frame.map.listLayers()
# turn off all layers
for layer in layers:
layer.visible = False
# loop over layers
save_folder = Path(save_folder)
for layer in layers:
print(f"Exporting layout for {layer.name}")
layer.visible = True
title.text = layer.name
layout.exportToPDF(save_folder/f"{layer.name}.pdf")
layer.visible = False This assumes that you only have one text element (the title) and no group layers.
... View more
07-24-2022
11:51 PM
|
0
|
0
|
7230
|
|
POST
|
Have you looked at Attribute Rules? Introduction to attribute rules—ArcGIS Pro | Documentation
... View more
07-21-2022
05:38 AM
|
1
|
0
|
796
|
|
POST
|
Hello, I work on the evolution of a pond from old maps. First of all, I georeferenced all my maps on ArcGis Pro, I also manage to superimpose them together. My problem is: I want to create a simplified map showing the evolution of the pond from the old lines of the pond. To do this, I don't know if I have to cut out my pond, which is not a completely circular pond, or if there is another way. Does anyone have a solution and can explain it to me clearly? I am new to ArcGis Pro So you have georeferenced maps of your pond from different years and want to extract only the area around the pond? You can do it this way: scroll to your pond for each of your georeferenced raster: right click on the layer in the contents Data -> Export Raster JohannesLindner_0-1658402763023.png In the Export Raster dialog, set the Clipping Geometry to "Current Display Extent" JohannesLindner_1-1658402804475.png
... View more
07-21-2022
04:30 AM
|
0
|
0
|
563
|
|
POST
|
Python: # use a SearchCursor to get ids and names
ids_and_names = [row for row in arcpy.da.SearchCursor("FC", ["ID", "name"])]
# use an UpdateCursor to update the concatenated names
with arcpy.da.UpdateCursor("FC", ["ID", "name_concat"]) as cursor:
for row in cursor:
names = [name for id, name in ids_and_names if id == row[0]]
name_concat = ", ".join(names)
cursor.updateRow([row[0], name_concat]) You could also use the field calulator with Arcade: // filter the dataset by the current id
var id = $feature.ID
var features_with_this_id = Filter($featureset, "ID = @ID")
// extract names as array
var names = []
for(var f in features_with_this_id) {
Push(names, f.name)
}
// return the concatenated array
return Concatenate(names, ", ")
... View more
07-21-2022
04:06 AM
|
0
|
1
|
2005
|
|
POST
|
These work for me... For FGDB: return $feature.Shape_Length For EGDB (SQL Server): return $feature['Shape.STLength()']
... View more
07-21-2022
02:35 AM
|
0
|
0
|
3319
|
|
POST
|
You can absolutely create (and update or delete) features in the same table or even different tables using attribute rules. The trick is to not return a value, but a dictionary, using special dictionary keys: Attribute rule dictionary keywords—ArcGIS Pro | Documentation For your case, the rule would look somewhat like this: // calculation attribute rule
// triggers: (Insert,) Update
// Exclude from application evaluation!
// if status did not change to "REPLACED", return -9999
var status_changed_to_replaced = $feature.Status == "REPLACED" && $originalfeature.Status != "REPLACED"
if(!status_changed_to_replaced) { return -9999 }
// copy attributes
var copy_fields = ["Field1", "Field2", "Field3"] // exclude readonly fields (OBJECTID, GlobalID, editor tracking, etc.)
var old_attributes = Dictionary(Text($feature)).attributes
var new_attributes = Dictionary()
for(var f in copy_fields) {
var field = copy_fields[f]
new_attributes[field] = old_attributes[field]
}
// optional: set attributes
new_attributes.Status = "AUTO_INSERTED"
// return the updated field value and instruct ArcGIS to create a new feature
return {
"result": 2022,
"edit": [{
"className": "Database.DataOwner.Featureclass", // complete name of your feature class here (the same class as the one on which you create this rule)
"adds": [{"geometry": Geometry($feature), "attributes": new_attributes}]
}]
}
... View more
07-21-2022
01:50 AM
|
1
|
2
|
2802
|
|
IDEA
|
@LCTechLogin You should be able to do something like this: // calculation attribute rule
// field: LastGeometryEdit (Date)
// triggers: Insert, Update
// geometry changed if we're inserting a new feature or if the old and new geometry aren't equal
var geometry_changed = $editcontext.editType == "INSERT" || !Equals(Geometry($originalfeature), Geometry($feature))
// if geometry changed, return current dtae and time, else return field value
return IIf(geometry_changed, Now(), $feature.LastGeometryEdit) This could also be somewhat used as workaround for the original idea. But of course, the rule will still fire if you edit an attribute, so there will be some perfomance hit, especially if you edit large chunks at once. var geometry_changed = $editcontext.editType == "INSERT" || !Equals(Geometry($originalfeature), Geometry($feature))
// no geometry edit? return the current field value
if(!geometry_changed) { return $feature.WATERSHED }
// your code (this will only get executed if geometry_changed is true)
var fsPolyBoundary = ...
var fsPoly = ...
var loc = ...
...
...
return name
... View more
07-21-2022
01:03 AM
|
0
|
0
|
6844
|
|
POST
|
So you want to do something like this? Click on Create Features, choose the point template Click into the map but instead of creating a new feature, the coordinates of an existing point are updated This could be kinda possible (you'd end up with a feature without geometry, so you wouldn't see it on the map). But, questions: What's your use case? Why not use the edit tools to edit the existing point? How would you decide which existing point to edit? Coordinates as in numeric fields in the table or as in the actual point geometry?
... View more
07-21-2022
12:41 AM
|
0
|
7
|
5287
|
|
POST
|
Try using a raw string: arcpy.CalculateField_management("inTable_view", r"Centralité__point___ATTACH"+".SEQ", calcExp, "VB")
... View more
07-06-2022
06:12 AM
|
0
|
1
|
1524
|
|
POST
|
When you return from a function (or an Arcade expression in this case), the code stops executing there. Everything after the first executed return statement gets skipped. That's why your first example didn't work. It's also why your second example didn't work, because it can be rewritten like this: if(condition1){
return "Su"
} else {
if(condition2) {
return "Mo"
} else {
if(condition3) {
return "Tu"
} else {
... To do what you want: evaluate an if statement for each condition either build up a return string as you go along or store each string and concatenate at the end // array to store the strings
var open_days = []
// evaluate each day, add open days to the array
if($feature.USER_SUNDAY == 1) { Push(open_days, "Su") }
if($feature.USER_MONDAY == 1) { Push(open_days, "M") }
if($feature.USER_TUESDAY == 1) { Push(open_days, "Tu") }
if($feature.USER_WEDNESDAY == 1) { Push(open_days, "W") }
if($feature.USER_THURSDAY == 1) { Push(open_days, "Th") }
if($feature.USER_FRIDAY == 1) { Push(open_days, "F") }
if($feature.USER_SATURDAY == 1) { Push(open_days, "Sa") }
// concatenate the strings and return
return Concatenate(open_days, ", ")
... View more
07-06-2022
12:04 AM
|
3
|
1
|
2237
|
|
POST
|
def split_name(name):
"""splits a name (str) into 3 parts (first, middle, last)"""
try:
name_parts = name.strip().split(" ")
except AttributeError:
# handle non-strings
return [None, None, None]
first = name_parts[0]
last = name_parts[-1]
middle = " ".join(name_parts[1:-1])
if middle == "":
middle = None
return [first, middle, last]
split_name('David Smith')
#['David', None, 'Smith']
split_name('David "The cooler David" Johnson')
#['David', '"The cooler David"', 'Johnson']
split_name("Clinton B Brennan")
#['Clinton', 'B', 'Brennan'] Use that function as code block and these expressions to calculate the fields: FirstName = split_name(!Name!)[0]
MiddleName = split_name(!Name!)[1]
LastName = split_name(!Name!)[2]
... View more
07-05-2022
07:52 AM
|
2
|
0
|
2343
|
|
POST
|
Let's look at Josh's answer above you. What it does is the following: get an array of values define a function with which to filter this array. this function returns true if you want the value to stay in the array. we want a value to stay in the array if it is unequal to zero (!=0). but we also have to account for null values. that's what DefaultValue does: it returns the value if it is not null and returns a default value (0 in this case) if it is null. filter the array get the average of the filtered array So, if we apply Josh's answer to your problem (and make the steps more obvious): // get an array of values
var values = [$feature.Qrt1_2022, $feature.Qrt2_2022, $feature.Qrt3_2022, $feature.Qrt4_2022]
// define a function that we use to filter the array
// returns true (keep value) if value is not null and is unequal to 0
function drop_zero(value) {
var non_null_value = DefaultValue(value, 0) // value is null? -> value = 0
return non_null_value != 0
}
// filter the array
var filtered_values = Filter(values, drop_zero)
// return the average of the filtered array
return Average(filtered_values)
... View more
07-05-2022
01:36 AM
|
3
|
1
|
5764
|
| 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
|