Create index/outline of rasters

2684
6
12-20-2012 09:10 AM
JanetBrewster
Occasional Contributor II
Hi All,

I'm trying to create an index of 60+ rasters -- I just want a simple polygon file that shows the outlines of the images so I can see where they are at a glance, rather than having to open each raster. These are all individual .imgs. The only out-of-the-box tools I have found are for mosaics, not for individual files (we already have a composite of the rasters, so I don't want to take the time or network space to create an unnecessary, monstrous mosaic). Is there a non-manual, non-Python way to do this?

Any thoughts would be appreciated. Thanks!


ps - I can use 10.1 or 9.3.1
0 Kudos
6 Replies
T__WayneWhitley
Frequent Contributor
What I have on file somewhere is a short Python script that will do it, but you don't want Python?  As far as I know, the best way to do it is by script of some kind - VBA, or even a compiled tool, but why bother with the install when you already presumably have Python installed?  The script I cobbled together loops to retrieve the min and max XY extent of the rasters to then insert polygons for....and the speed of it is shocking, processing thousands of raster datasets in mere seconds.  I set it up so I'd have both a shapefile (or feature class) and, if I export to a table, a legacy image catalog (because I have it also write IMAGE, XMIN, YMIN, XMAX, YMAX in the attribute table).

Do you still want some other solution?
0 Kudos
JeffreySwain
Esri Regular Contributor
Have you tried to create a Mosaic Dataset or an unmanaged Raster catalog?  One of the outputs are a polygon feature class that can be exported that has the rasters correlated.  This should be the most direct option.
0 Kudos
T__WayneWhitley
Frequent Contributor
Here is the script I was referring to earlier.... wow, is it aging - I need to update it for arcpy, but I'm pretty certain it still works in 10.
Substitute your variable pathnames, etc., in the spaces denoted by '< insert *** param here  >':
import arcgisscripting
gp = arcgisscripting.create(9.3)
gp.overwriteoutput = 'true'

# here's where you need to define some variables, only 4:
gp.workspace = r'< insert full root path to directory containing image tiles >'
coord_system = 'PROJCS[< insert coord sys params here >]'
GridName = '< your shapefile (you can convert to fc later, as you wish) >'
IMAGEfldLen = < your numeric length value for the image name field (suggest 50 or less) >

gp.CreateFeatureClass_management(gp.workspace, GridName, 'POLYGON', '', '', '', coord_system)
fields = ['IMAGE', 'XMIN', 'XMAX', 'YMIN', 'YMAX']
gp.AddField_management(GridName, fields[0], 'TEXT', '', '', IMAGEfldLen)
for i in range(1, 5):
         gp.AddField_management(GridName, fields, 'DOUBLE', 18, 17)
         print "added field: " + fields
 
rasters = gp.ListRasters()
arrayObj = gp.CreateObject('Array')
 
outRows = gp.InsertCursor(GridName)
 
for raster in rasters:
         extent = gp.describe(raster).extent
         arrayObj.add(extent.lowerleft)
         arrayObj.add(extent.lowerright)
         arrayObj.add(extent.upperright)
         arrayObj.add(extent.upperleft)
         arrayObj.add(extent.lowerleft)
         feat = outRows.NewRow()
         feat.Shape = arrayObj
         image = '.\\' + raster
         feat.SetValue('IMAGE', image)
         feat.SetValue('XMIN', extent.xmin)
         feat.SetValue('YMIN', extent.ymin)
         feat.SetValue('XMAX', extent.xmax)
         feat.SetValue('YMAX', extent.ymax)
         outRows.InsertRow(feat)
         arrayObj.RemoveAll()
 
del outRows


That should do it - if I get more time at a later date, I'll update this to use arcpy, use the da module cursor processing if possible, and add a script tool interface.  As it is, you'll have to open the file in, say, a text editor, and change your params where instructed.

Hope that works well for you!
[Note:  If I'm not mistaken, you may have to build a spatial index to view it properly (it's in the Toolbox) or if importing the resultant shp into a gdb, one will be built for you.]

-Wayne
0 Kudos
JanetBrewster
Occasional Contributor II
Thanks , Wayne! Maybe at some point I'll try the Python, but I've forgotten everything I've learned so I'm not facile enough with it to test it out right now.
0 Kudos
TrishRice
Occasional Contributor III
Another possibility but somewhat more manual:  Run raster calculator or resample to make all the values something easy like 1.  Convert raster into polygon. It could be modeled for repeatability on each raster.
0 Kudos
FionaGregory
New Contributor II
This would be a really useful tool. I've often felt the same need, but I  do it in other software.
0 Kudos