|
POST
|
No need to post duplicates. Also please read: How to post Python code.
... View more
05-14-2013
10:05 PM
|
0
|
0
|
476
|
|
POST
|
Your loop only processes one raster because on every loop you process the same raster over and over again (inRaster1 = "C:/py/07/lai_0907_m"). Do this instead: for filename in RasterFiles: print "Processing: {0}".format(filename) #input_dir = arcpy.env.workspace #inRaster1 = "C:/py/07/lai_0907_m" outRaster1 = os.path.join(OutputFolder,"z4_" + filename) # Process: Zonal Statistics #saveRaster = arcpy.sa.ZonalStatistics(ZoneData, "ID", inRaster1, "MEAN", "DATA") saveRaster = arcpy.sa.ZonalStatistics(ZoneData, "ID", filename, "MEAN", "DATA") saveRaster.save(outRaster1)
... View more
05-14-2013
06:27 PM
|
0
|
0
|
1248
|
|
POST
|
Yes, but seems a bit verbose to me. Here's a simple example using sys.argv instead of arcpy.GetParameterAsText: import sys
def myargs(func):
'''a decorator'''
defaultargs =sys.argv[1:]
def newfunc(*origargs):
if origargs:
return func(*origargs)
else:
return func(*defaultargs)
return newfunc
@myargs #the decoration
def myfunc(*args):
'''a decorated function'''
return args
if __name__ == "__main__":
for arg in myfunc('test'):print arg
for arg in myfunc():print arg
Here's a decent explanation of decorators: http://pythonconquerstheuniverse.wordpress.com/2012/04/29/python-decorators/
... View more
05-12-2013
07:29 PM
|
0
|
0
|
480
|
|
POST
|
Use the Combine tool. Oh and how's the view from up there on that high horse...? Scripting is for extending not "finishing" software. I'm not aware of any GIS software that doesn't support some form of scripting.
... View more
05-09-2013
04:56 PM
|
0
|
0
|
1528
|
|
POST
|
If I understand correctly, there is no string expression input based way to do this, in 10.1. SingleOutputMapAlgebra is still supported, I assume for backwards compatibility. i.e. >>> import arcpy
>>> print arcpy.__path__
['c:\\Program Files (x86)\\ArcGIS\\Desktop10.1\\arcpy\\arcpy']
>>> print arcpy.gp.SingleOutputMapAlgebra
<function <lambda> at 0x1748C3B0>
>>> import arcgisscripting
>>> gp=arcgisscripting.create()
>>> gp=arcgisscripting.create(10.1)
>>> print gp.singleoutputmapalgebra
<Tool: 'Single Output Map Algebra'>
However... I find the new raster object map algebra syntax to be much easier to use and much more flexible. Also, it's more future proof than relying on something that may not be available later on.
... View more
05-08-2013
09:54 PM
|
0
|
0
|
395
|
|
POST
|
In the raster calculator use an expression like below: Con(IsNull("little raster"), "big raster") . Before running the tool, click the environments button and set Processing Extent to "Same as layer big raster". [ATTACH=CONFIG]24088[/ATTACH]
... View more
05-06-2013
07:36 PM
|
0
|
0
|
3814
|
|
POST
|
If you have an ArcInfo (or "Advanced" in ArcGIS 10.1+ terms) level license, just use the ENVELOPE geometry option. If you don't have ArcInfo, download and use Dan Patterson's Bounding Containers toolbox.
... View more
05-02-2013
08:06 PM
|
0
|
0
|
1208
|
|
POST
|
The Selecting a fixed-distance band value topic in the help has some suggestions for the 2nd part of your question.
... View more
05-02-2013
07:58 PM
|
0
|
0
|
347
|
|
POST
|
The error message tells you the problem, you can't assign the result of an expression to another expression, only to a variable name. Bad: fac + i = ExtractByAttributes("Fac", "Value =" + i) Good: #Use a list or a dict fac={} fac = ExtractByAttributes("Fac", "Value =" + i) #Or use the eval function to evaluate a string expression (not as good...) eval('fac'+str(i)+'=ExtractByAttributes("Fac", "Value = ' + str(i) +'"') #Or eval using string format codes eval('fac%s=ExtractByAttributes("Fac", "Value = %s"' % (i,i)) Note the variable name is completely unrelated to the output file name... Are you saving the output to a file? If so, there's no reason to try and get the "i" value in the variable name, just use it in the output file name: extracted = ExtractByAttributes("Fac", "Value = %s" % i) extracted.save("D:/data/output/fac"+str(i))
... View more
05-02-2013
01:13 PM
|
0
|
0
|
1496
|
|
POST
|
You can use the Aggregate and Con functions in the Raster Calculator. For each land use code (e.g 9, 15, 32), run the Raster Calculator tool with the expression Aggregate(Con("landuse" == <landusecode>, 1, 0), 10, "SUM", "TRUNCATE"), e.g: Aggregate(Con("landuse" == 32, 1, 0), 10, "SUM", "TRUNCATE")
... View more
04-30-2013
04:25 PM
|
0
|
0
|
471
|
|
POST
|
Use the Mosaic To New Raster (Data Management) aand set the pixel type of your output raster to 16_BIT_UNSIGNED.
... View more
04-27-2013
10:17 PM
|
0
|
0
|
425
|
|
POST
|
Can you post your script using CODE tags instead of PRE. If you're not sure how to, read this: How to post Python code
... View more
04-23-2013
06:50 PM
|
0
|
0
|
880
|
|
POST
|
You could use the Cell Statistics tool to get a variety of stats including - max, min, mean, standard deviation. http://resources.arcgis.com/en/help/main/10.1/#/Cell_Statistics/009z0000007q000000/
... View more
04-23-2013
05:16 PM
|
0
|
0
|
365
|
| 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 |