2015-01-14 61 views
2

是否有一個處理座標系轉換的python庫? 我正在使用numpy meshgrids,但有時切換座標系有用。 因爲我不想推倒重來,是有其處理任何庫:庫執行座標系變換嗎?

  • 轉換(笛卡爾,球形,極性,...)
  • 旋轉?

回答

4

可以使用勻稱庫: 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(init='epsg:4326'), 
    pyproj.Proj(init='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