![]() |
Figura 1 - Pasta contendo os arquivos necessários |
Em função das cores definidas para cada cota no arquivo my_classes.ctp, o script cria um novo raster através do comando gdaldem (Figura 2).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# created by: Marcello Benigno | |
0 102 153 153 | |
1 236 241 230 | |
10 176 242 205 | |
50 180 246 179 | |
100 207 250 177 | |
150 242 252 179 | |
200 220 238 145 | |
250 147 208 93 | |
300 69 179 53 | |
350 21 151 47 | |
400 18 130 63 | |
450 81 144 58 | |
500 132 158 47 | |
550 181 171 35 | |
600 233 181 17 | |
650 235 149 2 | |
700 209 97 2 | |
750 177 54 2 | |
800 148 20 1 | |
850 124 6 1 | |
900 117 21 4 | |
950 113 30 6 | |
1000 109 39 9 | |
1050 106 45 12 | |
1100 117 64 30 | |
1150 133 88 60 | |
1200 149 113 93 | |
1250 162 144 135 | |
1300 173 173 172 | |
1350 190 190 190 | |
1400 210 208 210 | |
1450 227 225 227 |
![]() |
Figura 2 - Imagem SRTM colorida |
Em seguida é gerado o arquivo Hillshade (Figura 3).
![]() |
Figura 3 - Relevo sombreado (Hillshade) |
E os arquivos anteriores são unidos, como mostra a Figura 4.
![]() |
Figura 4 - União do relevo sombreado com a imagem SRTM colorida |
Por último, em função do limite do shapefile, o arquivo é "clipado". A Figura 5 mostra o resultado da utilização do script para o estado do Mato Grosso do Sul.
![]() |
Figura 5 - Resultado da utilização do script para o MS. |
Lembrando que para utilizar o script, é necessário lhe dar permissões de execução após baixá-lo, através do comando abaixo:
$ sudo chmod +x mosaic.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Author: Marcello Benigno, Mar/2014; copyright: GPL >= 2 | |
# Purpose: Create a beautiful SRTM Hillshade color Map | |
# Usage: ./mosaic.sh | |
## Required programs: | |
## imagemagick | |
## gdal >=1.7.0 | |
## my_classes.cpt - download at | |
## <https://gist.github.com/marcellobenigno/9289976> | |
echo -n "Enter the shapefile name (or path):" | |
read _SHP | |
echo "Unzipping files:" | |
echo "----------------" | |
for i in *.zip ; do unzip $i ; done | |
mkdir zip | |
mv *.zip zip | |
ls *.tif *.rrd *.aux > list.txt | |
files=`cat list.txt` | |
echo "Creating the mosaic:" | |
echo "----------------" | |
gdalwarp *.tif 00.tif | |
echo "removing unnecessary files:" | |
echo "----------------" | |
for i in `echo $files`;do | |
find . name *$i -exec rm -rf {} \; | |
done | |
rm list.txt | |
SHPFILE=$_SHP | |
BASE=`basename $SHPFILE .shp` | |
EXTENT=`ogrinfo -so $SHPFILE $BASE | grep Extent | sed 's/Extent: //g' | sed 's/(//g' | sed 's/)//g' | sed 's/ - /, /g'` | |
EXTENT=`echo $EXTENT | awk -F ',' '{print $1 " " $4 " " $3 " " $2}'` | |
echo $EXTENT | |
echo "Cutting SRTM according to the bounding box:" | |
echo "----------------" | |
gdal_translate -projwin $EXTENT -of GTiff -co compress=LZW 00.tif 01.tif | |
echo "Generating raster with the altimetric classes:" | |
echo "----------------" | |
gdaldem color-relief 01.tif -alpha my_classes.cpt 02.tif | |
echo "Generating hillshade:" | |
echo "----------------" | |
gdaldem hillshade -z 5 -s 111120 -co COMPRESS=LZW 01.tif 03.tif | |
echo "Adjusting Hillshade's contrast (takes a while):" | |
echo "----------------" | |
convert -gamma .5 03.tif 04.tif | |
echo "Merging hillshade with color terrain SRTM (takes a while):" | |
echo "----------------" | |
convert 02.tif 04.tif -compose Overlay -composite 05.tif | |
listgeo -tfw 01.tif | |
mv 01.tfw 05.tfw | |
echo "Assigning the original Coordinate System:" | |
echo "(loose spatial reference after merging with imagemagick)" | |
echo "----------------" | |
gdal_translate -of GTiff -co compress=LZW -co tiled=YES 05.tif -a_srs EPSG:4326 06.tif | |
echo "Cliping the raster to the bounding box of shapefile (takes a while):" | |
echo "----------------" | |
gdalwarp -co compress=JPEG -co TILED=YES -of GTiff -cutline $SHPFILE 06.tif dem_hillshade.tif | |
echo "Removing unnecessary files and ending :)" | |
echo "----------------" | |
rm -fr 00* 01* 02* 03* 04* 05* 06* *.tfw |