Skip to main content

Python Reprojector

Project description

build status coverage report

Python Reprojector

This is a simple python library for coordinate transformations between different projections. It uses the pyproj library as a wrapper for proj.4. The goal is to make transformations as simple as possible.

Usage

Get transformation function

from pyreproj import Reprojector

rp = Reprojector()
transform = rp.get_transformation_function(from_srs=4326, to_srs='epsg:2056')
transform(7.80071, 47.46614)
# returns: (2627299.6594659993, 1257325.3550428355)

The arguments from_srs and to_srs can be one of the following:

  • Integer: value of the EPSG code, e.g. 2056

  • String: EPSG code with leading “epsg:”, e.g. ‘epsg:2056’

  • String: proj4 definition string

  • Object: instance of pyproj.Proj

The returned function is a functools.partial that can also be used as first argument for shapely.ops.transform.

Transform coordinates directly

from shapely.geometry import Point
from pyreproj import Reprojector

rp = Reprojector()

p1 = Point(7.80071, 47.46614)
p2 = rp.transform(p1, from_srs=4326, to_srs=2056)
p2.wkt
# returns: 'POINT (2627299.659465999 1257325.355042835)'

rp.transform([7.80071, 47.46614], from_srs=4326, to_srs=2056)
# returns: [2627299.6594659993, 1257325.3550428355]

rp.transform((7.80071, 47.46614), from_srs=4326, to_srs=2056)
# returns: (2627299.6594659993, 1257325.3550428355)

The arguments from_srs and to_srs can be one of the following:

  • Integer: value of the EPSG code, e.g. 2056

  • String: EPSG code with leading “epsg:”, e.g. ‘epsg:2056’

  • String: proj4 definition string

  • Object: instance of pyproj.Proj

Get projection from service

from pyreproj import Reprojector

rp = Reprojector()
proj = rp.get_projection_from_service(epsg=2056)
type(proj)
# returns: <class 'pyproj.Proj'>

Changelog

1.0.1

https://gitlab.com/gf-bl/python-reprojector/milestones/1

  • Set up deployment

  • Lock version of pyproj<2.0.0

1.0.0

  • Initial version

  • Features:
    • define projections by projection object, proj4 definition or EPSG code

    • get projection by service (e.g. http://spatialreference.org/)

    • get a transformation function from source to target projection

    • transform coordinates as list or tuple or a shapely geometry directly

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyreproj-1.0.1.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

pyreproj-1.0.1-py2.py3-none-any.whl (16.8 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file pyreproj-1.0.1.tar.gz.

File metadata

  • Download URL: pyreproj-1.0.1.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.8

File hashes

Hashes for pyreproj-1.0.1.tar.gz
Algorithm Hash digest
SHA256 143727c73e763b5076e8e4a7837ed3391638191642c1f1cf2d17fde897d35f6c
MD5 b77965e42987c3c0377fb3bdca6d2965
BLAKE2b-256 cad8abbf3923787f1f56a9aba954ad86a63cca1bfcb7aac05fbe322fd80627b9

See more details on using hashes here.

File details

Details for the file pyreproj-1.0.1-py2.py3-none-any.whl.

File metadata

  • Download URL: pyreproj-1.0.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 16.8 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.8

File hashes

Hashes for pyreproj-1.0.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 fbd3bdd2ef819a7afe37d73377af6f398401b6c766bdb58446728bd1c91321eb
MD5 3e1d8de545f7653e0e8818481af8465a
BLAKE2b-256 96ed6e927e581fed0bdbf5cd8e29380f5606afe237e67365258cfbca3d023386

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page