Beispiel #1
0
def export_band(subdataset, bounds, crs, output_path):
    # ulx uly lrx lry
    ullr_args = [str(x) for x in [bounds[0], bounds[3], bounds[2], bounds[1]]]
    cmd = ['gdal_translate', '-of', 'GTiff', '-a_ullr']
    cmd += ullr_args
    cmd += ['-a_srs', crs, subdataset, output_path]
    call(cmd)
Beispiel #2
0
    def make_it_smaller(tif_path: str) -> None:
        with TemporaryDirectory() as tmp_dir:
            tmp_path = os.path.join(tmp_dir, "smaller.tif")
            translate_cmd = [
                "gdal_translate", "-of", "GTiff", "-outsize", "512", "512",
                tif_path, tmp_path
            ]
            if dry_run:
                logger.info(' '.join(translate_cmd))
            else:
                call(translate_cmd)

                shutil.move(tmp_path, tif_path)
Beispiel #3
0
def cogify(infile: str,
           outfile: str,
           args: List[str] = None,
           extra_args: List[str] = None):
    """Creates a COG from a GDAL-readable file."""
    if args is None:
        args = DEFAULT_COGIFY_ARGS[:]
    args = ["gdal_translate", "-of", "COG"] + args
    if extra_args:
        args.extend(extra_args)
    args.append(infile)
    args.append(outfile)
    return call(args)
Beispiel #4
0
def cogify(infile: str,
           outfile: str,
           args: Optional[List[str]] = None,
           extra_args: Optional[List[str]] = None) -> int:
    """Creates a COG from a GDAL-readable file."""
    if not gdal_driver_is_enabled("COG"):
        raise Exception(
            "GDAL's COG driver is not enabled. "
            "Please make sure your GDAL version is 3.1 or greater.")
    if args is None:
        args = DEFAULT_COGIFY_ARGS[:]
    args = ["gdal_translate", "-of", "COG"] + args
    if extra_args:
        args.extend(extra_args)
    args.append(infile)
    args.append(outfile)
    return call(args)
Beispiel #5
0
 def test_entry_point(self):
     result = call(["stac", "version"])
     self.assertEqual(0, result)
Beispiel #6
0
def cogify(input_path, output_path):
    call([
        'gdal_translate', '-of', 'COG', '-co', 'predictor=2', '-co',
        'compress=deflate', input_path, output_path
    ])
Beispiel #7
0
def merge_bands(input_paths, output_path):
    call(['gdal_merge.py', '-separate', '-o', output_path] + input_paths)