POST
|
I'm going to try it now, though part of my initial concern was that I don't know how to use the FieldMapping objects that the join tools require. I guess I will have to learn, and I will attempt to do the regular Spatial Join as well, as it seems that does the job as well (at least it does in ArcGIS Pro without any Python scripting). I will let you know which I find is faster for the large datasets I am looking at.
... View more
02-03-2020
10:25 AM
|
0
|
0
|
475
|
POST
|
Just to understand a little bit better: the process you are suggesting would be to run the Find Identical tool, output only the duplicates, run the nested Search/UpdateCursor loop that I proposed on the output, and then join that table back to the original using the FID field?
... View more
02-03-2020
08:52 AM
|
0
|
2
|
475
|
POST
|
Hello, I have a conceptual question that I am trying to figure out fast and efficient methods for coding in arcpy / Python. Given: I have a geometry dataset with attributes, and some of this geometry is identical in shape, but not in attribute. Objective: I'd like to identify the geometrically identical features, usually a pair, and then transfer an attribute from one feature to the other within that pair. To wit, in the below image: There are two geometrically identical lines between points B / E, though they may possess differing attributes in one specific field. I'd like to keep all existing attributes in each line, but also add the attributes in that specific field from each of the lines to the other into a newly created field. Method A: One way I've determined to do this is through the use of UpdateCursors, as in the code snippet below: fieldNames = ['GROUPID', 'ATTRB_1', 'DUPL_ATTRB', 'SHAPE@']
with arcpy.da.UpdateCursor(inputfc, fieldNames) as aList:
for a in aList:
with arcpy.da.UpdateCursor(inputfc, fieldNames) as bList:
for b in bList:
if a[0] != b[0] and a[-1] == b[-1]:
a[2] = b[1]
b[2] = a[1]
bList.updateRow(b)
aList.updateRow(a)
del a, aList, b, bList Here, the existing attribute that will remain for each feature is "ATTRB_1," and there is a new field created called "DUPL_ATTRB" where the geometric twin would thus transfer its attribute (ATTRB_1). But I am finding that this method takes a lot of time, especially for large datasets with upwards of tens of thousands (>10,000) of features. Other methods? I know this can be done with a SpatialJoin and some fieldMapping, but I'm having trouble understanding how to properly build the fieldMapping object to do this. However, I feel that the SpatialJoin may be significantly faster than the nested UpdateCursor method that was my initial attempt. Are there other methods that can be done to achieve this same goal more quickly and efficiently? Thanks in advance,
... View more
01-31-2020
04:07 PM
|
0
|
4
|
562
|
POST
|
Also, I'm interested in how you're timing the functions. Can you tell me more about how to measure the time it takes to run not just one command, but my entire script?
... View more
01-23-2020
09:16 AM
|
0
|
1
|
651
|
POST
|
I am a beginner, and the following question will show why. I am trying to extract one value from a layer that has only one feature in it, but the only way I know how to do it takes three lines of code. There must be a better way, right? See the below code that I am using, and excuse the ignorance. # pull some attributes from the isolated feature
with arcpy.da.SearchCursor(fcTemp, 'ATTR') as pulllist:
for pull in pulllist:
var = pull[0]
... View more
01-22-2020
11:02 PM
|
0
|
9
|
783
|
POST
|
Yes, that appears to be the issue. I assumed that by specifying the fields as '*', all fields and geometry would be passed in. I was able to make the code snippet work by specifically passing through the 'SHAPE@' field. The revised code as you wrote it works. Thank you both so much.
... View more
01-21-2020
12:19 PM
|
0
|
1
|
612
|
POST
|
Yes, I am starting to see. So a row is not a feature layer, and therefore can't be passed into the SelectLayerByLocation too. What can I do to test each point in a feature layer like I want to?
... View more
01-21-2020
11:59 AM
|
0
|
3
|
612
|
POST
|
Hi, I am getting an error when I try and run this code, but can't figure out why. Is there something I am missing? Thanks, resultCoT = 'A'
with arcpy.da.SearchCursor(inputpoints, '*') as pointList:
for point in pointList:
countTest = arcpy.SelectLayerByLocation_management(inputlines, "INTERSECT", point, "", "NEW_SELECTION")
with arcpy.da.SearchCursor(countTest, '*') as lineList:
for line in linelist:
if line[0] == 'PROPERTY':
count = count + 1
if count == 2:
resultCoT = 'B'
print(resultCoT) The error I get at the SelectLayerByLocation tool line is: RuntimeError: Object: Error in executing tool Shows you how little I know. . .
... View more
01-21-2020
11:40 AM
|
0
|
5
|
674
|
POST
|
My initial featureclass was composed of lines--so even if I selected one and intersected it with itself, I get three resultant lines: say A was the initial selection, lines B and D would seemingly be the resultant for a self-intersect. I've adopted Dan's suggestion to further break down the lines into points via the Feature Vertices to Points and then looping through the points to test intersections, which seems to provide the results I want (a point intersection between two lines, where I can then do logical operators to determine if the two lines I want to test indeed have a point intersection). I was hoping to avoid creating extra featureclass for which to test geometries against, but I don't know of a way to do that. I wish there was a way you could loop through a featureclass with a cursor and test each feature geometry against other features in that same feature class.
... View more
01-21-2020
08:28 AM
|
0
|
1
|
1263
|
POST
|
For instance, I am trying to test whether any two of the four lines in one feature class intersect at a point. In the image below, A & B do meet at a point, whereas A & C do not, and I would like to figure out how to test that relationship and determine the point, if possible.
... View more
01-20-2020
06:48 PM
|
0
|
7
|
1263
|
POST
|
Right, I knew my original question was vague. Basically, what I am trying to do is determine whether or not two lines in any given polyline are touching/meeting at the ends: for instance, in a four-sided rectangle (say a tax lot in a cadastral map), if the lines meet at a point or if they do not (such as if they were on opposite sides of the rectangle). I'm not sure if intersect is the right relationship, or if there is another relationship description that is more appropriate. Whenever I intersect (arcpy.Intersect_analysis()) the feature class with itself, I always get all of the lines, when what I am looking for is a point output that represents the specific location of the intersection of those two lines, if they do intersect; or nothing, if they do not. I've had good luck using cursors in place of other geospatial processing functions, and wonder if they would be appropriate here as well, I just don't quite know how to properly declare the objects in advance and then step through the featureclasses with the cursor to test the spatial relationships against the other features in the same class. Any help or code snippets would be helpful for me to learn, as I am just starting to get a grasp of the different objects/classes and their methods.
... View more
01-20-2020
06:44 PM
|
0
|
8
|
1263
|
POST
|
Hi, I need to compare two features in the same feature class. I'd like to test to see if they intersect. Specifically, I have a feature set composed of lines, and I'd like to know if any given two are intersecting. What is a quick and easy way to do this?
... View more
01-20-2020
03:59 PM
|
0
|
11
|
1596
|
POST
|
Hi, I am trying to search through a dataset to find a certain value in a certain field in order to update another field in that same row, but I can't quite seem to make the code snippet work. Can somebody tell me what I'm doing wrong? The below code completes just fine but returns nothing. import arcpy
arcpy.env.workspace = r"C:\Users\paperspace\Google Drive\QTA\19010_PDX Zoning\PDXZoning\PDX_Kerns.gdb"
fieldNames = ['TLID', 'RNO']
tlidList = arcpy.da.SearchCursor("taxlots_Kerns", fieldNames)
for tlids in tlidList:
string = "*-STR*"
if tlids[1] == string:
print(tlids) I can't tell if I'm using the wildcard incorrectly, the comparison incorrectly, or if there's something else I'm doing wrong. Thanks,
... View more
01-15-2020
01:33 PM
|
0
|
3
|
542
|
POST
|
Ah, yes, that makes sense. I knew it was something simple. Thank you.
... View more
01-15-2020
01:15 PM
|
0
|
1
|
1669
|
Title | Kudos | Posted |
---|---|---|
1 | 01-23-2020 08:28 AM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|