Behzad Valipour Sh. bio photo

Behzad Valipour Sh.

PhD Research Assistant @ SwissTPH

Email Twitter LinkedIn Github ResearchGate

Sometimes raw raster data coming with raw format which does not include any projection infomation in metadata. Using such raw data is difficult for further processing; therfore, it could be very useful to convert them to the format such as Geotiff which is usable for different purposes. On the other hand, due to large valume of the high resolution raster dataset, they are distributed in the tiles so that each tile covers only a special zone while making a mosaic out of several tiles to further analysis is compulsary.

One of the computer software library for reading and writing raster and vector geospatial data formats, which is released under the permissive X/MIT style free software license by the Open Source Geospatial Foundation is GDAL (Geospatial Data Abstraction Library). This library includes tools for both raster (gdal_translate, gdal_warp etc.) & vector (ogr2ogr, ogrmerge etc.). However, it is well-known for its tools for dealing with big raster datasets.

In this sample code, this powerful library was used to convert the SID (MrSID – Multi-resolution Seamless Image Database) to GeoTiff & to create mosaic out of the converted raster tiles. Finally, to generate a perview of the produced mosaic with low volume.


Fig. 1: One tile of the orthophoto image

Conversion of SID to GeoTiff

in the first step, it is required to use loop in bash to read and conver each SID tile to GeoTiff one.

#! /bin/bash
for filename in *.sid 
do
gdal_translate -a_srs EPSG:3346 -of GTiff -co COMPRESS=DEFLATE -co ZLEVEL=9 $filename $(pwd)/tiff/${filename%.*}.tif
done 

Getting the list of converted files

ls ./tiff/*.tif > list.txt

Making mosaic out of file’s list

gdalwarp -co BIGTIFF=YES --optfile ./tiff/list.txt ./mosaic/ort_mosaic_lithuania_2019.tif

Creation of the preview from produced mosaic

gdal_translate -of jpeg -scale -outsize 10% 10% ./mosaic/ort_mosaic_lithuania_2019.tif ./mosaic/ort_mosaic_lithuania_2019.jpeg 


Fig. 2: Created preview of the mosaic image