From How to extract elevation from .HGT file? I know how to get the elevation from SRTM1 and SRTM3 files. But how to get elevation from SRTM30 Plus ftp://topex.ucsd.edu/pub/srtm30_plus/srtm30/data/ ?
I tried to use the following code, but it returns the incorrect values:
def read_elevation_from_file_srtm30_plus(hgt_file, lon, lat):
with open('e060n40.Bathymetry.srtm', 'rb') as hgt_data:
# HGT is 16bit signed integer(i2) - big endian(>)
elevations = np.fromfile(hgt_data, np.dtype('>i2'), 6000*4800)\
.reshape((6000, 4800))
lat_y = int(round((lat - int(lat)) * 6000, 0))
lon_x = int(round((lon - int(lon)) * 4800, 0))
return elevations[6000 - lat_y, lon_x].astype(int)
What am I doing wrong?
lat_y = int(round((lat - int(lat)) * 5999, 0)) lon_x = int(round((lon - int(lon)) * 4799, 0))– LuFang Jun 22 '17 at 12:43