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

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
    关注
    评论

报告相同问题?

悬赏问题

  • ¥50 comsol稳态求解器 找不到解,奇异矩阵有1个空方程返回的解不收敛。没有返回所有参数步长;pid控制
  • ¥15 怎么让wx群机器人发送音乐
  • ¥15 fesafe材料库问题
  • ¥35 beats蓝牙耳机怎么查看日志
  • ¥15 Fluent齿轮搅油
  • ¥15 八爪鱼爬数据为什么自己停了
  • ¥15 交替优化波束形成和ris反射角使保密速率最大化
  • ¥15 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功