Export quicklooks with vector overlay using TuiView

Often when you have a large stack of images (e.g., a time series) it’s useful to create quick looks so you can flick through them. Normally I use gdal_translate with the ‘-scale’ and ‘-outsize’ flags, as described in a previous post.

Recently I wanted to quickly export all bands of an image for a presentation, with some points overlain. The TuiView manual describes how it’s possible to automate the ‘Save Current Display’ menu option using Python, which sounded ideal for this task.

Following the instructions to export a single image in the manual, I added a loop to export each band and name the output file with the band name, which produced exactly the result I needed. As this is something I’m likely to need to do again, I tidied the script up, made it a bit more general and added some more of the options available. The script can be downloaded from RSGIS Scripts on Bitbucket.

To export all bands in an image (original task):

python export_quicklook_tuiview.py --inimage tonzi_data_layers.kea \
       --outimage tonzi_data_layers_ql.png \
       --invector sensor_locations.shp \

I also added the options to export an image using the default stretch:

python export_quicklook_tuiview.py --inimage tonzi_data_layers.kea \
       --invector sensor_locations.shp \
       --outimage tonzi_data_layers_ql.png

Or if the data has already been stretched and RGB mapped to bands 1,2,3

python export_quicklook_tuiview.py --inimage tonzi_data_2sd_rgb.kea \
       --invector sensor_locations.shp \
       --outimage tonzi_data_rgb_2sd_ql.png --rgb --nostretch

To add text to the quick looks (e.g., the filename) imagemagick can be used:

convert in_image.png -gravity north -strokewidth 10 \
-pointsize 100 -annotate 0 "Title" out_image_with_title.png

To run for all images in a directory GNU Parallel can be used:

ls *kea | parallel \
python export_quicklook_tuiview.py --inimage {} \
       --invector sensor_locations.shp \
       --outimage {.}_ql.png

1 thought on “Export quicklooks with vector overlay using TuiView

  1. Pingback: parallel @ Savannah: GNU Parallel 20140622 (‘Brazil’) released | Open World

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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s