Issue
I have big problems by using GDAL in my Anaconda Spyder, but I need to do the following coordinate transformations:
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
Does someone has an idea how to do it without GDAL?
I tried it with transform
from shapely
but I read it is only for points and I need to transform shapefiles and it is just for points.
I am using Spyder 3.2.8 in Anaconda and Python 3.6.4
Thank you very much for your help!
Solution
Maybe it is not the best solution but this one wors for me now:
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]))
With shapely
it is possible to transform a shapefile point wise, after that, you can create a new array which contains the transformed points. With this, you can start further calculations.
Answered By - Dennis
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.