|
POST
|
If you go the all raster route, the Spatial Analyst Combine tool is what you will need (it's the raster equivalent of a vector "intersect" operation).
... View more
11-29-2010
03:14 PM
|
0
|
0
|
766
|
|
POST
|
Did you accidentally set a default value for the Extent environment variable (a specified xy rectangle for which all geoprocessing tools will perform within)? I inadvertently did this a while back and had a hell of a time figuring out what I did to make all my outputs come back with no results.
... View more
11-29-2010
10:10 AM
|
0
|
0
|
7054
|
|
POST
|
Cool! Makes you wonder why there's hardly any ESRI help and/or code examples items with this... P.S. I am wanting to adapt some very inefficient v9.3 code to use this stuff (arcpy.geometry). Can't wait! 😄 Need to get the "important" projects done so I can get into v10 finally 😛
... View more
11-29-2010
09:10 AM
|
0
|
0
|
2247
|
|
POST
|
Make 1/4 mile buffers. Intersect the buffers with your landuse polygons (using the Intersect tool). What happens? Do you see something to the effect of "Tiling Dataset" in the result info?
... View more
11-29-2010
06:43 AM
|
1
|
1
|
3402
|
|
POST
|
For ESRI-comliant SQL: http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00s500000033000000.htm
... View more
11-24-2010
12:55 PM
|
0
|
0
|
1110
|
|
POST
|
Yes, all you need to use the OBJECTID value (BTW, not always called OBJECTID). For example: myFC = r"C:\temp\test.shp"
oidFieldName = gp.describe(myFC).oidfieldname
searchRows = gp.searchcursor(myFC)
searchRow = searchRows.next()
while searchRow:
oidFieldValue = searchRow.getvalue(oidFieldName)
outputFC = r"C:\temp\output_" + str(oidFieldValue) + ".shp"
gp.Select(myFC, outputFC, oidFieldName + " = " + str(oidFieldValue)
searchRow = searchRows.next()
... View more
11-24-2010
11:39 AM
|
0
|
0
|
1110
|
|
POST
|
If you want: ORIG_FIELD = "My House" SPLIT1 = "My" SPLIT2 = "House" The Python syntax for the Calculate Field tool would be: SPLIT1 = !ORIG_FIELD!.split(" ")[0] #0 being the 1st word SPLIT1 = !ORIG_FIELD!.split(" ")[-1] #-1 being the last word
... View more
11-24-2010
09:51 AM
|
0
|
0
|
11239
|
|
POST
|
If you have $$$ and a bunch of interested people: http://learning-python.com/
... View more
11-24-2010
08:36 AM
|
0
|
0
|
3045
|
|
POST
|
I wrote a Python script that would get you part way there: http://forums.arcgis.com/threads/17809-polygon-in-polygon-analysis-count-if?p=56528&viewfull=1#post56528 The script basically does a recursive SelectByLocation (maybe specify 1 mile selction radius?). The FC then gets a CLUSTER_ID field (you can name it whatever you want) added and populated. So if there were three "clusters" of points that were > 1 mile appart (but the points in the cluster were all < 1 mile appart) you would end up with 3 different CLUSTER_ID values. Then all you need to do is add the X and Y coordinates to the table, run the Summary Statistics tool (using CLUSTER_ID as the case field, and getting the mean X and Y coordinate values). Build a new FC based on teh output of the summary stats table. Presto.
... View more
11-23-2010
03:09 PM
|
0
|
0
|
3396
|
|
POST
|
This is v9.3 code, but I think it does the same thing as your code. P.S. I use this thing all the time to for SQL - it's very handy!!! # Name: list_selected_values_v93.py
#
# Description
# -----------
# This script will list the unique values of selected features/records in a FC or table
# in a specified sort order. I meant this tool to be used to format long text strings
# as value1, value2, value3, etc. so that I could use it as part of an SQL expression.
#
# Written By: Chris Snyder, WA DNR, chris.snyder(at)wadnr.gov
#
# Written For: Python 2.5.1 and ArcGIS v9.3.1 SP1
#
# UPDATES:
#
# Notes on input parameters (for the toolbox):
# VARIABLE PAREMETER_INDEX PARAMETER_DATA_TYPE
# -------------------------------------------------------------------
# inputLayer 0 TableView (the input FeatureClass, Table, FeatureLayer or TableView)
# inputFieldName 1 Field Name
# inputSortOrder 2 String ("ASCENDING","DESCENDING", "UNSORTED")
#
try:
#Process: Import some modules
import os, string, sys, time, traceback, arcgisscripting
#Process: Create the gp object
gp = arcgisscripting.create(9.3)
#Process: Defines some functions used for getting messages from the gp and python
def showGpMessage():
gp.AddMessage(gp.GetMessages())
print >> open(logFile, 'a'), gp.GetMessages()
print gp.GetMessages()
def showGpWarning():
gp.AddWarning(gp.GetMessages())
print >> open(logFile, 'a'), gp.GetMessages()
print gp.GetMessages()
def showGpError():
gp.AddError(gp.GetMessages())
print >> open(logFile, 'a'), gp.GetMessages()
print gp.GetMessages()
def showPyLog(): #just print to the log file!
print >> open(logFile, 'a'), str(time.ctime()) + " - " + message
def showPyMessage():
gp.AddMessage(str(time.ctime()) + " - " + message)
print >> open(logFile, 'a'), str(time.ctime()) + " - " + message
print str(time.ctime()) + " - " + message
def showPyWarning():
gp.AddWarning(str(time.ctime()) + " - " + message)
print >> open(logFile, 'a'), str(time.ctime()) + " - " + message
print str(time.ctime()) + " - " + message
def showPyError():
gp.AddError(str(time.ctime()) + " - " + message)
print >> open(logFile, 'a'), str(time.ctime()) + " - " + message
print str(time.ctime()) + " - " + message
#Specifies the root directory variable, defines the logFile variable, and does some minor error checking...
dateTimeString = str(time.strftime('%Y%m%d%H%M%S'))
scriptName = os.path.split(sys.argv[0])[-1].split(".")[0]
userName = string.lower(os.environ.get("USERNAME")).replace(" ","_").replace(".","_")
tempPathDir = os.environ["TEMP"]
logFileDirectory = r"\\snarf\am\div_lm\ds\gis\tools\log_files"
if os.path.exists(logFileDirectory) == True:
logFile = os.path.join(logFileDirectory, scriptName + "_" + userName + "_" + dateTimeString + ".txt")
try:
print >> open(logFile, 'a'), "Write test successfull!"
except:
logFile = os.path.join(tempPathDir, scriptName + "_" + userName + "_" + dateTimeString + ".txt")
else:
logFile = os.path.join(tempPathDir, scriptName + "_" + userName + "_" + dateTimeString + ".txt")
if os.path.exists(logFile)== True:
os.remove(logFile)
message = "Created log file " + logFile; showPyMessage()
message = "Running " + sys.argv[0]; showPyMessage()
#Process: Check out the highest license available
try:
if gp.CheckProduct("ArcView") == "Available":
gp.SetProduct("ArcView")
elif gp.CheckProduct("ArcEditor") == "Available":
gp.SetProduct("ArcEditor")
elif gp.CheckProduct("ArcInfo") == "Available":
gp.SetProduct("ArcInfo")
except:
message = "ERROR: Could not select an ArcGIS license level! Exiting script..."; showPyError(); sys.exit()
message = "Selected an " + gp.ProductInfo() + " license"; showPyMessage()
#Process: Sets some gp environment variables
gp.overwriteoutput = True
#Process: Collect the input parameters
inputLayer = gp.GetParameterAsText(0) #tableview
inputFieldName = gp.GetParameterAsText(1) #fieldname
inputSortOrder = gp.GetParameterAsText(2) #string
#Process: Print out the input parameters
message = "INPUT PARAMETERS"; showPyMessage()
message = "----------------"; showPyMessage()
message = "Input Layer = " + inputLayer; showPyMessage()
message = "Input Field Name = " + inputFieldName; showPyMessage()
message = "Sort Order = " + inputSortOrder + "\n"; showPyMessage()
#Some error checking:
try:
dsc = gp.describe(inputLayer)
except:
message = "ERROR: Could not describe input layer! Exiting script..."; showPyError(); sys.exit()
#make sure the inputLayer is a FeatureClass or Table
inputLayerDataType = dsc.datasettype
if inputLayerDataType not in ("FeatureClass","Table"):
message = "ERROR: Input layer type (" + str(inputLayerDataType) + ") is not a FeatureClass or Table! Exiting script.."; showPyError(); sys.exit()
#make sure inputFieldName is in inputLayer
if len(gp.listfields(inputLayer, inputFieldName)) == []:
message = "ERROR: Input layer does not contain a " + str(inputFieldName) + " field! Exiting script..."; showPyError(); sys.exit()
#Make sure a valid sort method is being provided
if inputSortOrder not in ("ASCENDING","DESCENDING","UNSORTED"):
message = "ERROR: Input sort order must be either ASCENDING, DESCENDING, or UNSORTED! Exiting script..."; showPyError(); sys.exit()
elif inputSortOrder == "ASCENDING":
fieldSortString = inputFieldName + " A"
elif inputSortOrder == "DESCENDING":
fieldSortString = inputFieldName + " D"
else:
fieldSortString = ""
#Determine the field type of inputFieldName
try:
inputFieldNameType = gp.listfields(inputLayer, inputFieldName)[0].type
except:
message = "ERROR: Could not determine the field type of the specified Input Field Name! Exiting script..."; showPyError(); sys.exit()
#Process: Create a string to return
uniqueValueList = []
uniqueValueCount = 0
searchRows = gp.searchcursor(inputLayer, "", "", "", fieldSortString)
searchRow = searchRows.next()
while searchRow:
fieldValue = searchRow.getvalue(inputFieldName)
if fieldValue not in uniqueValueList:
uniqueValueCount = uniqueValueCount + 1
uniqueValueList.append(fieldValue)
searchRow = searchRows.next()
del searchRow
del searchRows
uniqueValueString = ""
for uniqueValue in uniqueValueList:
if inputFieldNameType in ("String","Text"):
uniqueValueString = uniqueValueString + "'" + str(uniqueValue) + "',"
else:
uniqueValueString = uniqueValueString + str(uniqueValue) + ","
message = "UNIQUE VALUES: " + str(uniqueValueString[:-1]); showPyMessage()
message = ""; showPyMessage()
message = "BTW: There are " + str(uniqueValueCount) + " unique values!"; showPyMessage()
except:
message = "\n*** PYTHON ERRORS *** "; showPyMessage()
message = "Python Traceback Info: " + traceback.format_tb(sys.exc_info()[2])[0]; showPyMessage()
message = "Python Error Info: " + str(sys.exc_type)+ ": " + str(sys.exc_value) + "\n"; showPyMessage()
... View more
11-23-2010
01:25 PM
|
0
|
0
|
755
|
|
POST
|
Its pretty dated, but this ESRI .pdf got me started: http://gisgeek.pdx.edu/programming/Writing_Geoprocessing_Scripts.pdf (this is actually an ESRI document that is on their "Library" DVD, not sure why it's not posted on their website..). I'm sure there's a newer one that shipped with v10. Also, the ESRI 2 day "intro to geoprocessing scripting" class was very usefull I have to say. Seems that a lot of universities have put this sort of stuff together for into ArcGIS/Python classes: http://bss.sfsu.edu/jdavis/cert/9021/Ex3-PythonExer.pdf
... View more
11-23-2010
01:20 PM
|
0
|
0
|
3045
|
|
POST
|
I can't find any documentation in the help about that stuff (arcpy.geometry)... You've probaly seen it, but here's a good example script though: http://resources.arcgis.com/gallery/file/geoprocessing/details?entryID=7DCD71C0-1372-4ECD-2860-A023289A7EC5 Funny that in the code they acknowledge some bug issues and have a work around...
... View more
11-23-2010
11:57 AM
|
0
|
0
|
2247
|
|
POST
|
Seems in the v9.3 OMD you can get a field list of the (I assume) fields involved in the relationship class... When i try to do it though: import arcgisscripting gp = arcgisscripting.create(9.3) dsc = gp.describe(r"\\snarf\am\div_lm\ds\gis\tools\sde_connections_read\ropa_gis_layer_user.sde\CADASTRE.DOCUMENT_TO_PARCEL") # a relationship class BTW fieldList = dsc.fields print fieldList I just get [] (a blank list!) Seems like a bug... Maybe it works in v10?
... View more
11-23-2010
11:46 AM
|
0
|
0
|
924
|
|
POST
|
Whatever works, but a sugestion: Always attempt to minimize dependencies (in your case the .ini file creation). Gald the .ini worked BTW, but there may be a more bullet-proof solution... Seem's like you should be able to handle it in the "Table Convert" process (using type forcing like I mentioned above)... Can you post that part of your code?
... View more
11-23-2010
09:43 AM
|
0
|
0
|
3340
|
|
POST
|
I don't have any recent experience w/ looping in model builder, but my feeling is you might be hitting up against ModelBuilder's limitations here. This sounds like a job for Python...
... View more
11-23-2010
08:54 AM
|
0
|
0
|
1185
|
| 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
|