[MapProxy] Wrong reprojection to SRS which use units=us-ft when using Mapproxy with pyproj

Martin Icking Martin.Icking at bentley.com
Wed Oct 10 05:10:15 PDT 2018


I discovered that using MapProxy with pyproj you cannot successfully reproject to an SRS that uses units different from meter.
In my case I tried to reproject OSM data into EPSG:32019 which resulted in wrong tiles.

The issue is caused by a nasty behavior of the pyproj library which has already been mentioned in multiple pyproj issues, see here: https://github.com/jswhit/pyproj/issues/67
Software using pyproj should use the additional parameter "preserve_units=True" when instantiating a new class, e.g.

ny_state = pyproj.Proj(init="EPSG:2263", preserve_units=True)

Currently MapProxy does not set this parameter, by that pyproj assumes that each SRS is based on "units=m".
I've successfully tried a quick fix in mapproxy's proj.py (I'm not a Python developer at all, so there might be nicer solutions):

def try_pyproj_import():
    try:
        from pyproj import Proj, transform, set_datapath
    except ImportError:
        return False

    # this new class overrides the constructor of the Proj class to set preserve_units to True by default
    class myProj(Proj):
        def __new__(self, projparams=None, preserve_units=True, **kwargs):
            return super(myProj, self).__new__(self,projparams,preserve_units,**kwargs)

    log_system.info('using pyproj for coordinate transformation')
    return myProj, transform, set_datapath

Best regards
Martin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapproxy/attachments/20181010/1770f2e7/attachment.html>


More information about the MapProxy mailing list