Created
March 4, 2021 14:37
-
-
Save nmathewa/581119781d6c71f184f4d7e8dfac3299 to your computer and use it in GitHub Desktop.
multi_reference.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Created on Thu Mar 4 19:14:00 2021 | |
@author: nma | |
""" | |
import numpy as np | |
from osgeo import gdal,osr | |
data_dir = "input_data" | |
ref_img = "reference_data" | |
out_dir = "out_putfile" | |
ref_ras = gdal.Open(ref_img) | |
rs_ds = gdal.Open(data_dir) | |
refeproj = ref_ras.GetProjection() | |
refe_trnas = ref_ras.GetGeoTransform() | |
inn_data = gdal.Open(data_dir) | |
arrr = inn_data.ReadAsArray() | |
[cols, rows] = arrr.shape | |
driver = driver = gdal.GetDriverByName("GTiff") | |
out_ras = driver.Create(out_dir,rows,cols,1,gdal.GDT_Float64) | |
out_ras.SetProjection(ref_ras.GetProjection()) | |
out_ras.GetRasterBand(1).WriteArray(arrr) | |
out_ras.SetGeoTransform(refe_trnas) | |
srs = osr.SpatialReference() | |
out_ras.FlushCache() ##saves to disk!! | |
out_ras = None | |
band=None |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment