easyidp.geotools.convert_proj3d

easyidp.geotools.convert_proj3d(points_np, crs_origin, crs_target, is_xyz=True)

通过 pyproj.CRS.Transformer 函数将一个或多个点从一个 CRS 转换为另一个 CRS

参数:
  • points_np (np.ndarray) -- nx3 的三维坐标点

  • crs_origin (pyproj.CRS object) -- the CRS of points_np

  • crs_target (pyproj.CRS object) -- 目标的 CRS

  • is_xyz (bool, default false) -- points_np 的格式;True:x, y, z;False:经度,纬度,高度

返回类型:

np.ndarray

备注

point_np and fmt parameters

points_np in this format:

   x  y  z
0  1  2  3

points_np in this format:

    lon  lat  alt
0    1    2    3
1    4    5    6

小心

pyproj.CRS 顺序:(纬度,经度,高度),EasyIDP 中的点顺序通常是(经度,纬度,高度)

但如果是 xyz 格式,则无需更改顺序

示例

数据准备

>>> import pyproj
>>> import numpy as np
>>> import easyidp as idp
>>> test_data = idp.data.TestData()

大地三维坐标

>>> geocentric = np.array([-3943658.7087006606, 3363404.124223561, 3704651.3067566575])
>>> geo_c = pyproj.CRS.from_dict({"proj": 'geocent', "ellps": 'WGS84', "datum": 'WGS84'})

相同的点在三维地心坐标中的顺序为 columns=['lon', 'lat', 'alt']

>>> geodetic = np.array([139.54033578028609, 35.73756358928734, 96.87827569602781])
>>> geo_d = pyproj.CRS.from_epsg(4326)

然后进行转换:

>>> out_c = idp.geotools.convert_proj3d(geodetic, geo_d, geo_c, is_xyz=True)
array([-3943658.71530418,  3363404.13219933,  3704651.34270485])

>>> out_d = idp.geotools.convert_proj3d(geocentric, geo_c, geo_d, is_xyz=False)
array([139.5403358 ,  35.73756338,  96.849     ])