-
Image download from ftp --> upload to AWS s3 bucket
-
Pull to AWS EC2 machine. Save off SWIR band ratios as tif with appropriate contrast. The SWIR data is an 8-band image. You need to first grab onnly the bands you need for visualization (8-3-1 or 6-3-1 make good combos)
import rasterio
import numpy as np
raster='18NOV09185526-A2AS-058669488010_01_P001.TIF'. #your file
outfile='swir_831.tif'
with rasterio.open(raster) as raster:
img1 = raster.read()
out_meta = raster.meta.copy()
ii=np.dstack((img1[7],img1[2],img1[0])) #(bands 8-3-1)
out_meta.update({"driver": "GTiff","count":3}). #change from 8 band count to 3 band
im = ii.transpose(1, 2, 0)
im = im.transpose(1, 2, 0)
with rasterio.open(outfile, "w", **out_meta) as dest:
dest.write(im)
-
You may have to adjust the scale. Technically you cann do something like this:
gdal_translate swir_831.tif swir_831_scaled.tif -scale 0 4670 0 4670 -exponent 0.5 -co COMPRESS=DEFLATE -co PHOTOMETRIC=RGB
I was still having signfiicant contrast problems once I converted to an mbtiles. So At this point, I actually pulled the image locally to QGIS and saved as a 'rendered' tif -
translate scaled tif to mbtiles:
gdal_translate swir_831_rendered.tif -of mbtiles swir_831_rendered.mbtiles
-
add overviews to the mbtiles:
gdaladdo -r average swir_831_rendered.mbtiles 2 4 8 16 32 64
This imagery is 3.7-m/pixel native resolution. Your TMS overviews will be zoom 9-15 -
unpack the mbtiles to create pyramid folders:
mb-util swir_831_rendered.mbtiles swir_831_rendered/
-
upload the unpacked mbtiles to the storm-ai-layers s3 bucket:
aws s3 cp swir_831_rendered/ s3://storm-ai-layers/swir_831_rendered/ --recursive
-
you can know stream your image from https://d27y2lu5k335jb.cloudfront.net/swir_831_rendered/{z}/{x}/{y}.png
-
change the names of the files, etc to be consistent.