I am very new to python and coding. I am trying to make the ice DEM(test5) fit over top of the NZ DEM so that the points line up. The data has different cell sizes. This is what I have so far. All it does is put the data into a numpy array at the moment. I am unsure on what my next steps should be. Attached is a link to a google drive with the files. https://drive.google.com/drive/folders/1E_IxZoA1PnA4gufFHBtLVRtVTUvFNFPs?usp=sharing
# -*- coding: utf-8 -*-
"""
Created on Wed May 19 15:40:19 2021
@author: pyoli286
"""
import numpy as np
# pathDem = str(input("input the path to file for example 'U:/SURV319/lab1work/lab1/': "))
# nameDem = str(input("input .asc file. For example 'nzdem1000.asc': "))
# pathIce = str(input("input the path to file for example 'U:/SURV319/lab1work/lab1/': "))
# nameIce = str(input("input .asc file. For example 'nzdem1000.asc': "))
pathDem = "/Users/liampyott/Documents/2021/319/Lab3/work/"
nameDem = "nzdem1000.asc"
pathIce = "/Users/liampyott/Documents/2021/319/Lab3/work/"
nameIce = "test5.asc"
def demNZ (inDemNz):
"""
takes the DEM for New Zealand and reads the first 6 lines and ads to a numpy array
"""
f = open(inDemNz, 'r')
headerline1 = f.readline()
headerline1 = headerline1.split()
NCOLS = int(headerline1[1])
headerline2 = f.readline()
headerline2 = headerline2.split()
NROWS = int(headerline2[1])
headerline3 = f.readline()
headerline3 = headerline3.split()
XLLCORNER = int(headerline3[1])
headerline4 = f.readline()
headerline4 = headerline4.split()
YLLCORNER = int(headerline4[1])
headerline5 = f.readline()
headerline5 = headerline5.split()
CELLSIZE = int(headerline5[1])
headerline6 = f.readline()
headerline6 = headerline6.split()
NODATA_VALUE = int(headerline6[1])
nzDem = []
for row in f:
row = row.split()
for col in row:
nzDem.append(float(col))
nzdem2d = np.reshape(nzDem, (NROWS, NCOLS))
return nzdem2d
def demIce (inDemIce):
"""
takes the DEM for ice and reads the first 6 lines and and ads to a numpy array
"""
f = open(inDemIce, 'r')
headerline1 = f.readline()
headerline1 = headerline1.split()
NCOLS = int(headerline1[1])
headerline2 = f.readline()
headerline2 = headerline2.split()
NROWS = int(headerline2[1])
headerline3 = f.readline()
headerline3 = headerline3.split()
XLLCORNER = int(headerline3[1])
headerline4 = f.readline()
headerline4 = headerline4.split()
YLLCORNER = int(headerline4[1])
headerline5 = f.readline()
headerline5 = headerline5.split()
CELLSIZE = int(headerline5[1])
headerline6 = f.readline()
headerline6 = headerline6.split()
NODATA_VALUE = int(headerline6[1])
iceDem = []
for row in f:
row = row.split()
for col in row:
iceDem.append(float(col))
ice2d = np.reshape(iceDem, (NROWS, NCOLS))
f.close
return ice2d
inDemNz = (pathDem+nameDem)
inDemIce = (pathIce+nameIce)
demNZ(inDemNz)
demIce(inDemIce)