def get_elevation(self, lat, lon): """ Returns the elevation in metres of point (lat, lon). Uses bilinar interpolation to interpolate the SRTM data to the required point. """ print "lon, lat: ", lon, lat print "geotransform : ", gdal.InvGeoTransform(self.geotransform) col_f, row_f = gdal.ApplyGeoTransform(gdal.InvGeoTransform(self.geotransform), lon, lat) col = int(col_f) row = int(row_f) # NOTE - THIS IS A FIDDLE TO STOP ERRORS AT THE EDGE OF # TILES - IT IS NO CORRECT - WE SHOULD GET TWO POINTS # FROM THE NEXT TILE. #if row==5999: row=5998 #if col==5999: col=5998 if row>3600: row=3600 if row>3600: row=3600 if col>3600: col=3600 if col>3600: col=3600 htarr = gdalnumeric.DatasetReadAsArray(self.tile['dataset'], col, row, 2, 2) height = bilinear_interpolation(htarr[0][0], htarr[0][1], htarr[1][0], htarr[1][1], row_f-row, col_f-col) return height
def get_elevation(self, lat, lon): """ Returns the elevation in metres of point (lat, lon). Uses bilinar interpolation to interpolate the SRTM data to the required point. """ row, col, row_f, col_f = self.pos_from_lat_lon(lat, lon) # NOTE - THIS IS A FIDDLE TO STOP ERRORS AT THE EDGE OF # TILES - IT IS NO CORRECT - WE SHOULD GET TWO POINTS # FROM THE NEXT TILE. #if row==5999: row=5998 #if col==5999: col=5998 if row==1200: row=1199 if row==1199: row=1198 if col==1200: col=1199 if col==1199: col=1198 #~ print row, col htarr = gdalnumeric.DatasetReadAsArray(self.tile['dataset'], col, row, 2, 2) height = bilinear_interpolation(htarr[0][0], htarr[0][1], htarr[1][0], htarr[1][1], row_f-row, col_f-col) return height