Создание растрового Mosai c с использованием слияния в python - PullRequest
0 голосов
/ 29 января 2020

Я пытаюсь объединить 4 растровых файла (тип данных: float32), код работает, но на выходе получается растр со значениями в диапазоне от 1.79769e + 308 до -1.79769e + 308. Нет значения данных в растре установлено -3,3999999e + 38

Я использую следующий код:

# Set tiles directory and find all files ending with .tif
path = "/home/DATA/" # tiles directory
onlyTIFF = [f for f in listdir(path) if isfile(join(path, f)) and  f.endswith(".tif")]
onlyTIFF = [os.path.join(outdir, f) for f in listdir(outdir) if isfile(join(outdir, f)) and  f.endswith(".tif")]
# List for the source files
src_files_to_mosaic = []
# Iterate over raster files and add them to source -list in 'read mode'
for fp in onlyTIFF:
    src = rio.open(fp)
    src_files_to_mosaic.append(src)
# Merge function returns a single mosaic array and the transformation info
mosaic, out_trans = merge(src_files_to_mosaic)
# Copy the metadata
out_meta = src.meta.copy()

# Update the metadata
out_meta.update({"driver": "GTiff",
                "height": mosaic.shape[1],
                 "width": mosaic.shape[2],
                 "transform": out_trans})
                 "dtype": rio.float32,
                 "count": 1})
with rio.open("/home/DATA/mosaic.tif","w", **out_meta) as dest:
    dest.write(mosaic)
...