|
POST
|
You could use DeleteFeatures_management ("bnd_lyr") at the end of your loop. http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//001700000036000000.htm That should just remove your feature layer each time.
... View more
05-05-2011
07:59 AM
|
0
|
0
|
999
|
|
POST
|
Just to be clear, you are talking about the PythonWin Trace Collector Debugging Tool, not the Python Debugger right? Have you tried both? If you are having problems with debugging without even using the geoprocessor module then it sounds more like a general problem with your environment and PythonWin. I don't think I will be able to help much. You should try e-mailing python-help@python.org they are a great resource for technical python related problems. FYI, I run the exact same setup, Windows 7 64-bit Arc10 SP1, running PythonWin 214 with Python 2.6.5 and haven't seen any issues with the PythonWin debugger. So there should be some solution out there for you. If something simple like this can't run in the debugger for you then I'm out of ideas, sorry. import win32traceutil
x = 0
xlist = list()
while x <= 10:
x += 1
xlist.append(x)
print xlist
print "done"
... View more
05-04-2011
05:24 AM
|
0
|
0
|
1014
|
|
POST
|
You want to describe your features and access the shapeType property. This sample will give you a place to start.
import arcpy
arcpy.env.workspace = #your workspace
fcList = arcpy.ListFeatureClasses()
drop_features = list()
for feature in fcList:
desc = arcpy.Describe(feature)
if desc.shapeType == 'Polygon':
drop_features.append(feature)
for feat in drop_features:
arcpy.Delete_management(feat)
You can also do away with the drop_features list if you want and just put the deletion where you would add the feature to the drop feature list.
... View more
05-03-2011
10:35 AM
|
0
|
0
|
995
|
|
POST
|
What build of PythonWin are you using? 214 works fine for me. I would try removing and reinstalling PythonWin with the latest build if you haven't already. Also, is PythonWin using 2.6.5 to run your code?
... View more
05-03-2011
10:21 AM
|
0
|
0
|
1014
|
|
POST
|
You get this error when you try to run a script or when you try to just open PythonWin? Does the IDLE work? Edit: Oh you just get it when trying to run through the debugger using win32traceutil? Did you try on just a simple print "Hello World" program?
... View more
05-03-2011
08:31 AM
|
0
|
0
|
1014
|
|
POST
|
You need to make a list of your datasets and loop through them. I don't think python will be able to recognize multiple inputs through one copy tool. Something like this.
sde1 = #your source connection
sde2 = #your output connection
arcpy.env.workspace = sde1
datasetList = [dataset1, dataset2,...]
for dataset in datasetList:
arcpy.Copy_management(dataset, sde2+dataset)
If you want to get ALL the datasets from an SDE GDB then you can also just do datasetList = arcpy.ListDatasets("", "Feature")
... View more
05-03-2011
07:22 AM
|
0
|
0
|
676
|
|
POST
|
For joining tables you need to have unqualified field names to stop the changing of the field names. arcpy.QualifiedFieldNames = "UNQUALIFIED" Generally when I join I use the below code. arcpy.JoinField_management(table1, field1, table2, field2) This makes the join permanent, if you just want temporary joins then use the AddJoin. *Edit: When you join tables with unqualified names, any duplicate names will have "_1" added to the end to make them unique. This usually comes up in the fields the join is based on, which usually have the same name. At least in my environment. Also, using field mappings may solve your problems as they give specific field names as the output, but I find them more trouble than the time they save. *Edit2: Oh sorry, see http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//001w00000008000000.htm Syntax is arcpy.env.qualifiedFieldNames = qualified_field_names unless you have from arcpy import env
... View more
05-03-2011
06:52 AM
|
0
|
0
|
555
|
|
POST
|
If you are getting a 210 error there is a problem with your write access to your target. I would test for a schema lock on your target feature class. Versioning might be an issue also depending on the setup of your database and your privileges.
... View more
04-21-2011
06:46 AM
|
0
|
0
|
834
|
|
POST
|
You can check this out for more information. http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//002z0000000z000000.htm As far as I know, to run a script on a server you will need an ArcGIS Server license available to that machine.
... View more
04-18-2011
05:42 AM
|
0
|
0
|
1103
|
|
POST
|
Did you try these steps? http://help.arcgis.com/EN/ARCGISDESKTOP/10.0/HELP/index.html#//00vp0000000n000210.htm Does the file name already exist?
... View more
04-12-2011
07:35 AM
|
0
|
0
|
513
|
|
POST
|
In terms of tracking your script, I like putting print functions in loops (as long as they aren't too large) to tell me what it is doing. Something simple under your if statement, such as
if file.endswith(".mxd"):
print file
... If you want to get real creative, you can get a count of all your mxds first with a similar loop. Keep a count of the number of mxds converted after the datasource as been successfully changed, divide that value by the total count of mxds, round it to the nearest integer, and print every X value, eg 10 percent, 20 percent etc There is probably an easier way to do that, I've never had occasion to do something of that sort.
... View more
04-11-2011
12:23 PM
|
0
|
0
|
1723
|
|
POST
|
I have something like this. import arcpy
Acount = 0
Bcount = 0
Ccount = 0
rows = arcpy.UpdateCursor("mydata", "", "", "OID; Type; Type_Num", "OID A")
for row in rows:
if row.Type == 'A':
Acount = Acount+1
row.Type_Num = Acount
elif row.Type == 'B':
Bcount = Bcount+1
row.Type_Num = Bcount
elif row.Type == 'C':
Ccount = Ccount+1
row.Type_Num = Ccount
rows.updateRow(row)
del row
del rows
... View more
04-11-2011
12:10 PM
|
0
|
0
|
720
|
|
POST
|
This is a cursor I use to find dates.
fc = # Feature Class with date field
field = "DateField"
rows = arcpy.SearchCursor(fc, field+" = date '2011-02-22'")
... Using times I think would be something like. I haven't had the opportunity to test this though. rows = arcpy.SearchCursor(fc, field+" = date '2011-02-22 00:00:00'") For HH:MM:SS. In terms of when to use what brackets etc, this link has some good info on syntax using different data types. http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00s500000033000000.htm
... View more
04-11-2011
10:23 AM
|
0
|
0
|
596
|
|
POST
|
Oh sorry, names are required for the replaceDataSource method. replaceDataSource (workspace_path, workspace_type, dataset_name, {validate}) Also, testing for support helps too. And are you sure the name of the layer ends in .shp? Those are the TOC names you are testing on, not dataSource names. Try something like this.
for lyr in arcpy.mapping.ListLayers(mxd):
if lyr.supports("DATASOURCE") and lyr.supports("DATASETNAME") and lyr.supports("NAME"):
if lyr.name == "OR_She_Dist1.shp":
lyr.replaceDataSource("C:/Rafiq_GIS/PYTHONTESTING/2011/2011_CountyComm/Data/Orange", "SHAPEFILE_WORKSPACE, "OR_She_Dist2.shp")
This help page has all the required info http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Layer/00s300000008000000/
... View more
04-11-2011
10:04 AM
|
0
|
0
|
664
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 05-17-2011 10:36 AM | |
| 1 | 08-16-2012 10:48 AM | |
| 1 | 10-31-2012 08:39 AM | |
| 1 | 07-16-2012 01:52 PM | |
| 1 | 03-15-2012 10:57 AM |
| Online Status |
Offline
|
| Date Last Visited |
08-22-2024
11:12 PM
|