POST
|
You're right, it takes only the first feature in the copy layer and pastes its attributes into all features of the paste layer. If you want to do a one-to-one copy/paste based on selection, you can do it like this: # read all copy features
data = [row for row in arcpy.da.SearchCursor(copy_layer, copy_fields)]
# paste their attributes into the paste features
with arcpy.da.UpdateCursor(paste_layer, paste_fields) as cursor:
for i, row in enumerate(cursor):
try:
cursor.updateRow(data[i])
except IndexError:
print("You selected too few features in the copy layer, only {} features in the paste layer were processed!".format(i))
break
if i+1 < len(data):
print("You selected too many features in the copy layer, {} features were not copied!".format(len(data)-i-1)) Note that both layers will be processed in order of OBJECTID. So the attributes of the copy feature with the lowest OID will be pasted to the paste feature with the lowest OID.
... View more
09-11-2023
02:44 AM
|
1
|
15
|
1507
|
POST
|
you actually do want to assign this rule to a field. The field parameter controls in which field the output of the expression is stored. An edit to any field will trigger the rule. your variable names are very misleading. related_inspections is actually the Structure feature class! if you have a relationship class, you can use FeaturesetByRelationshipName() instead of filtering the Featureset yourself your for loop treats the Featureset like an array. For arrays, the loop counter (i) is an integer. For Featuresets, it is the current feature. So your indexing doesn't work, because i is a Feature, not a number. You're trying to return an Array, but the rule expects a single value. Something like this should work: // Calculation Attribute Rule on hte inspection table
// field: StructureType
// triggers: Insert, Update
// depending on how you create your inspection record, it won't be able to find the parent feature on Insert, so you should also trigger on Update
// optional: abort if there is already a value in the field
if(!IsEmpty($feature.StructureType)) { return $feature.StructureType }
// get the parent feature
var parent = First(FeaturesetByRelationshipName($feature, "Structure_StructureInspection"))
// if a parent feature was found, return its StructureType, else return a default value
return IIf(parent == null, "no parent found", parent.StructureType)
... View more
09-11-2023
02:19 AM
|
1
|
1
|
467
|
POST
|
I don't think so. Attachments in AGOL/Portal aren't stored as joinable table. Instead, each attachment has its own url: "portal/rest/services/ServiceName/FeatureServer/LayerID/FeatureOID/attachments/AttachmentID" For example: "https://services.arcgis.com/xxxyyyzzz/arcgis/rest/services/TestService/FeatureServer/1/5/attachments/5" Things I tried: I haven't found a way to use that url in the symbology. The picture marker layer expects the actual byte data, not a path to the data. I tried calculating a BLOB field with the Arcade Attachments() function, but that doesn't return the actual data. I tried doing the join and symbology in Pro before publishing, but "in-memory joins are not supported" I tried including the attachment table in the feature service, but it got removed when I published I tried to publish the attachment table as standalone service, but I got the "Staging failed" error and don't want to spend too much time here... I think this is your best bet though, assuming you can publish the attachment table, you could then do the join.
... View more
09-11-2023
01:45 AM
|
1
|
1
|
3648
|
POST
|
fc = "TestPolygons" # path the the feature class or name of the layer
field = "IntegerField1"
group_field = "TextField1"
# read the fc
data = [row for row in arcpy.da.SearchCursor(fc, [group_field, field])]
# iterate over the groups
groups = {d[0] for d in data}
for g in sorted(groups):
# get the values in that group
values = {d[1] for d in data if d[0] == g}
# get a set of the complete range
complete_values = set(range(min(values), max(values)))
# the difference between these sets are the missing numbers
missing_values = complete_values - values
print("Missing values in group {}: {}".format(g, sorted(missing_values)))
... View more
09-11-2023
12:29 AM
|
1
|
1
|
1296
|
POST
|
Run this in the Python Window (change the first three lines): fc = "TestPolygons" # path to the feature class or name of the layer
field = "TextField1" # field you want to edit
sql = "Subtype = 'FOSC'" # select the features you want to edit
import string
letters = list(string.ascii_uppercase)
letters.remove("I")
letters.remove("O")
with arcpy.da.UpdateCursor(fc, field, sql) as cursor:
for i, row in enumerate(cursor):
letter = letters[int(i/1000)]
number = i % 1000
new_id = "SPLCNV1{}{:03}".format(letter, number)
cursor.updateRow([new_id]) This will fail after Z999!
... View more
09-08-2023
11:48 PM
|
2
|
0
|
618
|
POST
|
The script is meant to be run in the Python Window, not in the Fieled Calculator. Open the ArcMap Python Window Copy/Paste the script into the window Change the first two lines Execute by pressing Enter (may have to press it twice)
... View more
09-08-2023
11:25 PM
|
1
|
3
|
1342
|
POST
|
You can do it with a little Python script: fc = "TestPolygons" # path the the feature class or name of the layer
field = "IntegerField1"
# get a set of values in the field
values = {row[0] for row in arcpy.da.SearchCursor(fc, [field])}
# get a set of the complete range
complete_values = set(range(min(values), max(values)))
# the difference between these sets are the missing numbers
missing_values = complete_values - values
print(sorted(missing_values))
... View more
09-08-2023
02:30 AM
|
3
|
6
|
1377
|
POST
|
So what exactly is the problem? Feature isn't created Feature is created (there is a row in the attribute table), but without geometry An error occurs (error message?) Something other First thing I'd check id that your Park_ID can actually be found in the National_parks.CODE field. If not, the rule will abort in line 12.
... View more
09-08-2023
02:19 AM
|
0
|
2
|
505
|
POST
|
As I understand it, they aren't updating the triggering feature. They are copying the new value of $feature.asst_info into the polygon fc. Name, Type, and Code in lines 48-50 are attributes of the polygon fc, not the triggering feature. They are superfluously set to the values that are already in there, probably a relic from copy/pasting that piece of code from the insert block.
... View more
09-06-2023
10:12 AM
|
0
|
0
|
453
|
POST
|
Arcade indeed doesn't recognize the Shape field. Geometry() uses the whole feature. For that to work, you need to load the park geometries. // line 13
var polygFS = FeatureSetByName($datastore, "National_parks", ["*"], true)
// line 21
"geometry": Geometry(polygFilter), You don't need to supply the GlobalID for inserts (line 20).
... View more
09-05-2023
11:19 PM
|
0
|
0
|
481
|
POST
|
You can accomplish that with the arcpy.da.*Cursor classes: copy_layer = "Layer A"
copy_fields = ["columns1", "column2", "column3"]
paste_layer = "Layer B"
paste_fields = ["column3", "column4", "column5"]
# read the first copy feature
data = [row for row in arcpy.da.SearchCursor(copy_layer, copy_fields)][0]
# paste the copy feature's data into each paste feature
with arcpy.da.UpdateCursor(paste_layer, paste_fields) as cursor:
for row in cursor:
cursor.updateRow(data)
... View more
09-05-2023
12:28 PM
|
4
|
21
|
1824
|
POST
|
You're splitting hasAB, which is a boolean value. You want to split the actual field value of AsbUilts. You're checking for array size greater than one, so at least two numbers. You probably want to check for greater than zero. You're using splitAB[1], which is the second element of the array (Arcade [and most other programming languages] uses zero-based indexes). If there is only one element in the array, the expression will fail. Your url looks weird. I think it has to be formatted like http://bla/browse.aspx?parameter=number&otherparameter=value This expression will return a semicolon-separated list of urls (if applicable). It will return a default message for empty fields, and it will return the field value if it is not a number. var ab = $feature.AsBuilts
if(IsEmpty(ab)) { return "No as-built found" }
var urls = []
var ab_split = Split(ab, ",")
for(var i in ab_split) {
var n = Number(Trim(ab_split[i]))
if(IsNaN(n)) {
Push(urls, ab_split[i]) // if the value is not a number, just use the value
} else {
Push(urls, `http://documentmanager/browse.aspx?searchParams=${n}&moreSearchParams`)
}
}
return Concatenate(urls, ";") Alternatives: replace line 10 with continue, this will skip all non-numeric values add this before the return to give an error message: if(Count(urls) == 0) { return "No numeric as-built found" } Only return the first url: replace line 16 with this (and add the count check from above) return urls[0] I haven't tested it, but I don't think this will return clickable links for multiple as-builts. You would have to use an Arcade element (not an expression) in a popup for that.
... View more
09-05-2023
10:47 AM
|
0
|
0
|
1139
|
POST
|
tl;dr: return When(
Adresstatus == "Gehistoreerd", null,
IsEmpty(Busnummer), Huisnummer,
!IsEmpty(Busnummer), `<UND>${Huisnummer}</UND>`,
"Default value"
) A few pointers: return + something is not valid syntax. return something is. More info on return. = is for assignment (this variable now has this value), == is for comparison (does this variable have this value?) More info on operators. You can append multiple string values (what you tried with the <u>), but you have to actually make them strings using quotation marks, and you have to either add them ("<UND>" + Huisnummer + "</UND>") or use template literals, which I did above. Label formatting tags are not the same as HTML tags. For chained if-then blocks, you can use the When function.
... View more
09-05-2023
02:54 AM
|
2
|
0
|
687
|
POST
|
You can do something like this: var types = Split($feature.TextField1, ",")
if(Count(types) > 1) { return `multiple, ${$feature.TextField2}` }
return `${types[0]}, ${$feature.TextField2}` This will return "multiple, size" when there are multiple cart types present. Alternatives: delete line 2, now it will return the first cart type for carts with multiple types use return "multiple" in line 2, now you have a single entry that you can switch off in the legend
... View more
09-02-2023
12:32 AM
|
0
|
0
|
901
|
POST
|
Create another expression: return IIF($feature.Field == xxxxx, 'none', 'block') Use the output of that expression in the div's "display" style: <div style="display:{expression/expr2};background-color:{expression/expr0};color:#FFFFFF;padding:7px;text-align:center;">
<span style="font-size:medium;">{expression/expr1}</span>
</div> For features with the specified value, this will hide (display:none) the div.
... View more
09-01-2023
12:45 AM
|
1
|
0
|
960
|
Title | Kudos | Posted |
---|---|---|
1 | 08-16-2023 10:19 AM | |
1 | 05-24-2023 08:15 AM | |
1 | 08-31-2021 11:11 PM | |
1 | 02-16-2023 11:38 PM | |
1 | 08-29-2022 01:47 AM |
Online Status |
Offline
|
Date Last Visited |
02-03-2024
06:14 PM
|