|
POST
|
Something like this? var Num = Text($feature.Num)
var txt1
var txt2
if(Count(Num) == 10) {
// if 10 digit run this
txt1 = Left(Num, Count(Num)-6)
txt2 = Right(Num, Count(Num)-4)
} else {
// if 9 digit run this
txt1 = Left(Num, Count(Num)-5)
txt2 = Right(Num, Count(Num)-4)
}
return "https://rec-search.Yoyo/find/search.asp?dfYear="+ txt1 + "&dfDocumentStart=" + txt2 Seems like you're always using the 4 left digits and the 4 right digits. Why not just do this? var Num = Text($feature.Num)
var txt1 = Left(Num, 4)
var txt2 = Right(Num, 4)
return url = "https://rec-search.Yoyo/find/search.asp?dfYear="+ txt1 + "&dfDocumentStart=" + txt2
... View more
06-17-2021
01:17 AM
|
0
|
1
|
1278
|
|
POST
|
If I understood your problem correctly, you have 3 tables / feature classes: the parcels, the address points and a standalone table containing the pdf paths. If that is correct, then the code I posted is the way to do it. If you can get the pdf paths into the address points (join), it would be easier: var addresspoints = Intersects(
$feature,
FeatureSetByName($map,"Addresses (GIS)", ["FullAddress", "PdfPath"])
);
var cnt = Count(addresspoints);
var counter = (cnt-(cnt - 1))
if(cnt == 0) {
return "No addresses found for this parcel"
}
address_info = cnt + " Address(es):";
for (var address in addresspoints) {
var pdf_path = ""
if(!IsEmpty(address.PdfPath)) {
pdf_path = "; PDF: " + address.PdfPath
}
var address_text = (counter++) + ". " + address.FullAddress + pdf_path
address_info += TextFormatting.NewLine + address_text;
}
return address_info; Find is for finding sub-strings in strings. It won't help you with feature sets.
... View more
06-17-2021
12:44 AM
|
0
|
2
|
5236
|
|
POST
|
For ArcGIS Pro: Create an empty group layer and save it, then run this: empty_group_layer_file = arcpy.mp.LayerFile(r"H:\New Group Layer.lyrx")
active_map = arcpy.mp.ArcGISProject("current").activeMap
# In this example, I'll use a dict of {group_layer_name: [layers]} as input. Adjust according to your existing code.
group_layers = {
"Group Layer 1": [layer_1, layer_2],
"Group Layer 2": [layer_3, layer_4],
}
for group_name, layers in group_layers.items():
group = active_map.addLayer(empty_group_layer_file)[0]
group.name = group_name
for lyr in layers:
active_map.addLayerToGroup(group, lyr)
... View more
06-16-2021
12:38 AM
|
2
|
3
|
10802
|
|
POST
|
# you're checking and changing fields, not row!
# if you do this, it should work:
for row in cursor:
is_urban = row[0] > 3
cursor.updateRow([row[0], is_urban])
# even shorter:
for row in cursor:
cursor.updateRow([row[0], row[0] > 3]) # Also: you can replace lines 6 to 16 with this
try:
arcpy.management.DeleteField(fc, "isUrban")
except:
pass
arcpy.management.AddField(fc, "isUrban", "INTEGER")
... View more
06-14-2021
07:15 AM
|
1
|
1
|
1765
|
|
POST
|
Something like this? var addresspoints = Intersects(
$feature,
FeatureSetByName($map,"Addresses (GIS)", ["FullAddress"])
);
var cnt = Count(addresspoints);
// exit early, this removes the need for the else block
var counter = (cnt-(cnt - 1))
if(cnt == 0) {
return "No addresses found for this parcel"
}
// load the pdf table. you need at least the Path field and the field linking
// this table to your address points. I used FullAddress here, if it's
// some other field, you will have to include that in addresspoints, too.
var pdf_table = FeatureSetByName($map, "PDF", ["FullAddress", "Path"])
address_info = cnt + " Address(es):";
for (var address in addresspoints) {
// filter your pdf table
var key = address.FullAddress // or use your key field here
var pdf_row = First(Filter(pdf_table, "FullAddress = @key")) // or use your key field here
// if a pdf was found, display the path after the full address
var pdf_path = ""
if(!(pdf_row == null || IsEmpty(pdf_row))) {
pdf_path = "; PDF: " + pdf_row.Path
}
var address_text = (counter++) + ". " + address.FullAddress + pdf_path
address_info += TextFormatting.NewLine + address_text;
}
return address_info;
... View more
06-14-2021
05:17 AM
|
1
|
4
|
5260
|
|
POST
|
Interesting problem... No tools that I know of for both cases. You'd have to author them yourself with Python. Case 1: First thing that came to mind (completely untested): def parallel_length_between_lines(line, reference_line, distance=None, tolerance=None):
"""Returns a list of the lengths of the line segments that run parallel to reference_line.
The retuned lengths are the lengths of the intersection of line and
a buffer around reference_line. A more correct way would be to
deconstruct the lines into segments (split at vertices) and then
to compare the bearings of those segments. But that would be far more
computationally intense and far more difficult to program (I think).
line & reference_line: arcpy.Polyline
distance: the distance between the lines (the size of the buffer), optional
tolerance: relative tolerance by which distance is multiplied (used to fake small variations in the distance as "parallel"), optional
"""
# calculate distance
if not distance:
distance = line.distanceTo(reference_line)
if not tolerance:
tolerance = 0.001
distance *= 1 + abs(tolerance)
# create buffer
buffer = reference_line.buffer(distance)
# line and buffer do not intersect ? -> 0
if line.disjoint(buffer):
return 0
# intersect line and buffer
segment = line.intersect(buffer, 2)
# return segment length
# if line is "wavy" compared to reference_line (goes in and out of the buffer), segment will be multipart. Here, I return a list of the singlepart segment lengths, but you could also return the sum or the biggest part
segment_lengths = [arcpy.Polyline(segment[p]).length for p in range(segment.partCount)]
return segment_lengths You would then have to apply this function to each line feature in your red feature class, comparing them to the nearest (?) line feature in the purple feature class. Case 2: Sounds like a **bleep**-ton of math. Maybe arcpy.edit.Generalize could be a start?
... View more
06-11-2021
06:29 AM
|
1
|
1
|
3178
|
|
POST
|
Glad to help! Yeah, attribute rules (and Arcade in other instances, like popups, field calculation, advanced symbology and labels) can be pretty powerful, and they're still adding stuff to it. But you have to learn the language, it certainly helps if you have experience in other programming/script languages. You kinda jumped in at the deep end, here. There's a reason the blog is titled "Advanced Attribute Rules" 🙂 In case you haven't found it yet: The Arcace Guide and the Function Reference are great resources.
... View more
06-11-2021
04:48 AM
|
0
|
0
|
2320
|
|
POST
|
There is no function that does that. I don't think this is possible at all. Attribute rules work on the database level, and the database exists completely independent from any ArcGIS Project.
... View more
06-11-2021
03:37 AM
|
1
|
1
|
1294
|
|
POST
|
A field of a table can have an alias (alternative name) that is different from its real name. You can use this to make field names more readable in the table view, e.g. using spaces in the name. The arcpy cursors use SQL in the background. SQL doesn't work with alias names, only with the real ones. Using alias names in the cursor may cause the error you experience. So if in your example "speed100m" (or another field in liste) is not the real name of the field, that might be the problem. You can check by doing the ExtractMultiVBaluesToPoints in the python window in ArcGIS or with the toolbox and then looking at the table's fields. Or, you can print all field names: arcpy.sa.ExtractMultiValuesToPoint(.....)
print([f.name for f in arcpy.ListFields("in_memory/resultats_table")]) Some further tips: for field in liste:
with arcpy.da.UpdateCursor("in_memory/resultats_table", [field]) as cursor:
for row in cursor:
if row[0] is None: # this is wrong in your code!
pass
else:
# row[0] = round(...)
# this won't work. row is a tuple, you can't change a tuple's elements.
# do this instead:
cursor.updateRow([round(row[0], 2)])
# instead of the check for None, you could do this:
for field in liste:
with arcpy.da.UpdateCursor("in_memory/resultats_table", [field], "{} IS NOT NULL".format(field)) as cursor:
for row in cursor:
cursor.updateRow([round(row[0], 2)])
... View more
06-11-2021
03:31 AM
|
0
|
3
|
9739
|
|
POST
|
Please check that the variable field contains the actual field name and not an alias. # from your code above:
liste = ["speed100m"]
# each element of liste has to be an actual field name, not an alias!
... View more
06-11-2021
01:20 AM
|
0
|
5
|
9748
|
|
POST
|
// get point type from polygon type
var polygon_type = $feature.PolygonFC_type
var point_type = ""
if(polygon_type == "Liftschacht") { point_type = "Lift" }
if(polygon_type == "ABC") { point_type = "DEF" }
if(polygon_type == "UVW") { point_type = "XYZ" }
// centroid
// return point_type as attribute in the newly created point
return {
"result": $feature.field,
"edit": [
{
"className" : "g**m.i***************t",
"adds" : [
{
"attributes": {
"R****ID": $feature.globalid,
"PointFC_Type": point_type
// other fields
},
"geometry": centroidFeatureR****e
}
]
}
]
}
... View more
06-11-2021
12:00 AM
|
1
|
0
|
2327
|
|
IDEA
|
Ah, now I get it... can confirm that changing the symbology WORKS when running the script outside of ArcGIS (e.g. executing it in IDLE) running the script in ArcGIS in the python window (either by copy/pasting or by importing the script) changing the symbology DOES NOT WORK when running the script as script tool
... View more
06-10-2021
02:08 AM
|
0
|
0
|
2607
|
|
IDEA
|
Updated the code in my comment above: Now it also finds relationship classes in feature datasets, and it returns a list of dicts instead of the old describe objects, so it's easier to read the output. Not sure if this covers some of what you're looking for: import os, pprint
all_rs = listRelationshipClasses("path/to/your/database.sde") # see above
pprint.pprint(all_rs[0])
# filter by name
rs = [r for r in all_rs if r["name"] == "FilterName"]
rs = [r for r in all_rs if "PartOfTheName" in rs["name"]]
# filter by cardinality
rs = [r for r in all_rs if r["cardinality"] == "OneToOne"]
# filter by origin or destination table
rs = [r for r in all_rs if "OriginTableName" in r["originClassNames"]]
rs = [r for r in all_rs if "DestinationTableName" in r["destinationClassNames"]]
rs = [r for r in all_rs if "OriginTableName" in r["originClassNames"] and "DestinationTableName" in r["destinationClassNames"]]
# filter by dataset
rs = [r for r in all_rs if os.path.basename(r["path"]) == "DatasetName"]
# filter by flags
rs = [r for r in all_rs if r["isComposite"]]
rs = [r for r in all_rs if not r["isComposite"]]
# other flags: isAttachmentRelationship, isAttributed, isReflexive, isVersioned, canVersion, changeTracked
... View more
06-10-2021
12:56 AM
|
0
|
0
|
3558
|
|
IDEA
|
good, idea, upvoted. in the meantime, you can do this: def listRelationshipClasses(database):
"""Returns a list of dictionaries describing the relationship classes inside the given database.
Tested with SDE and FGDB
database: str, path to the database
"""
desc = arcpy.da.Describe(database)
parents = [desc] + [c for c in desc["children"] if c["dataElementType"] == "DEFeatureDataset"]
rs = []
for p in parents:
rs += [c for c in p["children"] if c["dataElementType"] == "DERelationshipClass"]
return rs
listRelationshipClasses("Path\to\your\database.gdb")
listRelationshipClasses("Path\to\your\database.sde")
... View more
06-09-2021
07:22 AM
|
0
|
0
|
3573
|
|
IDEA
|
Is this what you want? import os
import arcpy
aprx = arcpy.mp.ArcGISProject("path\to\your\project.aprx")
active_map = aprx.listMaps("MapName")[0]
lyr_directory = "..."
for lyr in active_map.listLayers():
# etc
aprx.save() Also, you could rewrite your code like this: symbol_layers = {
"Parcel_Buffer": "Parcel_Buffer_ArcGISPro.lyrx",
"Parcel_Selection": "Selected_Parcel_ArcGISPro.lyrx",
# ...
}
for lyr in active_map.listLayers():
try:
sym = os.path.join(lyr_directory, symbol_layers[lyr.name])
arcpy.management.ApplySymbologyFromLayer(lyr, sym)
except KeyError:
print("No symbol file for layer {}".format(lyr.name))
... View more
06-09-2021
07:02 AM
|
0
|
0
|
2620
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 03-05-2023 12:46 PM | |
| 1 | 12-07-2022 07:01 AM | |
| 1 | 06-21-2022 08:27 AM | |
| 1 | 09-18-2023 04:55 AM | |
| 1 | 11-07-2022 11:15 PM |
| Online Status |
Offline
|
| Date Last Visited |
02-03-2024
06:14 PM
|