zly272823 2019-09-19 17:00 采纳率: 0%
浏览 656
已结题

python读取hgt文件的坐标不统一

第一张为Global mapper打开3个hgt文件——N39E115.hgt、N39E116.hgt、N39E117.hgt第二张为下列python程序打开3个hgt文件——N39E115.hgt、N39E116.hgt、N39E117.hgt

为什么每个数据块显示的方向会不一样,不应该栅格数据自己本身是有经纬度,能够定位的吗?

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()

  • 写回答

2条回答 默认 最新

  • dabocaiqq 2019-09-19 17:14
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置