gdal_t2
In [2]:
cd /Users/abharathi/Documents/gis_data/gdal-tools/
In [3]:
ls
In [1]:
!gdalinfo /vsigs/spatialthoughts-public-data/viirs_ntl_2021_global.tif --config GS_NO_SIGN_REQUEST YES
In [34]:
cd ../naip
In [35]:
ls
In [6]:
ls *.jp2 > filelist.txt
Alpha band is an additional band that simply states which cells have value and which have no-Data. It is an image mask. Alpha is useful when you compress raster using PNG or JP2 formats and reduce quantization to 8bit Uint8. With such low dynamic range, it becomes tricky to use 0
or 255
as no-data.
In [10]:
!gdalinfo output_1_1.jp2
In [36]:
%time
!gdalbuildvrt -input_file_list filelist.txt naip.vrt
In [38]:
%%time
!gdal_translate -of JPEG -outsize 2% 2% naip.vrt naip_preview.jpg
In [39]:
%%time
!gdaltindex -write_absolute_path index.json --optfile filelist.txt
In [45]:
cd ../landsat8/
In [46]:
ls -lh
In [30]:
!gdalbuildvrt -o rgb.vrt -separate \
RT_LC08_L1TP_137042_20190920_20190926_01_T1_2019-09-20_B4.tif \
RT_LC08_L1TP_137042_20190920_20190926_01_T1_2019-09-20_B3.tif \
RT_LC08_L1TP_137042_20190920_20190926_01_T1_2019-09-20_B2.tif
In [47]:
!gdalbuildvrt -o allbands.vrt -separate \
RT_LC08_L1TP_137042_20190920_20190926_01_T1_2019-09-20_B4.tif \
RT_LC08_L1TP_137042_20190920_20190926_01_T1_2019-09-20_B3.tif \
RT_LC08_L1TP_137042_20190920_20190926_01_T1_2019-09-20_B2.tif \
RT_LC08_L1TP_137042_20190920_20190926_01_T1_2019-09-20_B5.tif \
RT_LC08_L1TP_137042_20190920_20190926_01_T1_2019-09-20_B8.tif
In [41]:
%%time
!gdal_translate rgp.vrt rgb.tif -co PHOTOMETRIC=RGB -co COMPRESS=DEFLATE
In [50]:
%%time
!gdal_translate -scale 0 0.3 0 255 -ot Byte rgb.vrt rgb_stretch.tif
In [52]:
!which gdal_calc.py
In [66]:
%run -i /Users/abharathi/micromamba/envs/opengeo/bin/gdal_calc.py
In [ ]:
%%time
%run -i /Users/abharathi/micromamba/envs/opengeo/bin/gdal_calc.py \
-A RT_LC08_L1TP_137042_20190920_20190926_01_T1_2019-09-20_B5.TIF \
-B RT_LC08_L1TP_137042_20190920_20190926_01_T1_2019-09-20_B4.TIF \
--outfile ndvi.tif --calc="(A-B)/(A+B)" --NoDataValue=-999
In [69]:
%%time
!gdalbuildvrt -o nrg.vrt -separate \
RT_LC08_L1TP_137042_20190920_20190926_01_T1_2019-09-20_B5.tif \
RT_LC08_L1TP_137042_20190920_20190926_01_T1_2019-09-20_B4.tif \
RT_LC08_L1TP_137042_20190920_20190926_01_T1_2019-09-20_B3.tif
In [73]:
%%time
!gdal_translate -of JPEG nrg.vrt nrg.jpg -co COMPRESS=JPG -scale 0 0.3 0 255 -ot Byte -outsize 10% 10%
In [76]:
!which gdal_pansharpen.py
In [78]:
%%time
%run -i /Users/abharathi/micromamba/envs/opengeo/bin/gdal_pansharpen.py \
RT_LC08_L1TP_137042_20190920_20190926_01_T1_2019-09-20_B8.tif \
rgb.vrt pansharpened.vrt -r bilinear -co COMPRESS=DEFLATE -co PHOTOMETRIC=RGB
In [80]:
%%time
!gdal_translate -of JPEG pansharpened.vrt pansharpened.jpg -scale 0 0.3 0 255 -ot Byte -outsize 40% 40%
In [83]:
cd ../london_1m_dsm/
In [84]:
ls *.asc > filelist.txt
In [85]:
%%time
!gdalbuildvrt -input_file_list filelist.txt londondsm.vrt
In [86]:
# No CRS in the vrt
!gdalinfo londondsm.vrt
In [89]:
%%time
#Assign SRS
!gdal_translate londondsm.vrt londondsm.tif \
-co COMPRESS=DEFLATE -co PREDICTOR=2 \
-a_srs EPSG:27700
In [ ]:
!gdaltransform -s_srs EPSG:4326