|
POST
|
You're halfway there. You're using the count of the intersection between your point $feature and the polygons, which is always 1 (assuming no overlapping polygons). When you got your polygon feature, you have to intersect that again with the point fc to get the point count: // get intersecting polygons
var intersectMUN = Intersects(FeatureSetbyName($datastore,"BajaCalifornia"), $feature);
// get the first polygon or return null
var firstMUN = First(intersectMUN)
if(firstMUN == null) { return null }
// get the points intersecting the polygon
var intersectPoints = Intersects(FeatureSetByName($datastore, "POINTS"), firstMUN);
// return "PolygonID - PointCount"
return (firstMUN.CVE_MUN) + " - " + Count(intersectPoints);
... View more
05-17-2022
01:17 AM
|
1
|
1
|
2215
|
|
POST
|
I have to move my Enterprise GDB to a new server (both Microsoft SQL). In the old database, I used traditional versioning and had archiving enabled. In the new database, I switched to branch versioning. I would like to port my old archives. I could copy the Database.DataOwner.Table_H tables to the new database, but this way, the old archive and the data would be separated and I would clutter my pristine workspace. So I want to copy the rows of the old archive tables into the new tables. As I see it, the field mapping would be New branch versioned table Old archive table GDB_FROM_DATE GDB_FROM_DATE GDB_IS_DELETE 1 (the current entries are already there, so only copy rows where GDB_TO_DATE < '9999-12-31') GDB_DELETED_AT GDB_TO_DATE GDB_DELETED_BY last_editor GDB_BRANCH_ID ??? My questions are: Is this reasonable or a stupid idea? What would the value for GDB_BRANCH_ID be? -1? Can I access the versioning fields with arcpy? arcpy.ListFields() and arcpy.da.*Cursor() don't expose them. Do you have any other advice?
... View more
05-12-2022
05:32 AM
|
0
|
0
|
789
|
|
IDEA
|
Related idea: Add Arcade Globals for Visualization/Symbology Exe... - Esri Community And from there (highlighting by me): There are no plans to extend the labeling or visualization profiles to include FeatureSet functionality for performance reasons. Label and visualization expressions are executed on a per-feature basis and a feature set query executed per-feature would slow down draw performance. For this use-case the recommendation is to use a calculate attribute rule where the script is executed at data creation or update time rather than once per draw loop. FeatureSetByName can be used to perform FeatureSet lookups with any other dataset in the same workspace. Cross-database cases are not currently possible but an idea to support that for future workflows could be submitted for conversation.
... View more
05-12-2022
02:27 AM
|
0
|
0
|
3872
|
|
POST
|
Ah, so you're dealing with numbers too big for Arcade. But is there any other better way to achieve this? If you have a constant part in your ID that doesn't change, you could remove that, convert the rest to number (hopefully smaller than 16 digits) and increase, then concatenate back. If the whole ID is a number, then you probably will have to split it up. This isn't super easy, though, because you have to take care of a few things: if the last part is "9", you can't just change it to "10" and concatenate wrong: "1239" + 1 --> "12310". right: "1239" + 1 --> "1240" if a part starts with "0", you will have to add that back in wrong: "00123" + 1 --> "124" right: "00123" + 1 --> "00124" I came up with this: function increase (txt) {
// split text into parts
// part_length has to be smaller than 16
var txt_length = Count(txt)
var part_length = 15
var parts = []
for(var i = 0; i < txt_length; i += part_length) {
Push(parts, Mid(txt, i, part_length))
}
for(var i = Count(parts) - 1; i >= 0; i -= 1) {
// add 1 to the last element
var old_part = parts[i]
var new_part = Text(Number(old_part) + 1)
parts[i] = new_part
if(Count(new_part) < Count(old_part)) {
// New_part is shorter (eg "000" -> "1")
// add padding and break the loop
var diff = Count(old_part) - Count(new_part)
for(var j = 0; j < diff; j += 1) {
parts[i] = "0" + parts[i]
}
break
}
if(Count(new_part) == Count(old_part) || i == 0) {
// the part's length did not change or this is the first element
// we're done, break the loop
break
}
if(Count(new_part) > Count(old_part)) {
// New_part is longer (eg "999" -> "1000")
// remove the first digit and continue the loop
parts[i] = Mid(new_part, 1, part_length)
continue
}
}
return Concatenate(parts)
} This is pretty long, maybe it can be done in a simpler way... function test(txt) {
Console(txt +"\n" + increase(txt) + "\n")
}
test("00000")
test("98")
test("99")
test("1234567890123456789012345678901234567890") // 40 digits!
test("9999999999999999999999999999999999999999")
test("10000000000000000000000000000000000000000") 00000
00001
98
99
99
100
1234567890123456789012345678901234567890
1234567890123456789012345678901234567891
9999999999999999999999999999999999999999
10000000000000000000000000000000000000000
10000000000000000000000000000000000000000
10000000000000000000000000000000000000001
... View more
05-12-2022
02:07 AM
|
1
|
1
|
1628
|
|
POST
|
# HouseNumber
!SITUS_1!.split(" ")[0]
# PrefixDirection
!SITUS_1!.split(" ")[1]
# StreetName
!SITUS_1!.split(" ")[2]
# Street Type
!SITUS_1!.split(" ")[3]
# FullStreetName is a little different: split by space, take everything except the first element (the house number) and join by space
" ".join(!SITUS_1!.split(" ")[1:])
... View more
05-11-2022
08:09 AM
|
1
|
1
|
2812
|
|
POST
|
Oops, missed a dot in my answer, I edited it. !SITUS_1!.split(" ")[0]
... View more
05-11-2022
07:56 AM
|
1
|
2
|
2824
|
|
POST
|
If the format is the same for each address, it's really easy. You can do it with the field calculator: # field calculation for HouseNumber
# Python
!FullStreetName!.split(" ")[0]
# other fields are analogous, just use different indexes Or you can do it all at once with an UpdateCursor: with arcpy.da.UpdateCursor("AdressLayer", ["SITUS_1", "HouseNumber", "FullStreetName", "PrefixDirection", "StreetName", "SuffixType"]) as cursor:
for row in cursor:
situs = row[0]
number, dir, name, type = situs.split(" ")
full_name = " ".join([dir, name, type])
new_row = [situs, number, full_name, dir, name, type]
cursor.updateRow(new_row)
... View more
05-11-2022
07:17 AM
|
1
|
4
|
2840
|
|
POST
|
Purely symbology based: Format Line Symbol, Add Marker symbol layer Format the markers to be placed at extremities Profit You can also add a second marker layer and format the marker layers to show at the start and end extremities, then symbolize them differently. eg start points as dots, end points as open circles:
... View more
05-11-2022
02:32 AM
|
3
|
1
|
2667
|
|
POST
|
Nothing built-in (that I know of). Off the top of my head, I see two possibilities: Python window Write a Python statement like below, copy it to a text file on your desktop/some other easy location. At the start of your session, you just have to paste it once into the Python window, then you can always use the up arrow to repeatedly call it. Select a polygon, run that command (switch to Python window, up arrow, enter), profit. # too lazy to test...
arcpy.management.SelectLayerByLocation("LineLayer", "INTERSECT", "GridLayer", selection_type="NEW_SELECTION") Relationship class and Attribute Rule To use the relationship class behavior (automatically select all related records), you could create a relationship and assign an Attribute Rule to the lines that triggers on Insert and Update and stores the ID of the intersecting grid polygon in the feature. This way, you could do it automatically. But a line intersecting multiple polygons would only get selected by one of those. The rule would be something like this // too lazy to test...
if($editcontext.editType == "UPDATE" && Equals(Geometry($feature), Geometry($originalfeature)) {
return
}
var polygons = FeatureSetByName($datastore, "Polygons", ["PrimaryKey"], true)
polygons = Intersects($feature, polygons)
// find the polygon with the greatest intersection with $feature
var max_length = 0
var poly_pk = null
for(var p in polygons) {
var intersect_line = Intersection(p, $feature)
if(Length(intersect_line) > max_length) {
max_length = Length(intersect_line)
poly_pk = p.PrimaryKey
}
}
return poly_pk
... View more
05-10-2022
09:42 AM
|
0
|
0
|
1035
|
|
POST
|
You're halfway there! The FeatureSetBy*() functions return feature sets, collection of features. You have to select 1 of those features (often the first one) and return 1 of its attributes. // load all related features
var related_features = FeatureSetByRelationshipName($feature, "SepticLocations", ["inspect_freq"], false)
// select one of those features, here we just grab the first one
var related_feature = First(related_features)
// if there are no related features, related_feature will be null and we will
// get an error down the line, so we need to check that and return early
if(related_feature == null) {
return null // if there are no related features, we return a default value (null in this case)
}
// return an attribute
return related_feature.inspect_freq
... View more
05-09-2022
10:50 PM
|
3
|
2
|
3422
|
|
POST
|
Hmmm, it seems to work: Can you give an example of original values where it doesn't return the correct value? Can you post the whole code, maybe your problem is in another part?
... View more
05-09-2022
10:36 PM
|
0
|
3
|
1668
|
|
POST
|
I'm building an Experience for internal use in our department. The feature services I consume in the maps are not public, but I do have public services (with reduced attributes) for some themes. I would like to show my colleagues a list of those services in the Experience, so that they can easily send external people to the correct links. Of course, I could just paste the links to the services into the Experience. But for purely optical reasons, I want to show the service's metadata, too (thumbnail, owner, last update, views, maybe buttons to open in MapViewer etc). I can do that by embedding the URL to the content of the folder in our portal that contains the public services, like I did in the screenshot with the Living Atlas: But now I have the Portal navigation bars in there, and I don't want that. Most of my colleagues are completely GIS-illiterate, they don't know and don't care about any other services or the Portal in general (and that's completely OK). I can hide the navigation bar by giving a background color to the text widget and positioning it above the Embed widget: This works and I will use it if there isn't a better way, but it feels (and is) really hacky. So, my question is: Is there a clean way to show summaries of services (thumbnail, owner, refresh date, number of views, short description) in an Experience?
... View more
05-09-2022
07:13 AM
|
0
|
0
|
631
|
|
POST
|
Yes. # for loop to loop through each "group_extent" polygon in turn and create shadow polygons
with arcpy.da.SearchCursor(group_extent,['SHAPE@', 'GroupRef', 'Species', 'MaxHeight']) as cursor:
groupCount = 0
for shp, groupRef, species, maxHeight in cursor:
# variables
memFC = "memory/FC"
shadowRas = "shadowRas"
shadowPnts = "memory\shadowPnts"
shadowPntsJoined = "memory\shadowPntsJoined"
# copy the current feature into a memory feature class
arcpy.management.CreateFeatureclass("memory", "FC", "POLYGON", spatial_reference=shp.spatialReference)
arcpy.management.AddField(memFC, "ValueField", "FLOAT")
with arcpy.da.InsertCursor(memFC, ["SHAPE@", "ValueField"]) as icursor:
icursor.insertRow([shp, maxHeight])
# polygon to raster
arcpy.conversion.PolygonToRaster(memFC, "ValueField", shadowRas, "CELL_CENTER", "NONE", cellsize, "DO_NOT_BUILD")
... View more
05-09-2022
02:11 AM
|
0
|
0
|
6091
|
|
POST
|
Huh, seems you can't truncate tables in memory, because you're not the data owner... arcpy.management.DeleteRows(memory_table) works, though.
... View more
05-09-2022
01:50 AM
|
0
|
0
|
6105
|
| 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
|