I would like to write a script in Python which takes data and does some things with it.
So far, I have written the following code :
import arcpy
arcpy.env.workspace = "C:\wody.gdb"
arcpy.env.overwriteOutput = True
fcList = arcpy.ListFeatureClasses()
bufferList = []
for fc in fcList:
if fc == "RZEKI":
arcpy.Buffer_analysis(fc, fc + "Buffer", "200 meters")
bufferList.append(fc + "Buffer")
Now, I would like to take RIVERS (RZEKI) only if river is longer than SOMETHING (they do not give data in meters but in units, so I just want to see an example seems like river_long > WHATEVER)
1 Answer 1
This is a pretty basic Select By Attribute query. I would suggest reading up on the documentation.
This is taken right from the example in the online help:
# Within selected features, further select only those cities which have a population > 10,000
arcpy.SelectLayerByAttribute_management("lyr", "SUBSET_SELECTION", ' "population" > 10000 ')
As far as calculating length, the help article A quick tour of Python will give you the code to calculate the length of the feature in the source units of the layer. Take a look at:
!shape.length!