Commit b00ca185 authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

added Python 2.7 compatibilty; added GDAL downwards compatibility

- added new package 'compatibility'  that ensures that the code also works with older versions of Python and GDAL
- added __init__.py to package level

geo.raster.reproject:
- warp_ndarray(): some modifications to ensure compatibility

geo.coord_trafo:
- lonlat_to_pixel(): fixed a Python 2.7 incompatibility

io.raster.gdal:
get_GDAL_ds_inmem(): some modifications to ensure compatibility

io.raster.GeoArray:
- fixed some Python 2.7 incompatibilies

io.temp_io: added new module temp_io for managing temporary files

processing.shell:
- subcall_with_output(): added verbose mode

ptds.__init__:
- added validation of GDAL version
parent 00152cf0
__author__='Daniel Scheffler'
from . import ptds
__all__=['ptds']
\ No newline at end of file
...@@ -11,10 +11,26 @@ from .io.raster.GeoArray import GeoArray ...@@ -11,10 +11,26 @@ from .io.raster.GeoArray import GeoArray
#from py_tools_ds.ptds.io.raster.GeoArray import GeoArray #from py_tools_ds.ptds.io.raster.GeoArray import GeoArray
__all__=['io', __all__=['io',
'map', 'geo',
'numeric', 'numeric',
'processing', 'processing',
'GeoArray'] 'GeoArray']
__version__ = '20160927.01' __version__ = '20161027_01'
__author__='Daniel Scheffler' __author__='Daniel Scheffler'
\ No newline at end of file
# Validate GDAL version
try:
import gdal
except:
from osgeo import gdal
try:
gdal.Warp
gdal.Translate
gdal.OpenNumPyArray
except AttributeError:
import warnings
warnings.warn("Your GDAL version is too old to support all functionalities of the 'py_tools_ds' package. "
"Please update GDAL!")
del gdal
\ No newline at end of file
__author__='Daniel Scheffler'
from . import gdal
__all__=['gdal',
'gdalnumeric']
\ No newline at end of file
# -*- coding: utf-8 -*-
__author__ = "Daniel Scheffler"
import os
try:
from osgeo import gdal
from osgeo import gdalnumeric
from osgeo import gdalconst
except ImportError:
import gdal
import gdalnumeric
import gdalconst
from ..processing.shell import subcall_with_output
from ..io.temp_io import get_tempfile
def Warp(destNameOrDestDS, srcDSOrSrcDSTab, options = '', format = 'GTiff',
outputBounds = None,
outputBoundsSRS = None,
xRes = None, yRes = None, targetAlignedPixels = False,
width = 0, height = 0,
srcSRS = None, dstSRS = None,
srcAlpha = False, dstAlpha = False,
warpOptions = None, errorThreshold = None,
warpMemoryLimit = None, creationOptions = None, outputType = gdal.GDT_Unknown,
workingType = gdal.GDT_Unknown, resampleAlg = None,
srcNodata = None, dstNodata = None, multithread = False,
tps = False, rpc = False, geoloc = False, polynomialOrder = None,
transformerOptions = None, cutlineDSName = None,
cutlineLayer = None, cutlineWhere = None, cutlineSQL = None, cutlineBlend = None, cropToCutline = False,
copyMetadata = True, metadataConflictValue = None,
setColorInterpretation = False,
callback = None, callback_data = None):
""" This functions brings functionality of gdal.Warp() that is not available in GDAL versions below 2.1 (?).
Keyword arguments are :
options --- can be be an array of strings, a string or let empty and filled from other keywords.
format --- output format ("GTiff", etc...)
outputBounds --- output bounds as (minX, minY, maxX, maxY) in target SRS
outputBoundsSRS --- SRS in which output bounds are expressed, in the case they are not expressed in dstSRS
xRes, yRes --- output resolution in target SRS
targetAlignedPixels --- whether to force output bounds to be multiple of output resolution
width --- width of the output raster in pixel
height --- height of the output raster in pixel
srcSRS --- source SRS
dstSRS --- output SRS
srcAlpha --- whether to force the last band of the input dataset to be considered as an alpha band
dstAlpha --- whether to force the creation of an output alpha band
outputType --- output type (gdal.GDT_Byte, etc...)
workingType --- working type (gdal.GDT_Byte, etc...)
warpOptions --- list of warping options
errorThreshold --- error threshold for approximation transformer (in pixels)
warpMemoryLimit --- size of working buffer in bytes
resampleAlg --- resampling mode
creationOptions --- list of creation options
srcNodata --- source nodata value(s)
dstNodata --- output nodata value(s)
multithread --- whether to multithread computation and I/O operations
tps --- whether to use Thin Plate Spline GCP transformer
rpc --- whether to use RPC transformer
geoloc --- whether to use GeoLocation array transformer
polynomialOrder --- order of polynomial GCP interpolation
transformerOptions --- list of transformer options
cutlineDSName --- cutline dataset name
cutlineLayer --- cutline layer name
cutlineWhere --- cutline WHERE clause
cutlineSQL --- cutline SQL statement
cutlineBlend --- cutline blend distance in pixels
cropToCutline --- whether to use cutline extent for output bounds
copyMetadata --- whether to copy source metadata
metadataConflictValue --- metadata data conflict value
setColorInterpretation --- whether to force color interpretation of input bands to output bands
callback --- callback method
callback_data --- user data for callback
"""
new_options = options
#new_options += ['-of', format]
if outputType != gdal.GDT_Unknown:
new_options += ['-ot', gdal.GetDataTypeName(outputType) ]
if workingType != gdal.GDT_Unknown:
new_options += ['-wt', gdal.GetDataTypeName(workingType) ]
if outputBounds is not None:
new_options += ['-te', str(outputBounds[0]), str(outputBounds[1]), str(outputBounds[2]), str(outputBounds[3]) ]
if outputBoundsSRS is not None:
new_options += ['-te_srs', str(outputBoundsSRS) ]
if xRes is not None and yRes is not None:
new_options += ['-tr', str(xRes), str(yRes) ]
if width or height:
new_options += ['-ts', str(width), str(height)]
if srcSRS is not None:
new_options += ['-s_srs', str(srcSRS) ]
if dstSRS is not None:
new_options += ['-t_srs', str(dstSRS) ]
if targetAlignedPixels:
new_options += ['-tap']
if srcAlpha:
new_options += ['-srcalpha']
if dstAlpha:
new_options += ['-dstalpha']
if warpOptions is not None:
for opt in warpOptions:
new_options += ['-wo', str(opt)]
if errorThreshold is not None:
new_options += ['-et', str(errorThreshold)]
if resampleAlg is not None:
if resampleAlg == gdal.GRA_NearestNeighbour:
new_options += ['-r', 'near']
elif resampleAlg == gdal.GRA_Bilinear:
new_options += ['-rb']
elif resampleAlg == gdal.GRA_Cubic:
new_options += ['-rc']
elif resampleAlg == gdal.GRA_CubicSpline:
new_options += ['-rcs']
elif resampleAlg == gdal.GRA_Lanczos:
new_options += ['-r', 'lanczos']
elif resampleAlg == gdal.GRA_Average:
new_options += ['-r', 'average']
elif resampleAlg == gdal.GRA_Mode:
new_options += ['-r', 'mode']
else: # gdal.GRA_Gauss is missing
new_options += ['-r', str(resampleAlg) ]
if warpMemoryLimit is not None:
new_options += ['-wm', str(warpMemoryLimit) ]
if creationOptions is not None:
for opt in creationOptions:
new_options += ['-co', opt ]
if srcNodata is not None:
new_options += ['-srcnodata', str(srcNodata) ]
if dstNodata is not None:
new_options += ['-dstnodata', str(dstNodata) ]
if multithread:
new_options += ['-multi']
if tps:
new_options += ['-tps']
if rpc:
new_options += ['-rpc']
if geoloc:
new_options += ['-geoloc']
if polynomialOrder is not None:
new_options += ['-order', str(polynomialOrder)]
if transformerOptions is not None:
for opt in transformerOptions:
new_options += ['-to', opt ]
if cutlineDSName is not None:
new_options += ['-cutline', str(cutlineDSName) ]
if cutlineLayer is not None:
new_options += ['-cl', str(cutlineLayer) ]
if cutlineWhere is not None:
new_options += ['-cwhere', str(cutlineWhere) ]
if cutlineSQL is not None:
new_options += ['-csql', str(cutlineSQL) ]
if cutlineBlend is not None:
new_options += ['-cblend', str(cutlineBlend) ]
if cropToCutline:
new_options += ['-crop_to_cutline']
if not copyMetadata:
new_options += ['-nomd']
if metadataConflictValue:
new_options += ['-cvmd', str(metadataConflictValue) ]
if setColorInterpretation:
new_options += ['-setci']
if isinstance(srcDSOrSrcDSTab, gdal.Dataset):
drv = gdal.GetDriverByName('ENVI')
inPath = get_tempfile(prefix='warp_in_', ext='.bsq')
drv.CreateCopy(inPath, srcDSOrSrcDSTab)
srcDSOrSrcDSTab = None
elif isinstance(srcDSOrSrcDSTab,str):
inPath = srcDSOrSrcDSTab
else:
raise ValueError
warpedPath = get_tempfile(prefix='warp_out_', ext='.bsq')
out, exitcode, err = subcall_with_output('gdalwarp %s %s -of ENVI -overwrite %s'
%(inPath, warpedPath, ' '.join(new_options)))
if exitcode:
raise Exception(err)
ds = gdal.Open(warpedPath)
if ds is None:
raise Exception(gdal.GetLastErrorMsg())
drv = gdal.GetDriverByName('MEM')
mem_ds = drv.CreateCopy(warpedPath, ds)
# cleanup
ds = None
[gdal.Unlink(p) for p in [inPath, os.path.splitext(inPath) [0] + '.hdr']]
[gdal.Unlink(p) for p in [warpedPath, os.path.splitext(warpedPath)[0] + '.hdr']]
return mem_ds
def TranslateOptions(destNameOrDestDS, srcDSOrSrcDSTab, options = '', format = 'GTiff',
outputType = gdal.GDT_Unknown, bandList = None, maskBand = None,
width = 0, height = 0, widthPct = 0.0, heightPct = 0.0,
xRes = 0.0, yRes = 0.0,
creationOptions = None, srcWin = None, projWin = None, projWinSRS = None, strict = False,
unscale = False, scaleParams = None, exponents = None,
outputBounds = None, metadataOptions = None,
outputSRS = None, GCPs = None,
noData = None, rgbExpand = None,
stats = False, rat = True, resampleAlg = None,
callback = None, callback_data = None):
""" This functions brings functionality of gdal.Translate() that is not available in GDAL versions below 2.1 (?).
Keyword arguments are :
options --- can be be an array of strings, a string or let empty and filled from other keywords.
format --- output format ("GTiff", etc...)
outputType --- output type (gdal.GDT_Byte, etc...)
bandList --- array of band numbers (index start at 1)
maskBand --- mask band to generate or not ("none", "auto", "mask", 1, ...)
width --- width of the output raster in pixel
height --- height of the output raster in pixel
widthPct --- width of the output raster in percentage (100 = original width)
heightPct --- height of the output raster in percentage (100 = original height)
xRes --- output horizontal resolution
yRes --- output vertical resolution
creationOptions --- list of creation options
srcWin --- subwindow in pixels to extract: [left_x, top_y, width, height]
projWin --- subwindow in projected coordinates to extract: [ulx, uly, lrx, lry]
projWinSRS --- SRS in which projWin is expressed
strict --- strict mode
unscale --- unscale values with scale and offset metadata
scaleParams --- list of scale parameters, each of the form [src_min,src_max] or [src_min,src_max,dst_min,dst_max]
exponents --- list of exponentiation parameters
outputBounds --- assigned output bounds: [ulx, uly, lrx, lry]
metadataOptions --- list of metadata options
outputSRS --- assigned output SRS
GCPs --- list of GCPs
noData --- nodata value (or "none" to unset it)
rgbExpand --- Color palette expansion mode: "gray", "rgb", "rgba"
stats --- whether to calculate statistics
rat --- whether to write source RAT
resampleAlg --- resampling mode
callback --- callback method
callback_data --- user data for callback
"""
new_options = options
new_options += ['-of', format]
if outputType != gdal.GDT_Unknown:
new_options += ['-ot', gdal.GetDataTypeName(outputType) ]
if maskBand is not None:
new_options += ['-mask', str(maskBand) ]
if bandList is not None:
for b in bandList:
new_options += ['-b', str(b) ]
if width != 0 or height != 0:
new_options += ['-outsize', str(width), str(height)]
elif widthPct != 0 and heightPct != 0:
new_options += ['-outsize', str(widthPct) + '%%', str(heightPct) + '%%']
if creationOptions is not None:
for opt in creationOptions:
new_options += ['-co', opt ]
if srcWin is not None:
new_options += ['-srcwin', str(srcWin[0]), str(srcWin[1]), str(srcWin[2]), str(srcWin[3])]
if strict:
new_options += ['-strict']
if unscale:
new_options += ['-unscale']
if scaleParams:
for scaleParam in scaleParams:
new_options += ['-scale']
for v in scaleParam:
new_options += [ str(v) ]
if exponents:
for exponent in exponents:
new_options += ['-exponent', str(exponent)]
if outputBounds is not None:
new_options += ['-a_ullr', str(outputBounds[0]), str(outputBounds[1]), str(outputBounds[2]), str(outputBounds[3])]
if metadataOptions is not None:
for opt in metadataOptions:
new_options += ['-mo', opt ]
if outputSRS is not None:
new_options += ['-a_srs', str(outputSRS) ]
if GCPs is not None:
for gcp in GCPs:
new_options += ['-gcp', str(gcp.GCPPixel), str(gcp.GCPLine), str(gcp.GCPX), str(gcp.GCPY), str(gcp.GCPZ) ]
if projWin is not None:
new_options += ['-projwin', str(projWin[0]), str(projWin[1]), str(projWin[2]), str(projWin[3])]
if projWinSRS is not None:
new_options += ['-projwin_srs', str(projWinSRS) ]
if noData is not None:
new_options += ['-a_nodata', str(noData) ]
if rgbExpand is not None:
new_options += ['-expand', str(rgbExpand) ]
if stats:
new_options += ['-stats']
if not rat:
new_options += ['-norat']
if resampleAlg is not None:
if resampleAlg == gdal.GRA_NearestNeighbour:
new_options += ['-r', 'near']
elif resampleAlg == gdal.GRA_Bilinear:
new_options += ['-r', 'bilinear']
elif resampleAlg == gdal.GRA_Cubic:
new_options += ['-r', 'cubic']
elif resampleAlg == gdal.GRA_CubicSpline:
new_options += ['-r', 'cubicspline']
elif resampleAlg == gdal.GRA_Lanczos:
new_options += ['-r', 'lanczos']
elif resampleAlg == gdal.GRA_Average:
new_options += ['-r', 'average']
elif resampleAlg == gdal.GRA_Mode:
new_options += ['-r', 'mode']
else:
new_options += ['-r', str(resampleAlg) ]
if xRes != 0 and yRes != 0:
new_options += ['-tr', str(xRes), str(yRes) ]
if isinstance(srcDSOrSrcDSTab, gdal.Dataset):
drv = gdal.GetDriverByName('ENVI')
inPath = get_tempfile(prefix='translate_in_', ext='.bsq')
drv.CreateCopy(inPath, srcDSOrSrcDSTab)
srcDSOrSrcDSTab = None
elif isinstance(srcDSOrSrcDSTab,str):
inPath = srcDSOrSrcDSTab
else:
raise ValueError
translatedPath = get_tempfile(prefix='translate_out_', ext='.bsq')
out, exitcode, err = subcall_with_output('gdal_translate %s %s -of ENVI %s'
%(inPath, translatedPath, ' '.join(new_options)))
if exitcode:
raise Exception(err)
ds = gdal.Open(translatedPath)
if ds is None:
raise Exception(gdal.GetLastErrorMsg())
drv = gdal.GetDriverByName('MEM')
mem_ds = drv.CreateCopy(translatedPath, ds)
# cleanup
ds = None
[gdal.Unlink(p) for p in [inPath, os.path.splitext(inPath) [0] + '.hdr']]
[gdal.Unlink(p) for p in [translatedPath, os.path.splitext(translatedPath)[0] + '.hdr']]
return mem_ds
def ensure_GDAL_version_compatibility(func2run, funcName2ensure):
import functools
try:
getattr(gdal, funcName2ensure)
except AttributeError:
if funcName2ensure in globals():
setattr(gdal,funcName2ensure, globals()[funcName2ensure])
else:
raise AttributeError("'gdal' has no attribute '%s'." %funcName2ensure)
@functools.wraps(func2run)
def inner(*args, **kwargs):
return func2run(*args, **kwargs)
return inner
def ensure_GDAL_version_compatibility(funcName2ensure):
try:
getattr(gdal, funcName2ensure)
funcIsMissing = False
except AttributeError:
funcIsMissing = True
print('drin1')
if funcName2ensure in globals():
print('drin2')
setattr(gdal,funcName2ensure, globals()[funcName2ensure])
print('pre', globals()[funcName2ensure])
gdal.Warp = globals()[funcName2ensure]
from gdal import Warp
print('pre2', Warp)
#print(importlib.import_module('gdal.%s' % funcName2ensure))
else:
raise AttributeError("'gdal' has no attribute '%s'." %funcName2ensure)
def real_decorator(function):
def wrapper(*args, **kwargs):
return function(*args, **kwargs)
return wrapper
if funcIsMissing:
delattr(gdal,funcName2ensure)
return real_decorator
def get_gdal_func(funcName):
try:
return getattr(gdal,funcName)
except AttributeError:
if funcName in globals():
return globals()[funcName]
else:
raise AttributeError("'gdal' has no attribute '%s'." % funcName)
\ No newline at end of file
# -*- coding: utf-8 -*-
__author__ = "Daniel Scheffler"
try:
from osgeo import gdal
from osgeo import gdalnumeric
from osgeo import gdalconst
except ImportError:
import gdal
import gdalnumeric
import gdalconst
def OpenNumPyArray(array):
"""This function emulates the functionality of gdalnumeric.OpenNumPyArray() which is not available in GDAL versions
below 2.1.0 (?).
:param array:
:return:
"""
rows, cols = array.shape[:2]
bands = array.shape[2] if array.ndim == 3 else 1
gdal_dtype = gdalnumeric.NumericTypeCodeToGDALTypeCode(array.dtype)
mem_drv = gdal.GetDriverByName('MEM')
mem_ds = mem_drv.Create('/vsimem/tmp/memfile.mem', cols, rows, bands, gdal_dtype)
if mem_ds is None:
raise Exception(gdal.GetLastErrorMsg())
for bandNr in range(bands):
band = mem_ds.GetRasterBand(bandNr + 1)
band.WriteArray(array[:, :, bandNr] if bands > 1 else array)
band = None
mem_ds.FlushCache() # Write to disk.
return mem_ds
def get_gdalnumeric_func(funcName):
try:
return getattr(gdal, funcName)
except AttributeError:
if funcName in globals():
return globals()[funcName]
else:
raise AttributeError("'gdalnumeric' has no attribute '%s'." % funcName)
\ No newline at end of file
...@@ -24,7 +24,6 @@ def get_corner_coordinates(gdal_ds=None, gt=None, cols=None, rows=None): ...@@ -24,7 +24,6 @@ def get_corner_coordinates(gdal_ds=None, gt=None, cols=None, rows=None):
y=gdal_ds_GT[3]+(px*gdal_ds_GT[4])+(py*gdal_ds_GT[5]) y=gdal_ds_GT[3]+(px*gdal_ds_GT[4])+(py*gdal_ds_GT[5])
ext.append([x,y]) ext.append([x,y])
yarr.reverse() yarr.reverse()
gdal_ds_GT = None
return ext return ext
......
...@@ -255,7 +255,6 @@ def latLonToPixel(latLonPairs, path_im=None, geotransform=None, projection=None) ...@@ -255,7 +255,6 @@ def latLonToPixel(latLonPairs, path_im=None, geotransform=None, projection=None)
pixelPairs.append([int(x), int(y)]) pixelPairs.append([int(x), int(y)])
return pixelPairs return pixelPairs
def lonlat_to_pixel(lon, lat, inverse_geo_transform): def lonlat_to_pixel(lon, lat, inverse_geo_transform):
"""Translates the given lon, lat to the grid pixel coordinates in data array (zero start)""" """Translates the given lon, lat to the grid pixel coordinates in data array (zero start)"""
# transform to utm # transform to utm
...@@ -276,7 +275,8 @@ def transform_GCPlist(gcpList, prj_src, prj_tgt): ...@@ -276,7 +275,8 @@ def transform_GCPlist(gcpList, prj_src, prj_tgt):
:param prj_tgt: WKT string :param prj_tgt: WKT string
:return: :return:
""" """
return [gdal.GCP(*transform_any_prj(prj_src, prj_tgt, GCP.GCPX, GCP.GCPY), GCP.GCPZ, GCP.GCPPixel, GCP.GCPLine) return [gdal.GCP(*(list(transform_any_prj(prj_src, prj_tgt, GCP.GCPX, GCP.GCPY))+
[GCP.GCPZ, GCP.GCPPixel, GCP.GCPLine])) # Python 2.7 compatible syntax
for GCP in gcpList] for GCP in gcpList]
......
...@@ -23,6 +23,7 @@ from ..coord_trafo import pixelToLatLon ...@@ -23,6 +23,7 @@ from ..coord_trafo import pixelToLatLon
from ... import GeoArray from ... import GeoArray
from ...io.raster.gdal import get_GDAL_ds_inmem from ...io.raster.gdal import get_GDAL_ds_inmem
from ...processing.progress_mon import printProgress from ...processing.progress_mon import printProgress
from ...compatibility.gdal import get_gdal_func
# dictionary to translate GDAL data types (strings) in corresponding numpy data types # dictionary to translate GDAL data types (strings) in corresponding numpy data types
...@@ -142,7 +143,8 @@ def warp_ndarray_OLD(ndarray, in_gt, in_prj, out_prj, out_gt=None, outRowsCols=N ...@@ -142,7 +143,8 @@ def warp_ndarray_OLD(ndarray, in_gt, in_prj, out_prj, out_gt=None, outRowsCols=N
if var1: if var1:
src_transform = rasterio.transform.from_origin(in_gt[0], in_gt[3], in_gt[1], abs(in_gt[5])) src_transform = rasterio.transform.from_origin(in_gt[0], in_gt[3], in_gt[1], abs(in_gt[5]))
print('calc_trafo_args') print('calc_trafo_args')
[print(i, '\n') for i in [src_crs, dst_crs, cols, rows, left, bottom, right, top, out_res]] for i in [src_crs, dst_crs, cols, rows, left, bottom, right, top, out_res]:
print(i, '\n')
from ...io.raster.GeoArray import GeoArray from ...io.raster.GeoArray import GeoArray
left, right, bottom, top = GeoArray(ndarray, in_gt, in_prj).box.boundsMap left, right, bottom, top = GeoArray(ndarray, in_gt, in_prj).box.boundsMap
...@@ -153,7 +155,8 @@ def warp_ndarray_OLD(ndarray, in_gt, in_prj, out_prj, out_gt=None, outRowsCols=N ...@@ -153,7 +155,8 @@ def warp_ndarray_OLD(ndarray, in_gt, in_prj, out_prj, out_gt=None, outRowsCols=N
out_arr = np.zeros((bands, out_rows, out_cols), out_dtype) \ out_arr = np.zeros((bands, out_rows, out_cols), out_dtype) \
if len(ndarray.shape) == 3 else np.zeros((out_rows, out_cols), out_dtype) if len(ndarray.shape) == 3 else np.zeros((out_rows, out_cols), out_dtype)
print(out_res) print(out_res)
[print(i,'\n') for i in [src_transform, src_crs, dst_transform, dst_crs]] for i in [src_transform, src_crs, dst_transform, dst_crs]:
print(i,'\n')
rio_reproject(ndarray, out_arr, src_transform=src_transform, src_crs=src_crs, dst_transform=dst_transform, rio_reproject(ndarray, out_arr, src_transform=src_transform, src_crs=src_crs, dst_transform=dst_transform,
dst_crs=dst_crs, resampling=dict_rspInt_rspAlg[rsp_alg], src_nodata=in_nodata, dst_nodata=out_nodata) dst_crs=dst_crs, resampling=dict_rspInt_rspAlg[rsp_alg], src_nodata=in_nodata, dst_nodata=out_nodata)
...@@ -194,7 +197,8 @@ def warp_ndarray_OLD(ndarray, in_gt, in_prj, out_prj, out_gt=None, outRowsCols=N ...@@ -194,7 +197,8 @@ def warp_ndarray_OLD(ndarray, in_gt, in_prj, out_prj, out_gt=None, outRowsCols=N
#print(dict_rspInt_rspAlg[rsp_alg]) #print(dict_rspInt_rspAlg[rsp_alg])
#print(in_nodata) #print(in_nodata)
#print(out_nodata) #print(out_nodata)
[print(i, '\n') for i in [in_gt, src_crs, out_gt, dst_crs]] for i in [in_gt, src_crs, out_gt, dst_crs]:
print(i, '\n')
rio_reproject(ndarray, out_arr, rio_reproject(ndarray, out_arr,
src_transform=in_gt, src_crs=src_crs, dst_transform=out_gt, dst_crs=dst_crs, src_transform=in_gt, src_crs=src_crs, dst_transform=out_gt, dst_crs=dst_crs,
resampling=dict_rspInt_rspAlg[rsp_alg], src_nodata=in_nodata, dst_nodata=out_nodata) resampling=dict_rspInt_rspAlg[rsp_alg], src_nodata=in_nodata, dst_nodata=out_nodata)
...@@ -356,7 +360,8 @@ def warp_ndarray(ndarray, in_gt, in_prj, out_prj=None, out_dtype=None, out_gsd=( ...@@ -356,7 +360,8 @@ def warp_ndarray(ndarray, in_gt, in_prj, out_prj=None, out_dtype=None, out_gsd=(
# GDAL Translate if needed # GDAL Translate if needed
if gcpList: if gcpList:
in_ds = gdal.Translate(