COG + STAC
Requirements
-
python 3.7
-
rio-viz, rio-cogeo
pip install rio-viz rio-cogeo
-
GDAL (optional)
You can also use Docker
docker run \
--name dockerimage\
-p 8000:8000 \
--volume $(pwd)/:/local \
--rm -it lambgeo/lambda:gdal2.4-py3.7 bash
e.g https://www.naturalearthdata.com/downloads/50m-raster-data/50m-cross-blend-hypso/
wget https://naciscdn.org/naturalearth/50m/raster/HYP_50M_SR.zip
GDAL Command line
$ gdalinfo HYP_50M_SR.tif
Driver: GTiff/GeoTIFF
Files: HYP_50M_SR.tif
Size is 10800, 5400
Coordinate System is:
GEOGCS["WGS 84",
DATUM["WGS_1984",
SPHEROID["WGS 84",6378137,298.257223563,
AUTHORITY["EPSG","7030"]],
AUTHORITY["EPSG","6326"]],
PRIMEM["Greenwich",0],
UNIT["degree",0.0174532925199433],
AUTHORITY["EPSG","4326"]]
Origin = (-179.999999999999972,90.000000000000000)
Pixel Size = (0.033333333333330,-0.033333333333330)
Metadata:
AREA_OR_POINT=Area
TIFFTAG_DATETIME=2014:10:18 09:30:26
TIFFTAG_RESOLUTIONUNIT=2 (pixels/inch)
TIFFTAG_SOFTWARE=Adobe Photoshop CC 2014 (Macintosh)
TIFFTAG_XRESOLUTION=342.85699
TIFFTAG_YRESOLUTION=342.85699
Image Structure Metadata:
INTERLEAVE=PIXEL
Corner Coordinates:
Upper Left (-180.0000000, 90.0000000) (180d 0' 0.00"W, 90d 0' 0.00"N)
Lower Left (-180.0000000, -90.0000000) (180d 0' 0.00"W, 90d 0' 0.00"S)
Upper Right ( 180.0000000, 90.0000000) (180d 0' 0.00"E, 90d 0' 0.00"N)
Lower Right ( 180.0000000, -90.0000000) (180d 0' 0.00"E, 90d 0' 0.00"S)
Center ( -0.0000000, 0.0000000) ( 0d 0' 0.00"W, 0d 0' 0.00"N)
Band 1 Block=10800x1 Type=Byte, ColorInterp=Red
Band 2 Block=10800x1 Type=Byte, ColorInterp=Green
Band 3 Block=10800x1 Type=Byte, ColorInterp=Blue
Within Python
with rasterio.open("HYP_50M_SR.tif") as src_dst:
print(src_dst.overviews(1))
print(src_dst.block_shapes)
[]
[(1, 10800), (1, 10800), (1, 10800)]
with rio-cogeo cli
$ rio cogeo validate HYP_50M_SR.tif
The following warnings were found:
- The file is greater than 512xH or 512xW, it is recommended to include internal overviews
The following errors were found:
- The file is greater than 512xH or 512xW, but is not tiled
- The offset of the main IFD should be 8 for ClassicTIFF or 16 for BigTIFF. It is 174982088 instead
- The offset of the first block of the image should be after its IFD
/Users/vincentsarago/Downloads/HYP_50M_SR/HYP_50M_SR.tif is NOT a valid cloud optimized GeoTIFF
Create a valid COG
$ rio cogeo create HYP_50M_SR.tif HYP_50M_SR_COG.tif -p jpeg
Reading input: /Users/vincentsarago/Downloads/HYP_50M_SR/HYP_50M_SR.tif
[####################################] 100%
Adding overviews...
Updating dataset tags...
Writing output to: /Users/vincentsarago/Downloads/HYP_50M_SR/HYP_50M_SR_COG.tif
Magic ?
ls -lah
total 366496
drwx------@ 8 vincentsarago staff 256B Jun 11 23:54 .
drwx------+ 77 vincentsarago staff 2.4K Jun 11 23:44 ..
-rw-r--r--@ 1 vincentsarago staff 167M Oct 18 2014 HYP_50M_SR.tif
-rw-r--r-- 1 vincentsarago staff 4.8M Jun 11 23:54 HYP_50M_SR_COG.tif
gdalinfo HYP_50M_SR_COG.tif
Driver: GTiff/GeoTIFF
Files: HYP_50M_SR_COG.tif
Size is 10800, 5400
Coordinate System is:
GEOGCS["WGS 84",
DATUM["WGS_1984",
SPHEROID["WGS 84",6378137,298.257223563,
AUTHORITY["EPSG","7030"]],
AUTHORITY["EPSG","6326"]],
PRIMEM["Greenwich",0],
UNIT["degree",0.0174532925199433],
AUTHORITY["EPSG","4326"]]
Origin = (-179.999999999999972,90.000000000000000)
Pixel Size = (0.033333333333330,-0.033333333333330)
Metadata:
AREA_OR_POINT=Area
OVR_RESAMPLING_ALG=NEAREST
TIFFTAG_DATETIME=2014:10:18 09:30:26
TIFFTAG_RESOLUTIONUNIT=2 (pixels/inch)
TIFFTAG_SOFTWARE=Adobe Photoshop CC 2014 (Macintosh)
TIFFTAG_XRESOLUTION=342.85699
TIFFTAG_YRESOLUTION=342.85699
Image Structure Metadata:
COMPRESSION=YCbCr JPEG
INTERLEAVE=PIXEL
SOURCE_COLOR_SPACE=YCbCr
Corner Coordinates:
Upper Left (-180.0000000, 90.0000000) (180d 0' 0.00"W, 90d 0' 0.00"N)
Lower Left (-180.0000000, -90.0000000) (180d 0' 0.00"W, 90d 0' 0.00"S)
Upper Right ( 180.0000000, 90.0000000) (180d 0' 0.00"E, 90d 0' 0.00"N)
Lower Right ( 180.0000000, -90.0000000) (180d 0' 0.00"E, 90d 0' 0.00"S)
Center ( -0.0000000, 0.0000000) ( 0d 0' 0.00"W, 0d 0' 0.00"N)
Band 1 Block=512x512 Type=Byte, ColorInterp=Red
Overviews: 5400x2700, 2700x1350, 1350x675, 675x338
Band 2 Block=512x512 Type=Byte, ColorInterp=Green
Overviews: 5400x2700, 2700x1350, 1350x675, 675x338
Band 3 Block=512x512 Type=Byte, ColorInterp=Blue
Overviews: 5400x2700, 2700x1350, 1350x675, 675x338
$ rio viz HYP_50M_SR_COG.tif
TiTiler - [Tee Tiler] : https://github.com/developmentseed/titiler
❤️ COG + STAC
https://bit.ly/titiler (https://dfu60xgk3j.execute-api.us-east-1.amazonaws.com/docs#/)
-
Search for some data
-
Visualize one STAC item https://dfu60xgk3j.execute-api.us-east-1.amazonaws.com**/stac/viewer**
-
Use TiTiler to get some data (numpy array)