POST
|
Thank you for your remarks. I think, using a list could solve the problem. The CopyFeature function obviously doesn't work with searchCursor objects. But finally I simply used the Select function and created a loop for the SQL expression. This script works fine now and copies each row of my input feature class to a separate file: # Set local variables
in_features = "cities_mexico"
searchCursor = arcpy.SearchCursor(in_features)
row = searchCursor.next()
for i in range(36):
cityName = row.CITY_NAME
# create output path name
out_feature_class = os.path.join(env.workspace, cityName)
where_clause = '"OBJECTID"='+str(i+1)
# Execute Select
arcpy.Select_analysis(in_features, out_feature_class, where_clause)
row = searchCursor.next()
... View more
03-23-2011
02:27 PM
|
0
|
0
|
172
|
POST
|
Thank you for your remarks. I think, using a list could indeed solve the problem. The CopyFeature function obviously doesn't work with the searchCursor object. But finally I just used the Select function and created a loop for the SQL expression. This script works fine now and copies each row of my feature class to a new seperate file: # Set local variables
in_features = "cities_mexico"
searchCursor = arcpy.SearchCursor(in_features)
row = searchCursor.next()
for i in range(36):
cityName = row.CITY_NAME
# create output path name
out_feature_class = os.path.join(env.workspace, cityName)
where_clause = '"OBJECTID"='+str(i+1)
# Execute Select
arcpy.Select_analysis(in_features, out_feature_class, where_clause)
row = searchCursor.next()
... View more
03-23-2011
02:20 PM
|
0
|
0
|
172
|
POST
|
Hi, I tried to write a small scritp which copies each row of a feature class to a new file. I wanted to use the CopyFeatures function to create the new files, but when I run the modul I get this error message back: AttributeError: 'NoneType' object has no attribute 'CopyFeatures_management' I am not sure what the problem exactly is and how to solve it. Any suggestions? This is the code I wrote:
# Import arcpy module
import arcpy
from arcpy import env
import os
env.workspace = r"C:\ArcGIS\Mexico.gdb"
# Load required toolboxes
arcpy.ImportToolbox("C:\Programme\ArcGIS\Desktop10.0\ArcToolbox\Toolboxes\Data Management Tools.tbx")
# Local variables:
cities_mexico = "cities_mexico"
searchCursor = arcpy.SearchCursor(cities_mexico)
row = searchCursor.next()
while row <> None:
# Process: Copy Features
outFeature = os.path.join(env.workspace, row.CITY_NAME)
print outFeature
arcpy.CopyFeatures_management(row, outFeature)
... View more
03-22-2011
06:42 AM
|
0
|
3
|
728
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|