我在Anaconda Spyder中使用GDAL遇到了很大的问题,但是我需要执行以下坐标转换:
src_spatialReference = osr.SpatialReference()#input coordinate system
src_spatialReference.ImportFromEPSG(inputCoordSystem) #import coordinate system from EPSG code
dst_spatialReference = osr.SpatialReference()#output coordinate system
dst_spatialReference.ImportFromEPSG(outputCoordSystem) #import coordinate system from EPSG code
transform_coord = osr.CoordinateTransformation(src_spatialReference,dst_spatialReference)
#transform geometry object
geomObj = ogr.CreateGeometryFromWkt(geomObj.wkt) #get geometric Object as WKT (well known text) and transform it to org geoemtry
geomObj.Transform(transform_coord) #transform object to other coordinate system
geomObjTransf=shapely.wkt.loads(geomObj.ExportToWkt()) #create shapely object form org geometry objekt
有人在没有GDAL的情况下有想法吗?
我使用transform
中的shapely
进行了尝试,但我读到它仅适用于点,我需要转换shapefile且仅适用于点。
我正在Anaconda和Python 3.6.4中使用Spyder 3.2.8
非常感谢您的帮助!
答案 0 :(得分:0)
也许这不是最好的解决方案,但这对我来说现在很麻烦:
<?php require 'vendor/autoload.php';
use App\src\{Manager, Worker};
$worker = new Worker();
$manager = new Manager();
$manager->manage($worker);
使用from shapely.geometry import Point
from shapely.geometry import LineString
from pyproj import Proj, transform
df_all = df
# store the measured points in a list
measuredpoints_list = np.array([df_all.LON20Hz.tolist(), df_all.LAT20Hz.tolist()]).T
# transform them to a proj. coord. system
measuredpoints_listtrans = []
for i in range(len(measuredpoints_list)):
measuredpoints_listtrans.append(PyProjTransform(4326, 3581, measuredpoints_list[i]))
cl_trans = []
for i in range(len(cl)):
cl_trans.append(PyProjTransform(4326, 3581, cl[i]))
可以对shapefile点进行逐点转换,之后,您可以创建一个包含转换点的新数组。这样,您就可以开始进一步的计算了。