POST
|
I am trying to identify features that occurred within a time frame of a feature with a certain field value. So if Point_Type = 1, I want to identify all features that took place within six hours of this feature. I have a date/time field for all features. I'm not real familiar with the time module in python, but I assume that module would have something to do with it. Does anyone know of a bit of code that would help me identify these features? Thanks! Tommy Burk
... View more
02-06-2012
05:45 AM
|
0
|
1
|
692
|
POST
|
Bruce, That did exactly what I needed. Thanks! Tommy Burk
... View more
01-31-2012
05:17 AM
|
0
|
0
|
420
|
POST
|
Mark, This is great. It's exactly what I want to do. I am unfamiliar with how to add/drop a flag item to/from the table. Can you give me a quick example of how that works? Thanks! Tommy Burk
... View more
01-31-2012
04:31 AM
|
0
|
0
|
420
|
POST
|
I have a bit of python code that compares consecutive row values in a field. If the first feature's field value is 1 and the second feature's field value is 2, it prints "Different." If they are both 1, it prints "Same." I want to take the features that read "Different" and shoot those out to a new feature class. I know there's a way to do this in python, but I can't seem to come up with it. My list script is as follows: IdList[]
rows = arcpy.SearchCursor("INPUT FEATURE CLASS")
for row in rows:
IdPlusOne = int(row.FIELD) + int(1)
IdList.append(IdPlusOne)
del row, rows
i = 0
i1 = 1
for Id in IdList:
if i1 >= len(IdList):
break
elif Id == IdList[i1]:
arcpy.AddMessage("Same")
i+=1
i1+=1
else:
arcpy.AddMessage("Different")
i+=1
i1+=1 So I would just like to have those rows that get listed as "Different" to be exported to a new feature class. Is this doable? Thanks so much for any assistance. Tommy Burk
... View more
01-31-2012
01:58 AM
|
0
|
0
|
420
|
POST
|
I have a bit of python code that compares consecutive row values in a field. If the first feature's field value is 1 and the second feature's field value is 2, it prints "Different." If they are both 1, it prints "Same." I want to take the features that read "Different" and shoot those out to a new feature class. I know there's a way to do this in python, but I can't seem to come up with it. My list script is as follows: IdList[] rows = arcpy.SearchCursor("INPUT FEATURE CLASS") for row in rows: IdPlusOne = int(row.FIELD) + int(1) IdList.append(IdPlusOne) del row, rows i = 0 i1 = 1 for Id in IdList: if i1 >= len(IdList): break elif Id == IdList[i1]: arcpy.AddMessage("Same") i+=1 i1+=1 else: arcpy.AddMessage("Different") i+=1 i1+=1 So I would just like to have those rows that get listed as "Different" to be exported to a new feature class. Is this doable? Thanks so much for any assistance. Tommy Burk
... View more
01-31-2012
01:56 AM
|
0
|
7
|
757
|
POST
|
Mathew, Rafael, I really appreciate your assistance with this. The final output ended up looking something like this: IdList = [] rows = arcpy.SearchCursor("INPUT_FILE") for row in rows: IdPlusOne = int(row.ID_FIELD) + int(1) IdList.append(IdPlusOne) del row, rows arcpy.MakeFeatureLayer_management("FC SELECTING FROM", "layer_lyr") i = 0 for Id in IdList: if IdList == 0: arcpy.SelectLayerByAttribute_management("layer_lyr", "NEW_SELECTION", "\"ID_FIELD\" = " + str(IdList)) i+=1 elif IdList >= 1: arcpy.SelectLayerByAttribute_management("layer_lyr", "ADD_TO_SELECTION", "\"ID_FIELD\" = " + str(IdList)) i+=1 arcpy.CopyFeatures_management("layer_lyr", "NEW_FEATURE_CLASS") This allowed me to create a list from a previous feature class, scroll through that feature class and list the values in an ID field, create a selection based on the list with 1 added to every value (which allows me to select the next row based on a consecutive ID field), and create new feature class from the new selection. I then merged the previous feature class and the new feature class to create a feature class the contains the original features in the list, and each following feature. I hope that's not too confusing. Nevertheless, it worked. Thanks again. You both were very helpful. Tommy Burk
... View more
01-27-2012
02:22 AM
|
0
|
0
|
461
|
POST
|
Thanks again. That gave me the list +1 which is perfect. Now I want to do a selection from a feature class that goes something like from FIELD in the feature class select values in the LIST. where_clause = "FIELD = LIST" Is that possible? Is there a special way I have to format the clause? After exporting from model builder, it looks like the format would be something like "\"ID_Field\" = List". Thanks so much. Tommy Burk
... View more
01-26-2012
06:49 AM
|
0
|
0
|
461
|
POST
|
Hi Rafael, Thanks for your response. The script you gave me does what I want. It prints the values of the OBJECTID field. Can I make this something that I can reference now? I want to use the OBJECTID field in one feature class to create a query to in another class. Essentially I want to do a OBJECTID +1 and use that statement to create a selection in another feature class. I originally thought a list would do it, because then I could call that list again.....Thanks again for your help! Tommy Burk
... View more
01-26-2012
04:02 AM
|
0
|
0
|
461
|
POST
|
Is there a way to list values in a field using python? I can list the field names or the field types in a certain feature class, but I want to list the actual values associated with the field. Is this possible? Thanks. Tommy Burk
... View more
01-26-2012
02:56 AM
|
0
|
8
|
616
|
POST
|
Hey Andrew, Thanks for your response. I think I did a poor job of explaining what I am trying to do. I have a feature class that is sorted by a date/time field. The earliest date is first. I have then run a datediff tool to determine the difference in time (in hours) and populated a field (hours) to show the difference in hours between features. I want to select the features that have less than 6 hours between them, which I can do. This allows me to get a starting point. I then want to include in that selection the next feature below that, so the next feature in the table, which will allow me to have an end point. I am having trouble figuring out how to create query for this second group of features I would like to select because the hours field is difference between the next row and not the previous row. Name Date/Time Hours Feature 1 Jan 23/9AM 0 Feature 2 Jan 23/12PM 3 Feature 3 Jan 24/6AM 18 Feature 4 Jan 24/12PM 6 Feature 5 Jan 25/6PM 30 Feature 6 Jan 27/6PM 48 So I can select feature 1, 2, and 4, but I also want to select feature 3, simply based on the fact that it's following feature 2, which I already selected. My assumption is that feature 2 and feature 3 are the starting and ending point of an event. I also want to select feature 5 (the end point), because I have feature 4 (the start point) selected. Feature 6 will not be in the selection because it is not a starting point (hour < 6) and does not follow a point where hour < 6. I am hoping that this will allow me to create a feature class that will include the starting and ending points of certain events. I apologize. I hope this makes sense. I'm trying to learn python on the fly. Thanks again for any help you can provide. Tommy Burk
... View more
01-25-2012
09:21 AM
|
0
|
0
|
261
|
POST
|
I am trying to find a piece of python code that will select consecutive rows in a feature class. I want to select all features in a feature class where a field is less than 6 (Hours < 6). I can do this part. I then want to select the next feature below each of those that are less than 6, no matter what it's field value is, so I can get a start and end point. I have tried using the search cursor, but I'm not real familiar with how it works. Is there a bit of code that would accomplish what I'm trying to do? Thanks for any help! Tommy Burk
... View more
01-25-2012
05:23 AM
|
0
|
3
|
1759
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|