src/cirrus/builtins/tasks/add-preview/lambda_function.py
def reproject(fin, fout, logger, crs='EPSG:4326'):
    """ Reproject file using GCPs into a known projection """
    '''
    # TODO - combine cogify with warping if possible
    envs = {
        "driver": "GTiff",
        "interleave": "pixel",
        "tiled": True,
        "blockxsize": 512,
        "blockysize": 512,
        "compress": "DEFLATE",
    }
    '''
    logger.debug('Reprojecting to %s: %s into %s' % (crs, fin, fout))
    with rasterio.open(fin) as src:
        if src.crs:
            transform, width, height = calculate_default_transform(
                src.crs,
                crs,
                src.width,
                src.height,
                *src.bounds,
            )
        else:
            # use GCPs
            transform, width, height = calculate_default_transform(
                src.crs,
                crs,
                src.width,
                src.height,
                gcps=src.gcps[0],
            )
        kwargs = src.meta.copy()
        kwargs.update({
            'crs': crs,
            'transform': transform,
            'width': width,
            'height': height
        })

        with rasterio.open(fout, 'w', **kwargs) as dst:
            for i in range(1, src.count + 1):
                _reproject(
                    source=rasterio.band(src, i),
                    destination=rasterio.band(dst, i),
                    src_transform=src.transform,
                    src_crs=src.crs,
                    dst_transform=transform,
                    dst_crs=crs,
                    resampling=Resampling.nearest)
 Reproject file using GCPs into a known projection 
Reproject file using GCPs into a known projection
Reproject file using GCPs into a known projection
def reproject(fin, fout, logger, crs='EPSG:4326'):
    logger.debug('Reprojecting to %s: %s into %s' % (crs, fin, fout))
    with rasterio.open(fin) as src:
        if src.crs:
            transform, width, height = calculate_default_transform(
                src.crs,
                crs,
                src.width,
                src.height,
                *src.bounds,
            )
        else:
            transform, width, height = calculate_default_transform(
                src.crs,
                crs,
                src.width,
                src.height,
                gcps=src.gcps[0],
            )
        kwargs = src.meta.copy()
        kwargs.update({
            'crs': crs,
            'transform': transform,
            'width': width,
            'height': height
        })
        with rasterio.open(fout, 'w', **kwargs) as dst:
            for i in range(1, src.count + 1):
                _reproject(
                    source=rasterio.band(src, i),
                    destination=rasterio.band(dst, i),
                    src_transform=src.transform,
                    src_crs=src.crs,
                    dst_transform=transform,
                    dst_crs=crs,
                    resampling=Resampling.nearest)
def reproject ( fin , fout , logger , crs = 'EPSG:4326' ) : '''
    # TODO - combine cogify with warping if possible
    envs = {
        "driver": "GTiff",
        "interleave": "pixel",
        "tiled": True,
        "blockxsize": 512,
        "blockysize": 512,
        "compress": "DEFLATE",
    }
    ''' logger . debug ( 'Reprojecting to %s: %s into %s' % ( crs , fin , fout ) ) with rasterio . open ( fin ) as src : if src . crs : transform , width , height = calculate_default_transform ( src . crs , crs , src . width , src . height , * src . bounds , ) else : transform , width , height = calculate_default_transform ( src . crs , crs , src . width , src . height , gcps = src . gcps [ 0 ] , ) kwargs = src . meta . copy ( ) kwargs . update ( { 'crs' : crs , 'transform' : transform , 'width' : width , 'height' : height } ) with rasterio . open ( fout , 'w' , ** kwargs ) as dst : for i in range ( 1 , src . count + 1 ) : _reproject ( source = rasterio . band ( src , i ) , destination = rasterio . band ( dst , i ) , src_transform = src . transform , src_crs = src . crs , dst_transform = transform , dst_crs = crs , resampling = Resampling . nearest )
Reproject file using GCPs into a known projection
Reproject file using GCPs into a known projection
""" Reproject file using GCPs into a known projection """ '''
    # TODO - combine cogify with warping if possible
    envs = {
        "driver": "GTiff",
        "interleave": "pixel",
        "tiled": True,
        "blockxsize": 512,
        "blockysize": 512,
        "compress": "DEFLATE",
    }
    ''' # use GCPs
fin
fout
logger
crs