Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- # usage: sh terraintextureshading.sh demfile newname resolution XMIN YMIN XMAX YMAX
- # example: sh terraintextureshading.sh mydem.tif sylarna 4 XMIN YMIN XMAX YMAX
- i="$1"
- f="$2"
- j="$3"
- XMIN="$4"
- YMIN="$5"
- XMAX="$6"
- YMAX="$7"
- slopefile2070="20 255 255 255
- 70 153 153 153"
- echo "$slopefile2070" > 20-70.txt
- slopefile3750="0 0 0 0
- 37 0 0 0
- 50 255 255 255"
- echo "$slopefile3750" > 37-50.txt
- slopefile45="0 1 1 1
- 50 1 1 1
- 50.01 255 255 255"
- echo "$slopefile45" > 45.txt
- #beskär raster
- echo "xmin: $XMIN, $YMAX $XMAX $YMIN"
- gdal_translate -projwin $XMIN $YMAX $XMAX $YMIN $i ${f}.tif
- #skala om
- gdalwarp -tr $j $j -r cubic ${f}.tif ${f}_${j}m.tif
- ## gaussian filter
- saga_cmd grid_filter 1 -INPUT ${f}_${j}m.tif -RESULT ${f}_${j}m_dn07 -SIGMA 0.7 -KERNEL_TYPE 0 -KERNEL_RADIUS 2
- # konvertera till float
- gdal_translate -of EHdr -ot Float32 ${f}_${j}m_dn07.sdat ${f}_${j}m.flt
- # rock shade
- texture 1.5 ${f}_${j}m.flt ${f}_${j}m_rock_1_5.flt
- texture_image +0.0 ${f}_${j}m_rock_1_5.flt ${f}_${j}m_rock_1_5_img.tif
- # texture shade
- texture 1.0 ${f}_${j}m.flt ${f}_${j}m_terr_1_0.flt
- texture_image +2.0 ${f}_${j}m_terr_1_0.flt ${f}_${j}m_terr_1_0_img.tif
- #hillshade
- gdaldem hillshade ${f}_${j}m.tif ${f}_${j}m_hillshade.tif -z 1.0 -s 1.0 -az 315.0 -alt 55.0 -of GTiff
- #slope
- gdaldem slope ${f}_${j}m.tif ${f}_${j}m_slope.tif -s 1.0 -of GTiff
- #färgsätt slope-mask
- gdaldem color-relief ${f}_${j}m_slope.tif 37-50.txt ${f}_${j}m_slope_37-50.tif
- #färgsätt slope
- gdaldem color-relief ${f}_${j}m_slope.tif 20-70.txt ${f}_${j}m_slope_20-70.tif
- #skapa mask till hk
- gdaldem color-relief ${f}_${j}m_slope.tif 45.txt ${f}_${j}m_slope_45.tif
- gdal_sieve.py -st 20 ${f}_${j}m_slope_45.tif ${f}_${j}m_slope_45_S30.tif
- gdal_polygonize.py ${f}_${j}m_slope_45_S30.tif -f "ESRI Shapefile" ${f}_mask.shp ${f}_mask DN
- ogr2ogr -where DN="255" ${f}_mask_clean.shp ${f}_mask.shp
- cp ${f}_${j}m_terr_1_0_img.tfw ${f}_${j}m_slopeshade.tfw
- rm ${f}.tif
- rm 45.txt
- rm 37-50.txt
- rm 20-70.txt
- rm ${f}_${j}m.tif
- rm ${f}_${j}m_dn07.*
- rm ${f}_${j}m.*
- rm *.hdr
- rm *.flt
- rm ${f}_${j}m_slope.tif
- rm ${f}_mask.*
- rm ${f}_${j}m_slope_45.*
- rm ${f}_${j}m_slope_45_S30.*
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement