项目作者: ManishSahu53

项目描述 :
This repo converts standard Raster dataset to Cloud Optimized GeoTIF
高级语言: Python
项目地址: git://github.com/ManishSahu53/cogconverter.git
创建时间: 2019-04-12T11:25:22Z
项目社区:https://github.com/ManishSahu53/cogconverter

开源协议:MIT License

下载


COG

Introduction

It validates the TIF and convert it into COG compliant using gdal. Following are the Use-Cases kept in mind while designing:

  1. Large TIF that cannot be fit into memory
  2. Reading data block by block, so can be run of even low memory server
  3. Supports Multiband TIFs
  4. 3-4 Band uint8 TIF (Orthomosaic)
  5. Building pyramids if not available (This will improve rendering speed)
  6. Compressing data
  7. Compressing to the same compression format as the original TIF. If original TIF was not compressed then LZW lossless compression is used to compress.
  8. Tile whole into 256x256 smaller blocks internally

Validator.py

It will validate tiff for COG format.

Converter.py

It has the actual converter function which converts tifs into COG format

To-Do

  1. Multi-core processing for faster results.

How to Run

  1. Inside python console
  1. import cogconverter as cog
  2. import gdal
  3. path_tif = 'sentinel2.tif'
  4. path_output = 'sentinel2_cog.tif'
  5. coordinate = 'EPSG:4326'
  6. intermediate_foramt = 'VRT'
  7. # If data is in TIF format
  8. ds = gdal.Open(path)
  9. <!-- If data is in another format, JP2 and other format have litte unknown issues, so we are following this pipeline to convert is into first VRT then procesing. -->
  10. ds = gdal.Warp('', path, dstSRS=coordinate, format=intermediate_foramt)
  11. ds1 = cog.converter.convert2blocksize(ds, path_output)
  12. ds1.FlushCache()
  13. ds1 = None
  14. ds = None

You can also run it as following.

  1. python converter.py -p data/non_cog.tif -o data/cog.tif
  2. python validator.py -p data/cog.tif