为什么每个数据块显示的方向会不一样,不应该栅格数据自己本身是有经纬度,能够定位的吗?
import os
# Original file:
#'ftp://e0srp01u.ecs.nasa.gov/srtm/version2/SRTM1/Region_04/N39E115.hgt.zip'
if not os.path.exists('N39E115.hgt.zip'):
# Download the data
try:
from urllib import urlopen
except ImportError:
from urllib.request import urlopen
print('Downloading data, please wait (10M)')
opener = urlopen('ftp://e0srp01u.ecs.nasa.gov/srtm/version2/SRTM1/Region_04/N39E115.hgt.zip')
open('N39E115.hgt.zip', 'wb').write(opener.read())
# Load the data (signed 2 byte integers, big endian) ##########################
import zipfile
import numpy as np
a=np.fromstring(zipfile.ZipFile('N39E115.hgt.zip').read('N39E115.hgt'),'>i2')
b=np.fromstring(zipfile.ZipFile('N39E116.hgt.zip').read('N39E116.hgt'),'>i2')
c=np.fromstring(zipfile.ZipFile('N39E117.hgt.zip').read('N39E117.hgt'),'>i2')
d=np.fromstring(zipfile.ZipFile('N40E115.hgt.zip').read('N40E115.hgt'),'>i2')
e=np.fromstring(zipfile.ZipFile('N40E116.hgt.zip').read('N40E116.hgt'),'>i2')
f=np.fromstring(zipfile.ZipFile('N40E117.hgt.zip').read('N40E117.hgt'),'>i2')
g=np.fromstring(zipfile.ZipFile('N41E115.hgt.zip').read('N41E115.hgt'),'>i2')
h=np.fromstring(zipfile.ZipFile('N41E116.hgt.zip').read('N41E116.hgt'),'>i2')
i=np.fromstring(zipfile.ZipFile('N41E117.hgt.zip').read('N41E117.hgt'),'>i2')
A=np.hstack((a,b,c))
C=np.concatenate([a,b],axis=0)
B=np.append(a,b,axis=0)
data=A
data.shape = (3603,1201)
data = data.astype(np.float32)
# Plot an interesting section #################################################
from mayavi import mlab
data = data[:6000, 0:6000]
# Convert missing values into something more sensible.
data[data == -32768] = data[data > 0].min()
0
mlab.figure(size=(400, 320), bgcolor=(0.16, 0.28, 0.46))
mlab.surf(data, colormap='gist_earth', warp_scale=0.2,
vmin=0, vmax=3000)
# The data takes a lot of memory, and the surf command has created a
# copy. We free the inital memory.
del data
# A view of the canyon
mlab.view(-5.9, 83, 570, [5.3, 20, 238])
mlab.show()