예제 #1
0
def process_image(rpc_metadata_path=None,
                  dem_path=None,
                  geoid_path=None,
                  spacing=None,
                  create_options=[],
                  *,
                  src_path,
                  dst_path):

    rpc_fixed_dir = os.path.join(os.path.dirname(dst_path), '_rpc')
    os.makedirs(rpc_fixed_dir, exist_ok=True)
    rpc_fixed_path = os.path.join(rpc_fixed_dir, os.path.basename(src_path))

    _logger.info("Add RPC tags from %s and write %s", src_path, rpc_fixed_path)
    add_rpc_tags(src_path=src_path,
                 dst_path=rpc_fixed_path,
                 metadata_path=rpc_metadata_path)

    _logger.info("Orthorectify %s and write %s", rpc_fixed_path, dst_path)
    orthorectify(src_path=rpc_fixed_path,
                 dst_path=dst_path,
                 dem_path=dem_path,
                 geoid_path=geoid_path,
                 spacing=spacing,
                 create_options=create_options)

    _logger.info("Clean up temporary results")
    shutil.rmtree(rpc_fixed_dir)
예제 #2
0
def process_image(dem_path=None, geoid_path=None, *, src, dst):
    _logger.info(f"Source: {src}")
    _logger.info(f"Destination: {dst}")

    name, ext = os.path.splitext(os.path.basename(src))
    dirname = os.path.dirname(src)
    dim_xml = glob(os.path.join(dirname, 'DIM_*.XML'))[0]
    rpc_xml = glob(os.path.join(dirname, 'RPC_*.XML'))[0]

    os.makedirs(os.path.join(dst, 'calibarate'), exist_ok=True)
    os.makedirs(os.path.join(dst, 'orthorectify'), exist_ok=True)
    calibration_dst_path = os.path.join(dst, 'calibarate', name + ext)
    orthorectify_dst_path = os.path.join(dst, 'orthorectify', name + ext)

    calibration.calibrate(src_path=src,
                          dst_path=calibration_dst_path,
                          metadata_path=dim_xml)

    name, ext = os.path.splitext(os.path.basename(src))
    temp_name = os.path.join(os.path.dirname(src), f'{name}_rpc{ext}')

    _logger.info("Add RPC tags from %s and write %s", calibration_dst_path,
                 temp_name)
    orthorectification.add_rpc_tags(src_path=calibration_dst_path,
                                    dst_path=temp_name,
                                    metadata_path=rpc_xml)

    _logger.info("Orthorectify %s and write %s", temp_name,
                 orthorectify_dst_path)
    orthorectification.orthorectify(src_path=temp_name,
                                    dst_path=orthorectify_dst_path,
                                    dem_path=dem_path,
                                    geoid_path=geoid_path)
예제 #3
0
def process_image(dem_path=None, geoid_path=None, spacing=None, *, src, dst):
    _logger.info(f"Source: {src}")
    _logger.info(f"Destination: {dst}")

    basename = os.path.basename(src)
    name, ext = os.path.splitext(basename)
    dirname = os.path.dirname(src)
    dim_xml = glob(os.path.join(dirname, 'DIM_*.XML'))[0]
    rpc_xml = glob(os.path.join(dirname, 'RPC_*.XML'))[0]

    calibration_dir = os.path.join(dst, '_calib')
    os.makedirs(calibration_dir, exist_ok=True)
    calibration_path = os.path.join(calibration_dir, basename)

    _logger.info("Calibrate %s and write %s", src, calibration_path)
    calibration.calibrate(src_path=src,
                          dst_path=calibration_path,
                          metadata_path=dim_xml)

    rpc_fixed_dir = os.path.join(dst, '_rpc')
    os.makedirs(rpc_fixed_dir, exist_ok=True)
    rpc_fixed_path = os.path.join(rpc_fixed_dir, basename)

    _logger.info("Add RPC tags from %s and write %s", calibration_path,
                 rpc_fixed_path)
    orthorectification.add_rpc_tags(src_path=calibration_path,
                                    dst_path=rpc_fixed_path,
                                    metadata_path=rpc_xml)

    orthorectify_fixed_dir = os.path.join(dst, '_ortho')
    os.makedirs(orthorectify_fixed_dir, exist_ok=True)
    orthorectify_path = os.path.join(orthorectify_fixed_dir, basename)
    _logger.info("Orthorectify %s and write %s", rpc_fixed_path,
                 orthorectify_path)
    orthorectification.orthorectify(src_path=rpc_fixed_path,
                                    dst_path=orthorectify_path,
                                    dem_path=dem_path,
                                    geoid_path=geoid_path,
                                    spacing=spacing)

    _logger.info("Clean up image temporary results")
    shutil.rmtree(calibration_dir)
    shutil.rmtree(rpc_fixed_dir)
예제 #4
0
def process_image(rpc_metadata_path=None,
                  dem_path=None,
                  geoid_path=None,
                  *,
                  src_path,
                  dst_path):

    name, ext = os.path.splitext(os.path.basename(src_path))
    temp_name = os.path.join(os.path.dirname(src_path), f'{name}_rpc{ext}')

    _logger.info("Add RPC tags from %s and write %s", src_path, temp_name)
    add_rpc_tags(src_path=src_path,
                 dst_path=temp_name,
                 metadata_path=rpc_metadata_path)

    _logger.info("Orthorectify %s and write %s", temp_name, dst_path)
    orthorectify(src_path=temp_name,
                 dst_path=dst_path,
                 dem_path=dem_path,
                 geoid_path=geoid_path)

    os.unlink(temp_name)