Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Is it possible to use pyproj to transform WKT without creating geometry objects such shapely geometry, GEOS geometry or OGR geometry.

If not what is the fastest way to do it?

share|improve this question

2 Answers 2

up vote 3 down vote accepted

Sure. In that case, you need to transform each point separately. First parse WKT and extract point coordinates, then loop over coordinates and perform transformation like:

import pyproj

srcProj = pyproj.Proj(init='epsg:%i' % epsg_in, preserve_units=True)
dstProj = pyproj.Proj(init='epsg:%i' % epsg_out, preserve_units=True)

x_out,y_out = pyproj.transform(srcProj, dstProj, x_in, y_in)
share|improve this answer
    
alright, but parsing and reconstructing WKT is not that easy for multipolygon for instance –  Below the Radar Aug 6 at 17:25
    
you might want to take a look at shapely toblerity.org/shapely/manual.html#well-known-formats –  Matej Aug 6 at 18:07

Also check out Lars Butler's https://github.com/larsbutler/geomet, a pure Python WKT/WKB <-> GeoJSON converter.

share|improve this answer
    
Yes, I am using it to convert fiona f['geometry'] to WKT. Thank you @sgillies –  Below the Radar Aug 6 at 14:26

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.