|
POST
|
This is probably more what you want. I assume you aren't looking for an attribute of "value". Also, I am not sure if the square brackets are needed.
where = "[survey_month] = " + value
arcpy.MakeFeatureLayer_management(inFC, lyrname, where)
... View more
03-05-2012
09:50 AM
|
0
|
0
|
2171
|
|
POST
|
For joined tables you still have to use the getVaue statement I am fairly certain. cur = arcpy.SearchCursor(layer)
for row in cur:
row.getValue("JoinedTableName.FieldName")
... View more
03-05-2012
09:35 AM
|
0
|
0
|
662
|
|
POST
|
You definitely have some issues here. It is not entirely clear what you are trying to do here. What field(s) are you trying to query? Are your species list your field names or are those attributes? This line needs the raw tag. arcpy.env.workspace = r"P:\CoWetlandTools\maps\distribution_maps_Johns_pytest" #"r" at beginning of path string specieslist needs to be outside your for loop. This will error out just on that. You need + signs to concatenate your strings in your where clause and format for the brackets. Also, this is assuming "X" is your field name, this is very likely incorrect.
where = "X in ('" + '\',\''.join(specieslist) + "')"
Also, it will help posting in [ CODE] [ /CODE] tags to see your indentation. The # sign at the top when posting.
... View more
02-29-2012
01:21 PM
|
0
|
0
|
1529
|
|
POST
|
You were very close, just a few workspace issues (you need to change the workspace to the actual .xlsx file to access the sheet, then back to the folder level to export the table and create the shapefile) and a couple small things. Give this a try, changing to your paths of course. import arcpy, os, sys, traceback
arcpy.env.workspace = r"C:\GIS\xlsxTest"
outPath = r"C:\GIS\xlsxTest\output"
arcpy.env.overwriteOutput = True
# Local variables
xVal = "POINT_X"
yVal = "POINT_Y"
# Factory code for NAD 1983
factory_code_CS = 4269
sr = arcpy.SpatialReference()
sr.factoryCode = factory_code_CS
sr.create()
# List all files in folder then list all tables in file
fileList = arcpy.ListFiles("*.xlsx")
print 'Listing .xlsx files in workspace'
try:
# Loop through each file
for file in fileList:
print file
arcpy.env.workspace = os.path.join(r"C:\GIS\xlsxTest", file)
# Use splitext to set the output name of the table
dbfFile = os.path.splitext(file)[0] #+ ".xlsx"
if arcpy.Exists(dbfFile+".dbf"):
print "deleting"
arcpy.Delete_management(dbfFile+".dbf")
# Convert excel to DBF
arcpy.TableToTable_conversion("Sheet1$", outPath, dbfFile+ ".dbf")
print 'File conversion. Converted ' + file
#List dBase tables
arcpy.env.workspace = outPath
tableList = arcpy.ListTables("", "dBASE")
print ' List dBase tables in workspace'
# Loop through each table
for table in tableList:
print table
# Make XY event layer
arcpy.MakeXYEventLayer_management(table, xVal, yVal, "points_" + table, sr)
# Save output
arcpy.FeatureClassToShapefile_conversion("points_"+table, outPath)
print 'Created XY shp file for ' + table
print 'Script complete.'
except:
tb = sys.exc_info()[2]
tbinfo = traceback.format_tb(tb)[0]
pymsg = "PYTHON ERRORS:\nTraceback Info:\n" + tbinfo + "\nError Info:\n " + str(sys.exc_type) + ": " + str(sys.exc_value) + "\n"
msgs = "ARCPY ERRORS:\n" + arcpy.GetMessages(2) + "\n"
arcpy.AddError(msgs)
arcpy.AddError(pymsg)
print msgs
print pymsg
arcpy.AddMessage(arcpy.GetMessages(1))
print arcpy.GetMessages(1)
... View more
02-29-2012
06:17 AM
|
0
|
0
|
1062
|
|
POST
|
Posting what code you are using might help. You can query by multiple fields in your where clause in the select by attributes tool.
... View more
02-29-2012
05:27 AM
|
0
|
0
|
1529
|
|
POST
|
You can start by removing the print workspace line unless you have that variable set somewhere else.
... View more
02-28-2012
04:56 AM
|
0
|
0
|
730
|
|
POST
|
It worked fine for me from IDLE. Have you tried it using different mxds?
... View more
02-27-2012
12:38 PM
|
0
|
0
|
826
|
|
POST
|
I had thought there would be some behind the curtain voodoo that could be accessed to go directly to the CustomTransformations folder, since whenever you use the Project tool with valid parameters the custom transformation will come up as an option. So somewhere out there is a CustomTransformation folder variable, but I guess it isn't accessible.
... View more
02-23-2012
11:44 AM
|
0
|
0
|
1246
|
|
POST
|
So you want to clip one polygon layer based on say priority = 1 of your other polygon layer, or clip based on each possible priority in the feature class? Yes you can do that. Make a feature layer with a where clause of the features you want to clip Clip Enclose in a for loop if you want to do different where clauses base on variable values.
... View more
02-23-2012
05:06 AM
|
0
|
0
|
440
|
|
POST
|
Does anyone know of a way to dynamically find the ArcGIS profile directory without having to code each in explicitly with an if/else? Specifically, I am trying to access the Custom Transformations folder. For example, I have 9.3.1 on Windows XP or 10.0 on Windows 7 and test doing something like the following if windows[0] == "6": trans_dir = os.getenv("USERPROFILE") +os.sep+ r"AppData\Roaming\ESRI\Desktop10.0\ArcToolbox\CustomTransformations" elif windows[0] == "5": trans_dir = os.getenv("USERPROFILE") +os.sep+ r"Application Data\ESRI\ArcToolbox\CustomTransformations" But also may run into situations where there is 9.3.1 on Windows 7, or 10.0 on Windows XP. Putting each possibility in seems rather sloppy. Is there a cleaner way to go about this?
... View more
02-22-2012
09:50 AM
|
0
|
5
|
1365
|
|
POST
|
If you are asking about pyscripter and arcpy, yes it is by default. Any module imported in the script has intellisense enabled, without having to actually import the module via the built in interpreter. No license is checked out in the case of arcpy. [ATTACH=CONFIG]12107[/ATTACH]
... View more
02-21-2012
01:35 PM
|
0
|
0
|
1977
|
|
POST
|
You can look at pyscripter, it has intellisense enabled by default without the need for a license. I find it far superior to PythonWin for my purposes, but to each their own. http://code.google.com/p/pyscripter/
... View more
02-21-2012
06:34 AM
|
0
|
0
|
1977
|
|
POST
|
I think you need to tell it your field variable is a field. Something along these lines. And you should be using Python too. arcpy.CalculateField_management(table, fieldnew, "!"+field+"!", "PYTHON", "")
... View more
02-15-2012
09:25 AM
|
0
|
0
|
2232
|
|
POST
|
Hate to barge in on a good conversation, but it looks like you are missing an update in your update cursor.
for row in uC:
if row.getValue(keyField) in updateDict:
row.setValue(testField1, updateDict[key][0])
row.setValue(testField2, updateDict[key][1])
row.setValue(testField3, updateDict[key][2])
row.setValue(testField4, updateDict[key][3])
row.setValue(testField5, updateDict[key][4])
row.setValue(testField6, updateDict[key][5])
uC.updateRow(row)
... View more
02-15-2012
04:28 AM
|
0
|
0
|
1885
|
| 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
|