|
POST
|
Another "export" tool is the CopyFeatures_management() tool - it's probably the export method I use the most since it only exports the selected features to a new FC. There is no SQL parameter like the Select_analysis() tool. Rather it uses the current selection set that was created by SelectByAttributes, SelectByLocation, or some other "selecty-type" tool.
... View more
02-23-2012
09:48 AM
|
0
|
0
|
908
|
|
POST
|
How about: arcpy.GetSystemEnvironment("APPDATA") or os.getenv("APPDATA") and then sort out the ESRI\Desktop10.0\ArcToolbox\CustomTransformations or ESRI\ArcToolbox\CustomTransformations using arcpy.GetInstallInfo("DESKTOP")['Version'] or gp.GetInstallInfo("DESKTOP")['Version']
... View more
02-22-2012
11:32 AM
|
0
|
0
|
1426
|
|
POST
|
To be more explicit, you could use the .GetInstallInfo method. Something like: try: installInfoDict = arcpy.GetInstallInfo("DESKTOP") except: installInfoDict = gp.getinstallinfo("DESKTOP") if installInfoDict['Version'] == '10.0': do this elif if installInfoDict['Version'] == '9.3': do that else: do someting completely different
... View more
02-22-2012
09:30 AM
|
0
|
0
|
1206
|
|
POST
|
I didn't test this code, but it should work something like: searchRows = arcpy.SearchCursor(myFC)
for searchRow in searchRow:
myIdValue = searchRow.MY_FIELD_NAME
outRaster = r"C:\temp\test_" + str(myIdValue)
arcpy.MakeFeatureLayer_management(myFC, "fl", "MY_FIELD_NAME = " + str(myIdValue))
arcpy.Clip_management(inputRaster, "", outRaster, "fl", "", "ClippingGeometry")
... View more
02-22-2012
05:42 AM
|
0
|
0
|
1109
|
|
POST
|
How about: import arcpy
myOutputTable = r"C:\temp\test.gdb\input"
for i in range(1,1001):
myOutputTable = r"C:\temp\test.gdb\table_id_" + str(i)
arcpy.TableSelect_analysis(myInputTable, myOutputTable, "MY_ID = " + str(i))
... View more
02-21-2012
03:17 PM
|
0
|
0
|
2092
|
|
POST
|
Ocasionally you might encounder a feature that is too small to be included in the ZonalStatistics layer - for example, a parcel that is smaller than a pixel or perhaps just happends to not in the center of the pixel. In that case, you can convert these features that "didn't make it" to points (use the FeatureToPoint tool), and then get the coresponding Slope value using the Sample tool in Spatial Analyst.
... View more
02-15-2012
01:09 PM
|
0
|
0
|
8240
|
|
POST
|
This: arcpy.CalculateField_management(table, fieldnew, "["+field.name+"]", "VB", "") is equavalent to this: arcpy.CalculateField_management(table, fieldnew, "!"+field.name+"!", "PYTHON", "") unless 'table' is actually a feature layer or table view that contains a join. In that case, you can only use the "VB" syntax with the square brackets.
... View more
02-15-2012
01:00 PM
|
0
|
0
|
2440
|
|
POST
|
Use the .zfill() method: >>> test = "1"
>>> test.zfill(10)
'0000000001'
>>>
... View more
02-14-2012
02:54 PM
|
0
|
0
|
3663
|
|
POST
|
I believe the draw order by default is controlled by the order of records in the attribute table - based on decending order of the OBJECTID field. So for example, a feature with OBJECTID = 20 will potentially obscure OBJECTID = 19 if they overlap. Using the Sort tool (new in v10.0) you can create a new feature class that is sorted however you want (SHAPE_Length, ACRES, YEAR, etc). If you are using v9.x, you might find this script handly: http://forums.esri.com/Thread.asp?c=93&f=1729&t=298702#933185, which also sorts tables or FCs. Also, if you are just concerned with display, I know there is a property under the Symbology Tab > Advanced > Symbol Levels that can control the order in which features are drawn. If you are interested in a more quantitative way to deal with overlapping features, this script (or some of the code behind it) might help you: http://arcscripts.esri.com/details.asp?dbid=16700. Google tells me another guy doing fire history stuff went so far as to use it in his masters thesis: repository.lib.ncsu.edu/dr/bitstream/1840.4/.../KetchieChris+final.pdf - what a brave guy!
... View more
02-14-2012
02:12 PM
|
0
|
0
|
1077
|
|
POST
|
Glad it worked! A request for you: Many of us have an interest in seeing this forum also serve as a sort of a code/algorithm library... That said, it sounds like the statistic you are calculating is some sort of "maximum angle" statistic. If so, would you mind posting your code? Even if not, it sounds interesting, and I bet a lot of people would find it useful. If not, that's okay too.
... View more
02-14-2012
07:06 AM
|
0
|
0
|
4470
|
|
POST
|
1. The CopyRows tool will export a raster attribute table to any "ESRI-approved" table format (.dbf, .mdb., .gdb, SDE, INFO, etc.) Unfortunatly, tab and comma delimited text format tables are not in that list! You would need to write your own thing to do that via Python (pretty easy to do), or download someone elses toolbox/code... Maybe a toolbox/python code such as http://arcscripts.esri.com/details.asp?dbid=13692? Curious that you can do a right click and "Export As" in ArcMap/ArcCatalog and export to a txt format (tab delimited BTW). However, there doesn't seem to be a tool in ArcToolbox that can accomplish this amazing feat... 2. Do you mean append to the table? Again, if you use one of the ESRI-appropved table formats, the Append tool works just great. There doesn't appear to be a way to do this "out of the box" however if you are using a txt fomat table though! A good resource for basic file reading/writting in Python: http://docs.python.org/tutorial/inputoutput.html A good resource for more "precise" csv file writting: http://docs.python.org/library/csv.html Here's some basic code I wrote to build a quick and dirty comma delimited text file: import arcpy
outputTxtFile = r"C:\csny490\myfile.txt" #output comma delimited text file
myGrid = r"C:\csny490\mm_from_space\wa06_mean4bin" #input raster file
fieldList = arcpy.ListFields(myGrid) #make a list of the fields
f = open(outputTxtFile, 'w') #open the text file for writting
f.write(",".join(['"'+ field.name + '"' for field in fieldList]) + "\n") #write the header (field names) using list comprehension
searchRows = arcpy.SearchCursor(myGrid) #open a search cursor
for searchRow in searchRows: #loop through the rows
f.write(",".join([str(searchRow.getValue(field.name)) for field in fieldList]) + "\n") #write out the field values of each row using list comprehension
del searchRow, searchRows #delete the cursor objects
f.close() #close the text file
... View more
02-13-2012
01:28 PM
|
0
|
0
|
1883
|
|
POST
|
How about an automatic "pop up" upon failure? import subprocess
subprocess.Popen('"C:\\Program Files\\Internet Explorer\\iexplore.exe" http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/000001_Angle_should_be_greater_than_0_and_less_than_180/00vp00000002000001/') There's some other ways too: http://stackoverflow.com/questions/1532884/open-ie-browser-window
... View more
02-13-2012
09:06 AM
|
1
|
0
|
1853
|
|
POST
|
So I tried in v10.0 and I am guessing that some of the Memo fields are somehow read protected. tbl2 = "C:\\csny490\\temp\\test.mdb\\GDB_Items"
print arcpy.SearchCursor(tbl2, "Path = '\landscapes'").next().Type #Type field is a Memo field, and it works...
{70737809-852C-4A03-9E22-2CECEA5B9BFA}
>>> print arcpy.SearchCursor(tbl2, "Path = '\landscapes'").next().Documentation
None
>>> print arcpy.SearchCursor(tbl2, "Path = '\landscapes'").next().Definition
None Workaround: Parse the output .xml format file of the ExportMetadata_conversion() tool?
... View more
02-10-2012
01:15 PM
|
0
|
0
|
1506
|
|
POST
|
My bad... You are totally correct! However, in v9.3 I can apparently read the values of Memo fields. In the example below, the SRTEXT field in the GDB_SpatialRefs table is reported as a Memo field in Access. I dont have a 'GDB_Items' table in my v9.3 PGDB, so maybe it's the table? Maybe it works to read memo fields in v9.3 and not in a v10.0 PGDB? tbl = r"D:\csny490\temp\test.mdb\GDB_SpatialRefs"
>>> lmpy.listFields(tbl)
NAME TYPE LENGTH SCALE PRECISION
----------------------------------------------------------------------------------------------------
SRID OID 4 0 0
SRTEXT String 2147483647 0 0
FalseX Double 8 0 0
FalseY Double 8 0 0
XYUnits Double 8 0 0
FalseZ Double 8 0 0
ZUnits Double 8 0 0
FalseM Double 8 0 0
MUnits Double 8 0 0
IsHighPrecision Integer 4 0 0
XYTolerance Double 8 0 0
ZTolerance Double 8 0 0
MTolerance Double 8 0 0
>>> lmpy.listRecords(tbl)
RECORD #1
----------------------------------------------------------------------------------------------------
SRID: 1
SRTEXT: PROJCS["NAD_1983_HARN_StatePlane_Washington_South_FIPS_4602_Feet",GEOGCS["GCS_North_American_1983_HARN",DATUM["D_North_American_1983_HARN",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Lambert_Conformal_Conic"],PARAMETER["False_Easting",1640416.666666667],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",-120.5],PARAMETER["Standard_Parallel_1",45.83333333333334],PARAMETER["Standard_Parallel_2",47.33333333333334],PARAMETER["Latitude_Of_Origin",45.33333333333334],UNIT["Foot_US",0.3048006096012192]]
FalseX: -117498300.0
FalseY: -98850300.0
XYUnits: 609.601219202
FalseZ: -100000.0
ZUnits: 1.0
FalseM: -100000.0
MUnits: 1.0
IsHighPrecision: 1
XYTolerance: 0.00328083333333
ZTolerance: 2.0
MTolerance: 2.0
LISTED 1 RECORDS
>>>
... View more
02-10-2012
12:44 PM
|
0
|
0
|
1506
|
|
POST
|
It's probably not the memo field type, but rather the table you are trying to read. All those GDB_* tables in a PGDB are 'off limits' to the high level ESRI geoprocessing objects. You would have to use some other non-ESRI module to read these GDB_* tables... That said, there are a bunch of ways to read Access databases (and the GDB_* tables) directly: http://stackoverflow.com/questions/853370/what-do-i-need-to-read-microsoft-access-databases-using-python
... View more
02-10-2012
08:54 AM
|
0
|
0
|
1506
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 03-25-2014 12:57 PM | |
| 1 | 08-29-2024 08:23 AM | |
| 1 | 08-29-2024 08:21 AM | |
| 1 | 02-13-2012 09:06 AM | |
| 2 | 10-05-2010 07:50 PM |
| Online Status |
Offline
|
| Date Last Visited |
08-30-2024
12:25 AM
|