|
POST
|
Define a dictionary that relates the string part of the id to the corresponding counter: duplicates = {"GLEDRHQF": 3}
def get_duplicate_counter(value):
try:
counter = duplicates[value] + 1
except KeyError:
counter = 1
duplicates[value] = counter
return counter
# or directly return the complete id:
# return "{}{:02d}".format(value, counter)
... View more
05-11-2021
12:46 AM
|
1
|
0
|
3178
|
|
POST
|
Thanks for the explanation Joshua, really appreciate it.
... View more
05-02-2021
10:41 PM
|
0
|
0
|
2930
|
|
POST
|
Ignoring for a moment that it works on other platforms, it sounds like it doesn't find related data because the relating field (TrafficSignID in my example code above) is empty. Try this simple constraint rule to throw an error when you try to insert a new TrafficSignWorkOrder without a TrafficSignID: if(IsEmpty($feature.TrafficSignID)) {
return false
}
return true
... View more
04-29-2021
12:20 AM
|
0
|
1
|
1183
|
|
POST
|
Try querying the TrafficSigns yourself: var trafficSignID = $feature.TrafficSignID
var trafficSigns = FeatureSetByName($datastore, "SDE.OWNER.TrafficSigns", ['TrafficSignID', 'AssetID'], false)
var relatedTrafficSigns = Filter(trafficSigns, 'TrafficSignID = @trafficSignID')
if(Count(relatedTrafficSigns) == 0) {
return 'nothing'
}
return First(relatedTrafficSigns).AssetID
... View more
04-27-2021
10:47 PM
|
0
|
0
|
1191
|
|
POST
|
Sadly, I can't suggest anything further than recreating the index. You probably should post that as a new question.
... View more
04-25-2021
10:30 PM
|
0
|
0
|
1034
|
|
POST
|
Use the tool Buffer. https://pro.arcgis.com/en/pro-app/latest/tool-reference/analysis/buffer.htm For buffer distance, use a negative value (in your case -10 meters). If you want to get the area where building is allowed, use Side Type "Full". If you want to get the area where building is prohibited, use Side Type "Exclude the input polygon from buffer".
... View more
04-23-2021
04:53 AM
|
1
|
2
|
1104
|
|
POST
|
To be fair, "current" works. # this works, too
aprx = arcpy.mp.ArcGISProject('CuRrEnT')
... View more
04-23-2021
01:28 AM
|
0
|
0
|
753
|
|
POST
|
Pretty much, yeah. I added a whole bunch of comments in the original code, hopefully that makes it clearer.
... View more
04-22-2021
06:16 AM
|
1
|
1
|
3789
|
|
POST
|
It looks like you can't do this directly in the symbology settings. You'd need the $datastore or $map global to do an Intersect, and they are not available in the Visualization profile. I'd create a new field and an Attribute Rule: // field: ShowFeature, numeric
// triggers: insert (not update!)
// This rule checks whether a new feature is at the same location as other
// features in the same feature class. If so, it edits the field ShowFeature
// for those other features to be 0. For the feature itself, that field will
// be set to 1.
// In your map, you can then hide the features where ShowFeature = 0, either
// via a definition query or via the symbology settings. This way, if there
// are multiple feature in the same location, only the most recently added
// feature is shown.
// Get a reference to the feature class the new feature belongs to.
var fs = FeatureSetByName($datastore, "database.owner.class", ["GlobalID"], true)
// Intersect the new feture with the whole feature class.
// Here "features in the same location" means "at that exact point".
// If you want to check for "features at a certain distance around the new
// feature", you should do this instead:
// var inter = Intersects(fs, Buffer($feature, 10, "meters"))
var inter = Intersects(fs, $feature)
// You will find at least 1 intersecting feature (the new feature itself).
// If there is exactly 1 intersecting feature, that means that there are no
// other features in the same location. Just return ShowFeature = 1.
if(Count(inter) == 1) {
return 1
}
// If you get here, there are multiple features in the same location.
// For the older features (the ones that aren't $feature), you want to
// set ShowFeature = 0.
var updates = []
for(var fi in inter) {
// Check if the currently tested feature (fi) ist the newly added one
// ($feature). We do that here by comparing GlobalIDs.
if(fi["GlobalID"] != $feature["GlobalID"]) {
// If fi is not the new feature, we want to hide it
updates[Count(updates)] = {"globalID": fi["GlobalID"], "attributes": {"ShowFeature": 0}}
}
}
// Now we return the result.
// We set $feature.ShowFeature to 1 ("result": 1).
// And we edit all intersecting features in the same feature class
// with the update array we filled above.
return {
"result": 1,
"edit": [{
"className": "owner.class",
"updates": updates
}]
} Then, you can hide the features where ShowFeature = 0, either with a query or in the symbology.
... View more
04-22-2021
01:38 AM
|
1
|
3
|
3802
|
|
POST
|
Yeah, the cursor.updateRow was the most confusing thing. Is this behavior specific to UpdateCursor/all arcpy.da.*Cursors? Or is this the expected behavior, that the child iterators are independent from each other, but not from the parent / the parent not from them?
... View more
04-21-2021
07:19 AM
|
0
|
0
|
2996
|
|
IDEA
|
I agree, canceling should be possible. As a workaround, you could just apply the sketch and then use the Reshape or Continue Feature tools.
... View more
04-21-2021
12:28 AM
|
0
|
0
|
859
|
|
POST
|
Didn't know about itertools.tee, seems cool but honestly a little confusing. I'd have done that by storing the previous value in a variable.
... View more
04-20-2021
10:10 PM
|
0
|
0
|
3005
|
|
POST
|
# The error is thrown by this line:
vDict[Row[0]]=Row[1] # Dict[id] =Frequency
# You only use one field (Frequency) in your cursor, so Row is a list with only one entry. Personally, I hate using field calculator to calculate values based on multiple rows. I'd rather use pure Python: # extract all rows and sort by ID
# data = [ [ID, Freq], [ID, Freq], ... ]
data = [row for row in arcpy.da.SearchCursor("Test", ["ID", "Frequency"])]
data.sort(key = lambda d: d[0])
# do the calculation
for i in range(len(data)):
try:
value = data[i][1] / data[i+1][1]
except:
# instead of catching all exceptions, you could also just catch the ones you expect:
# last element will raise IndexError
# Freq == NULL will raise TypeError
# Freq == 0 will raise ZeroDivisionError
value = -1
data[i].append(value)
# convert data into a lookup dictionary
# data = {ID: value, ID: value, ...}
data = {d[0]: d[2] for d in data}
# write the results into the table
with arcpy.da.UpdateCursor("Test", ["ID", "ValueField"]) as cursor:
for id, value in cursor:
try:
new_value = data[id]
except KeyError:
new_value = -1
cursor.updateRow([id, new_value])
... View more
04-20-2021
06:13 AM
|
1
|
0
|
3027
|
|
POST
|
The only way I can think of is the really painful one of exporting all the images and reattaching them to the Point FC. See this thread .
... View more
04-20-2021
12:37 AM
|
0
|
1
|
818
|
| 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
|