|
POST
|
ArcGIS Help claims that it is possible to perform multi-line statements in the raster calculator but I have not been able to do so http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Building_complex_statements/00p60000000p000000/ I'm wondering if this is a case of false advertising or if I'm missing something? Robert has pretty much covered it, but I just wanted to point out it's not false advertising - the help page you linked to is not for the raster calculator. It's for map algebra in the arcpy Spatial Analyst module.
... View more
09-19-2012
04:02 PM
|
0
|
0
|
1164
|
|
POST
|
Use the Copy Raster and then the Build Raster Attribute Table tools.
... View more
09-18-2012
01:05 AM
|
0
|
0
|
376
|
|
POST
|
You can use the Adobe Reader command line print option. If you leave the printer name blank, reader will print to the default printer. AcroRd32 /N /T PdfFile [PrinterName [ PrinterDriver [ PrinterPort ] ] ] Python example: import subprocess printer='MyPrinter' pdffile=r'C:\Some Dir\some pdf.pdf' acroread=r'C:\Program Files (x86)\Adobe\Reader 9.0\Reader\AcroRd32.exe' #'"%s"'is to wrap double quotes around paths # as subprocess will use list2cmdline internally if we pass it a list #which escapes double quotes and Adobe Reader doesn't like that cmd='"%s" /N /T "%s" "%s"'%(acroread,pdffile,printer) proc = subprocess.Popen(cmd,stdout=subprocess.PIPE,stderr=subprocess.PIPE) stdout,stderr=proc.communicate() exit_code=proc.wait()
... View more
09-17-2012
03:51 PM
|
2
|
2
|
27668
|
|
POST
|
You're not the only one. I haven't been able to find/contribute anything since the good old days of ArcScripts. See also http://forums.arcgis.com/threads/61952-Finding-contributed-add-ins-and-tools-is-impossible!!!
... View more
09-13-2012
03:54 PM
|
0
|
0
|
386
|
|
POST
|
The STD calculation tried to do an 'illegal' operation and an indeterminate (#IND) value (also known as NaN or "Not a Number") was returned. You'll get this trying to calculate the square root of a negative number - i.e sqrt(-1.0). As standard deviation = square root(variance), perhaps a cells variance is set to -1 or -9999 or someother negative number when there's a nodata value...? More info: http://www.johndcook.com/IEEE_exceptions_in_cpp.html
... View more
09-09-2012
04:22 PM
|
0
|
0
|
588
|
|
POST
|
if i could find a way to just publish the pyt once then throw the extra scripts in there and have them recognized that would be the bomb Something like the following might work: # \--SomeDir
# | toolbox.pyt
# | some_script.py
# | another_script.py
# | ...
# | last_script.py
#
# Each *.py contains a class called Tool that's just a stub for your "main" def.
#----------------------------
#The .pyt file (all Tools are dynamically imported not hardcoded)
#----------------------------
import arcpy
import os,sys,glob
class Toolbox(object):
def __init__(self):
"""Define the toolbox (the name of the toolbox is the name of the .pyt file)."""
self.label = "MultiTool_Toolbox"
self.alias = "Toolbox with Multiple Dynamically Imported Tools"
# Dynamic list of tool classes associated with this toolbox
path=os.path.dirname(__file__)
self.tools=[]
for py in glob.glob(os.path.join(path,'*.py')):
if not __file__ in py:
module=os.path.basename(py)[:-3]
#Note: "Tool" class must have same
#name as the script "Tool" classes
self.tools.append(__import__(module).Tool)
#----------------------------
#The .py script files
#----------------------------
#"Tool" class can be called anything but must be
# the same in each script and in the calling toolbox
class Tool(object):
# tool/parameter setup methods etc...
def execute(self,*args,**kwargs):
main(*args,**kwargs)
def main(*args,**kwargs):
#do stuff
return
if __name__=='__main__':
#Run script
main(sys.argv[1:])
... View more
09-07-2012
03:31 PM
|
0
|
2
|
3354
|
|
POST
|
If you didn't want to modify your existing script tools to convert them to classes, then you could do that (calling your scripts from the execute method of each Tool class). I was thinking more of just converting the scripts to classes though, especially if you're writing stubs for those classes anyway. How you could do it depends on how you've written your scripts. If your existing 10.0 scripts are basic scripts where all the code is in the top-level scope, then in the execute method of the new Tool class you could use the subprocess module to call python and pass it the path to the 10.0 script. If your 10.0 scripts are organised into functions, you might be able to do something like: #----------------
# 10.0 script tool
# script_10_0.py
#----------------
import arcpy
def do_some_stuff(arg1,arg2):
print arg1,arg2
if __name__ == '__main__':
arg1=arcpy.GetParameterAsText(0)
arg2=arcpy.GetParameterAsText(1)
do_some_stuff(arg1,arg2)
#----------------------
# 10.1 Python Toolbox
#----------------------
import arcpy
import script_10_0 #import the old 10.0 script tool so you can call its functions.
class Toolbox(object):
def __init__(self):
"""Define the toolbox (the name of the toolbox is the name of the
.pyt file)."""
self.label = "10_0_Tool_Toolbox"
self.alias = "Toolbox with 10.0 Tools"
# List of tool classes associated with this toolbox
self.tools = [Tool1]
class Tool1(object):
#...
def execute(self, parameters, messages):
arg1=parameters[0].valueAsText
arg2=parameters[1].valueAsText
script_10_0.do_some_stuff(arg1,arg2)
... View more
09-06-2012
03:55 PM
|
0
|
0
|
3354
|
|
POST
|
I'm still using 10.0 so can't actually test this, but have you tried using the standard python package structure? Something like:
# \--SomeDir
# | toolbox.pyt
# \--toolpackage
# | __init__.py
# | script_a.py
# | script_b.py
#----------------------------
#The .pyt file
#----------------------------
import arcpy
from toolpackage.script_a import Tool1
from toolpackage.script_a import Tool2
from toolpackage.script_b import Tool3
class Toolbox(object):
def __init__(self):
"""Define the toolbox (the name of the toolbox is the name of the
.pyt file)."""
self.label = "MultiTool Toolbox"
self.alias = "mtt"
# List of tool classes associated with this toolbox
self.tools = [Tool1, Tool2, Tool3]
... View more
09-05-2012
04:48 PM
|
0
|
0
|
3354
|
|
POST
|
Get GDAL (the simplest installs are either from GISInternals or OSGEO4W). Then use the "gdal_translate" utility from the command line or a batch script. Command line example: for %i in (C:\inputdir\*.bil) do @gdal_translate -co 'COMPRESS=LZW' %i C:\outputdir\%~ni.tif This will preserve the colour table. The -co 'COMPRESS=LZW' will use LZW lossless compression for the output tif. And here's a batch file to do the same, but recursively over subfolders and preserve the folder hierarchy: (note, the previous one liner will work from a command prompt, if you want to use it in a batch file, change the "%" symbols to "%%"). @echo off
cd /D C:\inputdir
for /R %%i in ("*.bil") do (
mkdir "C:\outputdir%%~dpi"
gdal_translate -co "COMPRESS=LZW" "%i" "C:\outputdir%%~dpi%~ni.tif"
)
... View more
08-21-2012
06:35 PM
|
1
|
0
|
3379
|
|
POST
|
See this site for ArcGIS scripts to generate building shadows. You'd need to determine sun azimuth and altitude for the particular date/time yourself and pass them as parameters to the script.
... View more
08-07-2012
09:46 PM
|
0
|
0
|
586
|
|
POST
|
You're also importing env separately. I don't think this will make any difference, but it is uneccessary. Just use: import arcpy
arcpy.env.workspace = "C:/Documents and Settings"
... View more
07-30-2012
02:27 PM
|
0
|
0
|
1079
|
|
POST
|
http://forums.arcgis.com/threads/48475-Please-read-How-to-post-Python-code
... View more
07-14-2012
10:38 PM
|
0
|
0
|
954
|
|
POST
|
Did you look at the Cell Statistics tool Steve recommended? It does exactly what you are attempting to do with that long Con(IsNull()) code. outCellStats = CellStatistics(["murle_ras_7","murle_ras_6","murle_ras_5","murle_ras_4",...,"murle_ras_N"], "SUM", "DATA")
... View more
06-26-2012
04:02 PM
|
0
|
0
|
874
|
|
POST
|
You could also take a look at the shelve module - http://docs.python.org/library/shelve.html It provides a filesystem based dict like class. Though as it's filesystem based, it will probably be slower than your 64bit python subprocess method.
... View more
05-31-2012
06:40 PM
|
0
|
0
|
2780
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 07-30-2025 03:00 PM | |
| 1 | 06-10-2025 08:06 PM | |
| 5 | 05-20-2025 07:56 PM | |
| 1 | 05-04-2025 10:34 PM | |
| 5 | 04-22-2025 09:04 PM |