EOX GitLab Instance

Commit 465bd485 authored by Lubomir Doležal's avatar Lubomir Doležal
Browse files

[preprocessor] allow georeferencing read_only formats (DIMAP) without warping via temporary tif

parent 5c243427
......@@ -53,12 +53,21 @@ def gcp_georef(input_filename: os.PathLike, target_filename: os.PathLike, order:
succeded = False
# simple case: get the geotransform from some GCPs
read_only = False
try:
ds = gdal.Open(input_filename, gdal.GA_Update)
except RuntimeError:
logger.warn('Can not open file by GDAL %s' % (input_filename))
return
logger.warn('Can not open file by GDAL for update mode %s' % (input_filename))
try:
ds = gdal.Open(input_filename)
read_only = True
except RuntimeError:
logger.warn('Can not open file by GDAL for read mode too %s' % (input_filename))
return
if ds.GetGCPCount() <= 4:
if read_only:
# need to circumvent read_only via a temporary tif, which should be picked up by data_file_globs
ds = gdal.GetDriverByName("GTiff").CreateCopy(replace_ext(target_filename, '.tif'), ds, strict=0)
try:
gcps = ds.GetGCPs()
gt = gdal.GCPsToGeoTransform(gcps)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment