4
$\gingroup$

HiLatLong值和alt值取Geotiff值时有问题, 并想知道这些数据是否以Excel或CSV文件格式公开提供?可惜我自己什么都没发现

my data:https://wetransfer.com/downloads/8e5ba7aa4cd8c406068a60543b353b0420220622084939/d3c744面向知道Python的人

import numpy as np import matplotlib.pyplot as plt from netCDF4 import Dataset import pandas as pd  data = Dataset("C:/Users/Oliver Weisser/Desktop/Bachelor/Programm/Daten/Daten/ETOPO1_Bed_g_gdal.grd",'r') print(data.variables.keys())  lon_range = data.variables['x_range'][:] lat_range = data.variables['y_range'][:] topo_range = data.variables['z_range'][:] spacing = data.variables['spacing'][:] dimension = data.variables['dimension'][:] z = data.variables['z'][:] lon_num =  dimension[0] lat_num =  dimension[1]  lon = np.linspace(lon_range[0],lon_range[1],dimension[0]) lat = np.linspace(lat_range[0],lat_range[1],dimension[1])  topo = np.reshape(z, (lat_num, lon_num))   dfl = pd.DataFrame({         'Latitude': lat.reshape(-1),         'Longitude': lon.reshape(-1),         'Altitude': topo.reshape(-1)         }) print(dfl)

源码 :ETOPO1区域选择

这是我至今所编解码 也许有人会发现那里有窃听器

endgroup元
一号
  • $\gingroup$ 批注非扩展讨论这场对话移位聊天. endgroup元
    - 格力特
    Jun 242022 8点04

1回答一号

重置默认
4
$\gingroup$

所以我希望我终于理解你真正问题所在, 并由此从csv数据中提供高位信息

import numpy as np from netCDF4 import Dataset import matplotlib.pyplot as plt  csv_data = np.loadtxt('1994_12_O18grid.csv',skiprows=1,delimiter=',')  num_el = csv_data[:,0] lat = csv_data[:,1] lon = csv_data[:,2] value = csv_data[:,3]  data = Dataset("ETOPO1_Bed_g_gdal.grd",'r') lon_range = data.variables['x_range'][:] lat_range = data.variables['y_range'][:] topo_range = data.variables['z_range'][:] spacing = data.variables['spacing'][:] dimension = data.variables['dimension'][:] z = data.variables['z'][:] lon_num =  dimension[0] lat_num =  dimension[1]  etopo_lon = np.linspace(lon_range[0],lon_range[1],dimension[0]) etopo_lat = np.linspace(lat_range[0],lat_range[1],dimension[1]) topo = np.reshape(z, (lat_num, lon_num))  height = np.empty_like(num_el) for i in range(len(num_el)):  #in this loop we search for the height values for the specific lat and lon values from your csv     desired_lat_idx = np.abs(etopo_lat - lat[i]).argmin()     desired_lon_idx = np.abs(etopo_lon - lon[i]).argmin()     height[i] = topo[desired_lat_idx,desired_lon_idx]  plt.figure() height[height<0]=0 # if you want to disregard values below 0 plt.imshow(np.reshape(height,(180,360))) # if the resolution of your csv data changes from 1 degree to something different you need to chance the values in the reshape.简单化我硬码数

查找高度效率不高,但我没有时间做适当的numpy样式解法

endgroup元
6
  • $\gingroup$ 详细查一查但它看起来很有希望非常感谢你的时间 并耐心回答我 endgroup元
    - 微信
    军士22202212点08
  • 一号
    $\gingroup$ 欢迎你,也许作为未来建议 尝试更好地编解题人民能更快地帮助你 endgroup元 军士22202212: 13
  • 一号
    $\gingroup$ 好,我照办你可能注意到我新编码并仍然需要帮助:-) endgroup元
    - 微信
    军士2220221214
  • $\gingroup$ 对,别担心每个人从点开始 endgroup元 军士22202212: 25
  • $\gingroup$ Hi/Lat/Value/Altitude问题不明时,我将尝试在新题中再次详解问题 endgroup元
    - 微信
    军士232022

答案解答

点击后答题后,你同意我们服务条件并承认你读理解隐私策略行为规范.

不是你要找的答案浏览其他问题贴上标签 问题自问.