easyidp.geotools.convert_proj

easyidp.geotools.convert_proj(shp_dict, crs_origin, crs_target)

基于 pyproj 包提供地理坐标转换

参数:
  • shp_dict (dict) -- read_shp() 函数的输出

  • crs_origin (pyproj object) -- read_shp(..., return_proj=True) 的隐藏输出

  • crs_target (str | pyproj object) --

    例子:
    crs_target = pyproj.CRS.from_epsg(4326)
    crs_target = r'path/to/{shp_name}.prj'

示例

数据准备

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

>>> plot = {'N1W1': np.array([[139.54052962,  35.73475194], [139.54055106,  35.73475596]])}

>>> proj = pyproj.CRS.from_epsg(4326)
>>> proj_to = pyproj.CRS.from_epsg(32654)

然后将经纬度坐标转换为 WGS 84 / UTM 第 54N 区(CRS: EPSG:32654)

>>> idp.geotools.convert_proj(plot, proj, proj_to)
{'N1W1': array([[ 368017.75637046, 3955511.0806603 ],
                [ 368019.70199342, 3955511.49771163]])}