[GIS] Specify directories for use with gdaltindex

gdal

I'd like to use gdaltindex to create a polygon shapefile of thousands of georeferenced .tif documents. I've found this incredibly easy to accomplish in a single directory on Linux
(e.g. gdaltindex indexoutput.shp *.tif) but I'll also need to index several hundred sub directories on a windows drive. I do have FWTools installed on the windows machine.

The majority of these files are Tiff's with a world file and have not yet been converted to geoTiffs. I work in a few different coordinate systems, so ideally I'd like to go through and make a single pass at each coordinate system.

It looks like I can use -skip_different_projection to take care of the projection issue, but my search hasn't turned up any parameters of gdaltindex to specify directories, so any help is much appreciated.

Best Answer

You can use an optfile (see the bottom of the page) which contains paths to all your tif files.

You can create the optfile using a dos command prompt - something like:

dir /s/b *.tif > tiff_list.txt

You can then just call gdaltindex with the optfile:

gdaltindex -skip_different_projection indexoutput.shp --optfile tiff_list.txt

As for the different projections, if you know what projectios everything is in you can use a different optfile. Otherwise you could potentially do the following (bit sloppy I know, but I can't think of a way you could do it otherwise):

  1. run through the optfile
  2. compare the resulting index with the optfile, remove any duplicates from the optfile
  3. rinse and repeat until there are not tif files left to be cataloged
Related Question