Advertisement
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: |
#RasterDataInfo.py
#
#Author
# Dan Patterson
#Purpose
# Lists the properties of raster data and optionally writes to a file.
#
#Properties (right-click on the tool and specify the following)
#General
# Name RasterDataInfo
# Label Raster Data Info
# Desc List rasters in a folder.
# All raster classes within the folder will be described.
# You can optionally create a text file containing all output.
# Simply select an output folder then specify an output filename.
#
#Source script RasterDataInfo.py
#
#Parameter list (examples below)
# Parameter Properties
# Display Name Data type Type Direction MultiValue
# argv[1] Select a folder Workspace Required Input No
# argv[2] Output text filename Optional Optional Input No
#--------------------------------------------------------------------
#Import the standard modules
# Get the folder
# Get an optional output filename
# Get a list of feature classes (shapefiles)
# cycle through the list and add their names to the messages
#
import win32com.client, sys, os, string
gp = win32com.client.Dispatch("esriGeoprocessing.GpDispatch.1")
#
gp.workspace=sys.argv[1]
aFileName=sys.argv[2]
#
aMessage="\n" + "Raster data in folder: " + gp.workspace + "\n"
s2=" "
s4=" "
#
#Determine if output is to go to a file as well
#
if aFileName <> '#': #check to see if a filename is specified
aFile=open(aFileName, 'w')
aFile.write(aMessage + "\n")
gp.AddMessage("\n" + "Output saved to: " + aFileName + "\n" + "Processing..." + "\n")
else:
gp.AddMessage("\n" +aMessage + "\n" + "Optional text file not created")
aLst=gp.ListRasters("*", "all") #a list, change as desired
aLst.reset()
aRaster=aLst.next() #an element in a list
#
aCounter = 0
#
while aRaster:
desc=gp.Describe(aRaster)
aCounter = aCounter + 1
if aFileName <> '#':
gp.addMessage(str(aCounter) + s2 + str(desc.CatalogPath))
#
outList = []
outList.append(str(aCounter) + s2 + str(desc.CatalogPath))
outList.append(s4 + "Dataset type: " + str(desc.DataSetType))
outList.append(s4 + "Format: " + str(desc.Format))
outList.append(s4 + "Compression type: " + str(desc.CompressionType))
outList.append(s4 + "Sensor type: " + str(desc.SensorType))
outList.append(s4 + "Table type: " + str(desc.TableType))
outList.append(s4 + "Primary field: " + str(desc.PrimaryField))
outList.append(s4 + "Pixel type: " + str(desc.PixelType))
outList.append(s4 + "Is integer: " + str(desc.IsInteger))
#if str(desc.Format) == "GRID":
# rasterNoData = s4 + "NoData value: " + str(desc.NoDataValue)
outList.append(s4 + "Number of bands: " + str(desc.BandCount))
outList.append(s4 + "Height: " + str(desc.Height))
outList.append(s4 + "Width: " + str(desc.Width))
outList.append(s4 + "Raster Cell Height: " + str(desc.MeanCellHeight))
outList.append(s4 + "Raster Cell Width: " + str(desc.MeanCellWidth))
outList.append(s4 + "Extent: Xmin, Ymin, Xmax, Ymax " + str(desc.Extent))
#
#output to messages
#
if aFileName <> '#':
for aVal in outList:
aFile.write(aVal + "\n")
aFile.write("\n")
else:
for aVal in outList:
gp.AddMessage(aVal)
aRaster = aLst.next()
gp.AddMessage("Rasters Processed: " + str(aCounter) + "\n")
#
if aFileName <> '#':
aFile.flush()
aFile.close()
gp.AddMessage("\n")
#
#del gp
|
|
[x]
The Solution Rating System
|
||
|
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
|
Loading Advertisement... |