Пример #1
0
def stack_bands_together(src_files, basename):
    """
    Take a list of src files of equal position and time, and stack them into a single VRT

    :param src_files: []
    :param basename: str
    :return: filename string
    """
    scene_vrt = '{}.vrt'.format(basename)

    execute(['gdalbuildvrt', '-separate', scene_vrt] + src_files)

    return scene_vrt
Пример #2
0
def create_tile_files(input_vrt, target_dir='.', pixel_size=4000,
                      output_format='NetCDF',
                      create_options=None):
    if create_options is None:
        create_options = ['FORMAT=NC4', 'COMPRESS=DEFLATE', 'ZLEVEL=1']
    csv_path = 'test.csv'

    # Make list like ['-co', 'FORMAT=NC4', '-co', 'COMPRESS=DEFLATE', '-co', 'ZLEVEL=1']
    create_options = sum([['-co', option] for option in create_options], [])
    pixel_size = str(pixel_size)

    execute(['gdal_retile.py', '-v', '-targetDir', target_dir,
             '-ps', pixel_size, pixel_size,
             '-of', output_format, '-csv', csv_path, '-v'] + create_options + [input_vrt])

    return list_tile_files(csv_path)
Пример #3
0
def reproject_and_expand(input_vrt, basename, output_extents, target_srs="EPSG:4326"):
    reprojected_vrt = '{}.{}.vrt'.format(basename, target_srs.lower().replace(':', ''))
    target_pixel_res = "0.00025"

    extents_args = []
    if output_extents:
        extents_args = ['-te'] + list(output_extents)

    execute(['gdalwarp',
             '-t_srs', target_srs,
             '-of', 'VRT',
             '-tr', target_pixel_res, target_pixel_res,  # Pixel resolution x,y (Fraction of a degree)
             '-tap',  # Force to nest within the grid definition
             '-srcnodata', '-999',
             '-dstnodata', '-999'] +
            extents_args +
            [input_vrt, reprojected_vrt])
    return reprojected_vrt