converting multiple kea to tif

506 views
Skip to first unread message

Theo Awo

unread,
Jun 12, 2017, 3:21:20 AM6/12/17
to RSGISLib Support
Hi All,

Wondering if there's a way to use gdal_translate to bulk process the conversion of kea files to tiff instead of one by one using:

gdal_translate –of GTIFF filenam_demsref.kea filename_demsref.tif

Regards.

Pete Bunting [pfb]

unread,
Jun 12, 2017, 3:29:01 AM6/12/17
to Theo Awo, RSGISLib Support
Hi Theo, 

I use a shell script such as the one below:

# Created by Pete Bunting (peteb...@mac.com)
#
# A simple script to use gdal_translate to convert files 
# to the KEA format.
#

# Inputs:
# $1 is the input directory 
# $2 is the output directory

FILES=$1/*.kea
for f in $FILES
do
  echo "Processing $f file..."
  filename=`basename ${f} .kea`
  echo "Output: ${2}/${filename}.tif"
  gdal_translate -of GTIFF ${f} ${2}/${filename}.tif
  gdaladdo ${2}/${filename}.tif 2 4 8 16 32
done

Best wishes, 

Pete

****************************************************
* Dr Pete Bunting
* Reader in Remote Sensing
* Earth Observation and Ecosystem Dynamics Group
* Department of Geography and Earth Sciences
* Aberystwyth University
* Aberystwyth
* Ceredigion
* SY23 3DB
* UK

* Ph: +44 (0) 1970 622615
* Mob: +44 (0) 7917 842743
* Email: p...@aber.ac.uk
* ORCID: http://orcid.org/0000-0002-7435-0148
****************************************************
"Please consider the environment before printing this email or any documents attached”

--
You received this message because you are subscribed to the Google Groups "RSGISLib Support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rsgislib-suppo...@googlegroups.com.
To post to this group, send email to rsgislib...@googlegroups.com.
Visit this group at https://groups.google.com/group/rsgislib-support.
For more options, visit https://groups.google.com/d/optout.



--------------------------------------------------------------------
Un o’r 4 prifysgol uchaf yn y DU a’r orau yng Nghymru am fodlonrwydd myfyrwyr.
(Arolwg Cenedlaethol y Myfyrwyr 2016)
www.aber.ac.uk

Top 4 UK university and best in Wales for student satisfaction
(National Student Survey 2016)
www.aber.ac.uk

David Trethewey

unread,
Jun 12, 2017, 2:47:52 PM6/12/17
to rsgislib...@googlegroups.com
A long time ago I wrote a script to do the opposite, converting .tif
GeoTiff files to .kea in Python, to reduce the size of stored Landsat
scenes.

David Trethewey



On 12/06/17 08:28, Pete Bunting [pfb] wrote:
> Hi Theo,
>
> I use a shell script such as the one below:
>
> # Created by Pete Bunting (peteb...@mac.com <mailto:peteb...@mac.com>)
> * Email: p...@aber.ac.uk <mailto:p...@aber.ac.uk>
> * ORCID: http://orcid.org/0000-0002-7435-0148
> ****************************************************
> /"Please consider the environment before printing this email or any
> documents attached”/
>
>> On 12 Jun 2017, at 08:21, Theo Awo <philu...@gmail.com
>> <mailto:philu...@gmail.com>> wrote:
>>
>> Hi All,
>>
>> Wondering if there's a way to use gdal_translate to bulk process the
>> conversion of kea files to tiff instead of one by one using:
>>
>> gdal_translate –of GTIFF filenam_demsref.kea filename_demsref.tif
>>
>> Regards.
>>
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "RSGISLib Support" group.
>> To unsubscribe from this group and stop receiving emails from it, send
>> an email to rsgislib-suppo...@googlegroups.com
>> <mailto:rsgislib-suppo...@googlegroups.com>.
>> To post to this group, send email to rsgislib...@googlegroups.com
>> <mailto:rsgislib...@googlegroups.com>.
>> Visit this group at https://groups.google.com/group/rsgislib-support.
>> For more options, visit https://groups.google.com/d/optout.
>
>
>
> --------------------------------------------------------------------
> Un o’r 4 prifysgol uchaf yn y DU a’r orau yng Nghymru am fodlonrwydd
> myfyrwyr.
> (Arolwg Cenedlaethol y Myfyrwyr 2016)
> www.aber.ac.uk
>
> Top 4 UK university and best in Wales for student satisfaction
> (National Student Survey 2016)
> www.aber.ac.uk
>
> --
> You received this message because you are subscribed to the Google
> Groups "RSGISLib Support" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to rsgislib-suppo...@googlegroups.com
> <mailto:rsgislib-suppo...@googlegroups.com>.
> To post to this group, send email to rsgislib...@googlegroups.com
> <mailto:rsgislib...@googlegroups.com>.
convertallTIFstoKEA_createMTL_kea.py

Theo Awo

unread,
Jun 13, 2017, 12:42:03 AM6/13/17
to Pete Bunting [pfb], RSGISLib Support
Thanks very much Pete!

To unsubscribe from this group and stop receiving emails from it, send an email to rsgislib-support+unsubscribe@googlegroups.com.
To post to this group, send email to rsgislib-support@googlegroups.com.

Nathan Thomas

unread,
Jun 13, 2017, 12:46:14 AM6/13/17
to Theo Awo, Pete Bunting, RSGISLib Support
Hi Theo,

Just to provide a pure python example:

import subprocess
import os

inDir = ‘infilepath’

files = [file for file in os.listdir(inDir) if file.endswith(‘.tif’)]

for file in files:
subprocess.call(‘gdal_translate -of KEA ‘ + os.path.join(inDir, file) + ‘ ‘ + os.path.join(inDir, file.replace(‘.tif’,’_kea.kea’)),shell=True)



Cheers, Nathan


To unsubscribe from this group and stop receiving emails from it, send an email to rsgislib-suppo...@googlegroups.com.
To post to this group, send email to rsgislib...@googlegroups.com.

Theo Awo

unread,
Aug 22, 2017, 4:35:03 PM8/22/17
to Nathan Thomas, Pete Bunting, RSGISLib Support
Thanks Nathan. I'll try this both options...
Reply all
Reply to author
Forward
0 new messages