执行坐标系转换的库?

5

是否有一个Python库能够处理坐标系转换? 我在使用numpy meshgrids时,有时需要切换坐标系。 由于不想重复造轮子,是否有任何可以处理以下内容的库:

  • 转换(笛卡尔、球形、极坐标等)
  • 平移
  • 旋转?
2个回答

4
你可以使用shapely库: http://toblerity.org/shapely/manual.html 仿射变换: http://toblerity.org/shapely/manual.html#affine-transformations 坐标变换: http://toblerity.org/shapely/manual.html#other-transformations 示例代码:
from shapely.geometry import Point
from functools import partial
import pyproj
from shapely.ops import transform

point1 = Point(9.0, 50.0)

print (point1)

project = partial(
    pyproj.transform,
    pyproj.Proj('epsg:4326'),
    pyproj.Proj('epsg:32632'))

point2 = transform(project, point1)
print (point2)

你也可以使用 ogr 库。例如:

from osgeo import ogr
from osgeo import osr

source = osr.SpatialReference()
source.ImportFromEPSG(2927)

target = osr.SpatialReference()
target.ImportFromEPSG(4326)

transform = osr.CoordinateTransformation(source, target)

point = ogr.CreateGeometryFromWkt("POINT (1120351.57 741921.42)")
point.Transform(transform)

print (point.ExportToWkt())

(来自http://pcjericks.github.io/py-gdalogr-cookbook/projection.html


4

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接