Using GDAL to import a lot of images, or one image with multiple bands, at one time

Here are some loop codes you can use to import imagery using GDAL. The first is a loop to import all bands in an image. This is particularly useful if you are importing hyperspectral data.

C:\Data Folder\ for /l %b in (1,1,#of bands) do gdal_translate -of rst -b %b filename.img filename_%b.rst

(as always, choose the file types accordingly, in this example I’m converting a multiband IMG into RST)

This next one is for converting all of a certain file format (i.e., tif) within a directory to another file format (i.e., rst)

C:\Data Folder\ for %i in (*.tif) do for /l %b in (1,1,#of bands) do gdal_translate -of rst -b %b %i outrst\%~ni_%b.rst

To do this see the FWTools/GDAL post below. Open FWTools then change directories to where your data is.

About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: