Как записать Отражение и Сияние в GTIFF - PullRequest
1 голос
/ 09 июля 2019

есть 2 файла:
1. Данные включают отражательную способность и сияние.
2. Содержит ссылку на координаты места.

Как связать эти данные с файлом GEOTIFF. Перепробовал много вариантов. Ничто не приходит на ум.

Методы получения итогов

def getRadianceAndReflectance(filePath):
    with h5py.File(filePathToSVI01, "r") as f:
        a_group_key = list(f.keys())
        group = f['All_Data']
        data = group['VIIRS-I1-SDR_All']
        print(data['/All_Data/VIIRS-I1-SDR_All/Radiance'])
        print(data['/All_Data/VIIRS-I1-SDR_All/Reflectance'])

        n1 = np.array(data['/All_Data/VIIRS-I1-SDR_All/Radiance'])
        n2 = np.array(data['/All_Data/VIIRS-I1-SDR_All/Reflectance'])
    return Data(n1, n2)
def getLatLon(filePath):
    with h5py.File(filePath, "r") as f:
        data = f['All_Data']
        dt = data['/All_Data/']
        inputArray = np.array(dt['/All_Data/VIIRS-IMG-GEO_All/Latitude'])
        resultArray = inputArray[inputArray[..., 0] >= 0]
        secondInputArray = np.array(dt['/All_Data/VIIRS-IMG GEO_All/Longitude'])
        secondResultArray = secondInputArray[secondInputArray[..., 0] >= 0]
    return Coord(resultArray, secondResultArray)

Запись в файл, а затем проблемы

from osgeo import gdal
from osgeo import osr
import numpy as np
import os, sys

image_size = (400,400)

obj = getLatLon(filePathToGIMGO)

#  Choose some Geographic Transform (Around Lake Tahoe)
lat = [obj.lat.min(),obj.lat.max()]
lon = [obj.lon.min(),obj.lon.max()]
print(lat)
print(lon)

#  Create Each Channel

#r_pixels = np.zeros((image_size), dtype=np.uint8)
#g_pixels = np.zeros((image_size), dtype=np.uint8)
#b_pixels = np.zeros((image_size), dtype=np.uint8)

#  Set the Pixel Data (Create some boxes)
for x in range(0,image_size[0]):
    for y in range(0,image_size[1]):
        if x < image_size[0]/2 and y < image_size[1]/2:
            r_pixels[y,x] = 255
        elif x >= image_size[0]/2 and y < image_size[1]/2:
            g_pixels[y,x] = 255
        elif x < image_size[0]/2 and y >= image_size[1]/2:
            b_pixels[y,x] = 255
        else:
            r_pixels[y,x] = 255
            g_pixels[y,x] = 255
            b_pixels[y,x] = 255

# set geotransform
nx = image_size[0]
ny = image_size[1]
xmin, ymin, xmax, ymax = [min(lon), min(lat), max(lon), max(lat)]
xres = (xmax - xmin) / float(nx)
yres = (ymax - ymin) / float(ny)
geotransform = (xmin, xres, 0, ymax, 0, -yres)

var = getRadianceAndReflectance(filePathToSVI01) #get Radiance and Reflectance
# I need to write an int array

# create the 3-band raster file
dst_ds = gdal.GetDriverByName('GTiff').Create('myGeoTIFF.tif', 1500, 1500, 3, gdal.GDT_Byte)

dst_ds.SetGeoTransform(geotransform)    # specify coords
srs = osr.SpatialReference()            # establish encoding
srs.ImportFromEPSG(3857)                # WGS84 lat/long
dst_ds.SetProjection(srs.ExportToWkt()) # export coords to file

#dst_ds.GetRasterBand(1).WriteArray()   # This!

dst_ds.FlushCache()                     # write to disk
dst_ds = None

Пожалуйста, помогите мне, я провел много времени в Google. Все бесполезно.

...