[gdal-dev] script selecting the extent

Even Rouault even.rouault at mines-paris.org
Fri Jul 13 05:34:17 PDT 2012


Selon Margherita Di Leo <diregola at gmail.com>:

> Hi,
>
> I have more than 22000 GeoTiff's stored in a folder (the world coverage of
> ASTER GDEM) and I have to select among them only those covering the Europe
> area, in order to import them in GRASS. I was about to write a Python
> script to do that (using gdalinfo), but I felt like reinventing the wheel,
> because I'm pretty sure I've already seen in the internet something doing
> that, but can't remember where.. or likely some of you guys has already
> experienced this and are willing to share a script :-)

If you want to use python, don't use it to parse the output of gdalinfo ! Use
the GDAL Python API instead. Would be far easier and robust.

But I don't think you need to do any scripting. You could use "gdaltindex
an_index.shp *.tif" ( http://gdal.org/gdaltindex.html ) to create an index of
all the files, and then with "ogrinfo an_index.shp -spat xmin ymin xmax ymax",
you would get the list of files that intersection the bounding box. Perhaps
"ogr2ogr -f CSV list.csv an_index.shp -spat xmin ymin xmax ymax" would lead to
something even more easily usable.

>
> TIA,
>
> --
> Dr. Margherita Di Leo
>




More information about the gdal-dev mailing list