Skip to content
Commits on Source (6)
......@@ -80,7 +80,8 @@ install:
script:
- python -c "import pyproj; pyproj.Proj(init='epsg:4269')"
- nose2 -v --coverage pyproj --coverage-report xml
- nose2 -v
- nose2 --coverage pyproj --coverage-report xml # coverage report on separate line as does not show failures
after_success:
- coveralls
......
pyproj
======
[![Build Status](https://travis-ci.org/jswhit/pyproj.svg)](https://travis-ci.org/jswhit/pyproj)
[![Build Status](https://travis-ci.org/pyproj4/pyproj.svg)](https://travis-ci.org/pyproj4/pyproj)
[![Build status](https://ci.appveyor.com/api/projects/status/8xkka4s97uwhkc64/branch/master?svg=true
)](https://ci.appveyor.com/project/jswhit/pyproj)
[![Coverage Status](https://coveralls.io/repos/github/pyproj4/pyproj/badge.svg?branch=master)](https://coveralls.io/github/pyproj4/pyproj?branch=master)
[![PyPI version](https://badge.fury.io/py/pyproj.svg)](https://badge.fury.io/py/pyproj)
[![Anaconda-Server Badge](https://anaconda.org/conda-forge/pyproj/badges/version.svg)](https://anaconda.org/conda-forge/pyproj)
......@@ -15,12 +17,12 @@ pyproj
Python interface to [PROJ.4](https://github.com/OSGeo/proj.4).
[Installation](https://jswhit.github.io/pyproj/html/installation.html)
[Installation](https://pyproj4.github.io/pyproj/html/installation.html)
------------
[Documentation](http://jswhit.github.io/pyproj)
[Documentation](http://pyproj4.github.io/pyproj)
-------------
Bugs/Questions
--------------
Report bugs/ask questions at https://github.com/jswhit/pyproj/issues.
Report bugs/ask questions at https://github.com/pyproj4/pyproj/issues.
python-pyproj (2.0.2+ds-1~exp2) UNRELEASED; urgency=medium
python-pyproj (2.1.0+ds-1~exp1) experimental; urgency=medium
* New upstream release.
* Also ignore test failures on kfreebsd-i386 & powerpc.
* Update GitHub URLs for move to pyproj4 organisation.
* Add pyproj Contributors to copyright holders.
-- Bas Couwenberg <sebastic@debian.org> Wed, 13 Mar 2019 21:02:02 +0100
-- Bas Couwenberg <sebastic@debian.org> Fri, 15 Mar 2019 16:30:11 +0100
python-pyproj (2.0.2+ds-1~exp1) experimental; urgency=medium
......
......@@ -25,7 +25,7 @@ Build-Depends: debhelper (>= 9),
Standards-Version: 4.3.0
Vcs-Browser: https://salsa.debian.org/debian-gis-team/python-pyproj
Vcs-Git: https://salsa.debian.org/debian-gis-team/python-pyproj.git
Homepage: https://github.com/jswhit/pyproj
Homepage: https://github.com/pyproj4/pyproj
Package: python-pyproj
Architecture: any
......
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: pyproj
Upstream-Contact: Jeffrey Whitaker <jeffrey.s.whitaker@noaa.gov>
Source: https://github.com/jswhit/pyproj
Source: https://github.com/pyproj4/pyproj
Files-Excluded: docs/* docs/.*
Files: *
Copyright: 2006, 2013, Jeffrey Whitaker <jeffrey.s.whitaker@noaa.gov>
2019, Alan D. Snow
2019, pyproj Contributors
License: MIT-short
Files: debian/*
......
---
Bug-Database: https://github.com/jswhit/pyproj/issues
Bug-Submit: https://github.com/jswhit/pyproj/issues/new
Bug-Database: https://github.com/pyproj4/pyproj/issues
Bug-Submit: https://github.com/pyproj4/pyproj/issues/new
Name: pyproj
Repository: https://github.com/jswhit/pyproj.git
Repository-Browse: https://github.com/jswhit/pyproj
Repository: https://github.com/pyproj4/pyproj.git
Repository-Browse: https://github.com/pyproj4/pyproj
......@@ -4,5 +4,5 @@ dversionmangle=s/\+(debian|dfsg|ds|deb)\d*$//,\
uversionmangle=s/_/./g;s/rel$//;s/(\d)[_\.\-\+]?((RC|rc|pre|dev|beta|alpha|b|a)[\-\.]?\d*)$/$1~$2/,\
filenamemangle=s/(?:.*?)?v?(\d[\d\.]*)(?:rel)?\.(tgz|tbz|txz|(?:tar\.(?:gz|bz2|xz)))/pyproj-$1.$2/,\
repacksuffix=+ds \
https://github.com/jswhit/pyproj/releases \
https://github.com/pyproj4/pyproj/releases \
(?:.*?/archive/)*(?:rel|v|pyproj|)[\-\_]?(\d[\d\-\.]+[a-z]*)\.(?:tgz|tbz|txz|(?:tar\.(?:gz|bz2|xz)))
This diff is collapsed.
# cimport c_numpy
# c_numpy.import_array()
include "base.pxi"
from pyproj.crs import CRS
from pyproj.compat import cstrencode, pystrdecode
from pyproj.datadir import get_data_dir
from pyproj.exceptions import ProjError
......@@ -175,243 +172,5 @@ cdef class Proj:
xdatab[i] = projlonlatout.uv.u
ydatab[i] = projlonlatout.uv.v
# def _fwdn(self, c_numpy.ndarray lonlat, radians=False, errcheck=False):
# """
# forward transformation - lons,lats to x,y (done in place).
# Uses ndarray of shape ...,2.
# if radians=True, lons/lats are radians instead of degrees.
# if errcheck=True, an exception is raised if the forward
# transformation is invalid.
# if errcheck=False and the forward transformation is
# invalid, no exception is
# raised and 1.e30 is returned.
# """
# cdef PJ_UV projxyout, projlonlatin
# cdef PJ_UV *llptr
# cdef int err
# cdef Py_ssize_t npts, i
# npts = c_numpy.PyArray_SIZE(lonlat)//2
# llptr = <PJ_UV *>lonlat.data
# for i from 0 <= i < npts:
# if radians:
# projlonlatin = llptr[i]
# else:
# projlonlatin.u = _DG2RAD*llptr[i].u
# projlonlatin.v = _DG2RAD*llptr[i].v
# projxyout = pj_fwd(projlonlatin,self.projpj)
#
# if errcheck:
# err = proj_context_errno(self.projctx)
# if err != 0:
# raise ProjError(proj_errno_string(err))
# # since HUGE_VAL can be 'inf',
# # change it to a real (but very large) number.
# if projxyout.u == HUGE_VAL:
# llptr[i].u = 1.e30
# else:
# llptr[i].u = projxyout.u
# if projxyout.v == HUGE_VAL:
# llptr[i].u = 1.e30
# else:
# llptr[i].v = projxyout.v
#
# def _invn(self, c_numpy.ndarray xy, radians=False, errcheck=False):
# """
# inverse transformation - x,y to lons,lats (done in place).
# Uses ndarray of shape ...,2.
# if radians=True, lons/lats are radians instead of degrees.
# if errcheck=True, an exception is raised if the inverse transformation is invalid.
# if errcheck=False and the inverse transformation is invalid, no exception is
# raised and 1.e30 is returned.
# """
# cdef PJ_UV projxyin, projlonlatout
# cdef PJ_UV *llptr
# cdef Py_ssize_t npts, i
# npts = c_numpy.PyArray_SIZE(xy)//2
# llptr = <PJ_UV *>xy.data
#
# for i from 0 <= i < npts:
# projxyin = llptr[i]
# projlonlatout = pj_inv(projxyin, self.projpj)
# if errcheck:
# err = proj_context_errno(self.projctx)
# if err != 0:
# raise ProjError(proj_errno_string(err))
# # since HUGE_VAL can be 'inf',
# # change it to a real (but very large) number.
# if projlonlatout.u == HUGE_VAL:
# llptr[i].u = 1.e30
# elif radians:
# llptr[i].u = projlonlatout.u
# else:
# llptr[i].u = _RAD2DG*projlonlatout.u
# if projlonlatout.v == HUGE_VAL:
# llptr[i].v = 1.e30
# elif radians:
# llptr[i].v = projlonlatout.v
# else:
# llptr[i].v = _RAD2DG*projlonlatout.v
def __repr__(self):
return "Proj('{srs}', preserve_units=True)".format(srs=self.srs)
cdef class TransProj:
def __cinit__(self):
self.projpj = NULL
self.projctx = NULL
def __init__(self, p1, p2):
# set up the context
self.projctx = proj_context_create()
py_data_dir = cstrencode(get_data_dir())
cdef const char* data_dir = py_data_dir
proj_context_set_search_paths(self.projctx, 1, &data_dir)
self.projpj = proj_create_crs_to_crs(
self.projctx,
TransProj.definition_from_object(p1),
TransProj.definition_from_object(p2),
NULL)
if self.projpj is NULL:
raise ProjError("Error creating CRS to CRS.")
def __dealloc__(self):
"""destroy projection definition"""
if self.projpj is not NULL:
proj_destroy(self.projpj)
if self.projctx is not NULL:
proj_context_destroy(self.projctx)
@staticmethod
def definition_from_object(in_proj):
"""
Parameters
----------
in_proj: :obj:`pyproj.Proj` or :obj:`pyproj.CRS`
Returns
-------
char*: Definition string for `proj_create_crs_to_crs`.
"""
if isinstance(in_proj, Proj):
return in_proj.definition
return cstrencode(CRS.from_user_input(in_proj).to_wkt())
def is_geographic(proj):
if hasattr(proj, "crs"):
proj = proj.crs
return proj.is_geographic
def _transform(p1, p2, inx, iny, inz, radians):
pj_trans = TransProj(p1, p2)
# private function to call pj_transform
cdef void *xdata
cdef void *ydata
cdef void *zdata
cdef double *xx
cdef double *yy
cdef double *zz
cdef Py_ssize_t buflenx, bufleny, buflenz, npts, i
cdef int err
if PyObject_AsWriteBuffer(inx, &xdata, &buflenx) <> 0:
raise ProjError
if PyObject_AsWriteBuffer(iny, &ydata, &bufleny) <> 0:
raise ProjError
if inz is not None:
if PyObject_AsWriteBuffer(inz, &zdata, &buflenz) <> 0:
raise ProjError
else:
buflenz = bufleny
if not (buflenx == bufleny == buflenz):
raise ProjError('x,y and z must be same size')
xx = <double *>xdata
yy = <double *>ydata
if inz is not None:
zz = <double *>zdata
else:
zz = NULL
npts = buflenx//8
if radians and is_geographic(p1):
for i from 0 <= i < npts:
xx[i] = xx[i]*_RAD2DG
yy[i] = yy[i]*_RAD2DG
proj_trans_generic(
pj_trans.projpj,
PJ_FWD,
xx, _DOUBLESIZE, npts,
yy, _DOUBLESIZE, npts,
zz, _DOUBLESIZE, npts,
NULL, 0, 0,
)
cdef int errno = proj_errno(pj_trans.projpj)
if errno:
raise ProjError("proj_trans_generic error: {}".format(
pystrdecode(proj_errno_string(errno))))
if radians and is_geographic(p2):
for i from 0 <= i < npts:
xx[i] = xx[i]*_DG2RAD
yy[i] = yy[i]*_DG2RAD
def _transform_sequence(p1, p2, Py_ssize_t stride, inseq, bint switch, radians):
pj_trans = TransProj(p1, p2)
# private function to itransform function
cdef:
void *buffer
double *coords
double *x
double *y
double *z
Py_ssize_t buflen, npts, i, j
int err
if stride < 2:
raise ProjError("coordinates must contain at least 2 values")
if PyObject_AsWriteBuffer(inseq, &buffer, &buflen) <> 0:
raise ProjError("object does not provide the python buffer writeable interface")
coords = <double*>buffer
npts = buflen // (stride * _DOUBLESIZE)
if radians and is_geographic(p1):
for i from 0 <= i < npts:
j = stride*i
coords[j] *= _RAD2DG
coords[j+1] *= _RAD2DG
if not switch:
x = coords
y = coords + 1
else:
x = coords + 1
y = coords
if stride == 2:
z = NULL
else:
z = coords + 2
proj_trans_generic (
pj_trans.projpj,
PJ_FWD,
x, stride*_DOUBLESIZE, npts,
y, stride*_DOUBLESIZE, npts,
z, stride*_DOUBLESIZE, npts,
NULL, 0, 0,
)
cdef int errno = proj_errno(pj_trans.projpj)
if errno:
raise ProjError("proj_trans_generic error: {}".format(
proj_errno_string(errno)))
if radians and is_geographic(p2):
for i from 0 <= i < npts:
j = stride*i
coords[j] *= _DG2RAD
coords[j+1] *= _DG2RAD
include "proj.pxi"
cdef class _Transformer:
cdef PJ * projpj
cdef PJ_CONTEXT * projctx
cdef public object input_geographic
cdef public object output_geographic
cdef public object input_radians
cdef public object output_radians
cdef public object is_pipeline
include "base.pxi"
from pyproj.crs import CRS
from pyproj.proj import Proj
from pyproj.compat import cstrencode, pystrdecode
from pyproj.datadir import get_data_dir
from pyproj.exceptions import ProjError
cdef class _Transformer:
def __cinit__(self):
self.projpj = NULL
self.projctx = NULL
self.input_geographic = False
self.output_geographic = False
self.input_radians = False
self.output_radians = False
self.is_pipeline = False
def __init__(self):
# set up the context
self.projctx = proj_context_create()
py_data_dir = cstrencode(get_data_dir())
cdef const char* data_dir = py_data_dir
proj_context_set_search_paths(self.projctx, 1, &data_dir)
def __dealloc__(self):
"""destroy projection definition"""
if self.projpj is not NULL:
proj_destroy(self.projpj)
if self.projctx is not NULL:
proj_context_destroy(self.projctx)
@staticmethod
def _init_crs_to_crs(proj_from, proj_to):
cdef _Transformer transformer = _Transformer()
transformer.projpj = proj_create_crs_to_crs(
transformer.projctx,
_Transformer._definition_from_object(proj_from),
_Transformer._definition_from_object(proj_to),
NULL)
if transformer.projpj is NULL:
raise ProjError("Error creating CRS to CRS.")
transformer.input_radians = proj_angular_input(transformer.projpj, PJ_FWD)
transformer.output_radians = proj_angular_output(transformer.projpj, PJ_FWD)
transformer.is_pipeline = False
return transformer
@staticmethod
def from_proj(proj_from, proj_to):
if not isinstance(proj_from, Proj):
proj_from = Proj(proj_from)
if not isinstance(proj_to, Proj):
proj_to = Proj(proj_to)
transformer = _Transformer._init_crs_to_crs(proj_from, proj_to)
transformer.input_geographic = proj_from.crs.is_geographic
transformer.output_geographic = proj_to.crs.is_geographic
return transformer
@staticmethod
def from_crs(crs_from, crs_to):
if not isinstance(crs_from, CRS):
crs_from = CRS.from_user_input(crs_from)
if not isinstance(crs_to, CRS):
crs_to = CRS.from_user_input(crs_to)
transformer = _Transformer._init_crs_to_crs(crs_from, crs_to)
transformer.input_geographic = crs_from.is_geographic
transformer.output_geographic = crs_to.is_geographic
return transformer
@staticmethod
def from_pipeline(const char *proj_pipeline):
cdef _Transformer transformer = _Transformer()
# initialize projection
transformer.projpj = proj_create(transformer.projctx, proj_pipeline)
if transformer.projpj is NULL:
raise ProjError("Invalid projection {}.".format(proj_pipeline))
transformer.input_radians = proj_angular_input(transformer.projpj, PJ_FWD)
transformer.output_radians = proj_angular_output(transformer.projpj, PJ_FWD)
transformer.is_pipeline = True
return transformer
@staticmethod
def _definition_from_object(in_proj):
"""
Parameters
----------
in_proj: :obj:`pyproj.Proj` or :obj:`pyproj.CRS`
Returns
-------
char*: Definition string for `proj_create_crs_to_crs`.
"""
if isinstance(in_proj, Proj):
return cstrencode(in_proj.srs)
return cstrencode(in_proj.to_wkt())
def _transform(self, inx, iny, inz, radians):
# private function to call pj_transform
cdef void *xdata
cdef void *ydata
cdef void *zdata
cdef double *xx
cdef double *yy
cdef double *zz
cdef Py_ssize_t buflenx, bufleny, buflenz, npts, i
cdef int err
if PyObject_AsWriteBuffer(inx, &xdata, &buflenx) <> 0:
raise ProjError
if PyObject_AsWriteBuffer(iny, &ydata, &bufleny) <> 0:
raise ProjError
if inz is not None:
if PyObject_AsWriteBuffer(inz, &zdata, &buflenz) <> 0:
raise ProjError
else:
buflenz = bufleny
if not (buflenx == bufleny == buflenz):
raise ProjError('x,y and z must be same size')
xx = <double *>xdata
yy = <double *>ydata
if inz is not None:
zz = <double *>zdata
else:
zz = NULL
npts = buflenx//8
# degrees to radians
if not self.is_pipeline and not radians and self.input_radians:
for i from 0 <= i < npts:
xx[i] = xx[i]*_DG2RAD
yy[i] = yy[i]*_DG2RAD
# radians to degrees
elif not self.is_pipeline and radians and not self.input_radians and self.input_geographic:
for i from 0 <= i < npts:
xx[i] = xx[i]*_RAD2DG
yy[i] = yy[i]*_RAD2DG
proj_trans_generic(
self.projpj,
PJ_FWD,
xx, _DOUBLESIZE, npts,
yy, _DOUBLESIZE, npts,
zz, _DOUBLESIZE, npts,
NULL, 0, 0,
)
cdef int errno = proj_errno(self.projpj)
if errno:
raise ProjError("proj_trans_generic error: {}".format(
pystrdecode(proj_errno_string(errno))))
# radians to degrees
if not self.is_pipeline and not radians and self.output_radians:
for i from 0 <= i < npts:
xx[i] = xx[i]*_RAD2DG
yy[i] = yy[i]*_RAD2DG
# degrees to radians
elif not self.is_pipeline and radians and not self.output_radians and self.output_geographic:
for i from 0 <= i < npts:
xx[i] = xx[i]*_DG2RAD
yy[i] = yy[i]*_DG2RAD
def _transform_sequence(self, Py_ssize_t stride, inseq, bint switch, radians):
# private function to itransform function
cdef:
void *buffer
double *coords
double *x
double *y
double *z
Py_ssize_t buflen, npts, i, j
int err
if stride < 2:
raise ProjError("coordinates must contain at least 2 values")
if PyObject_AsWriteBuffer(inseq, &buffer, &buflen) <> 0:
raise ProjError("object does not provide the python buffer writeable interface")
coords = <double*>buffer
npts = buflen // (stride * _DOUBLESIZE)
# degrees to radians
if not self.is_pipeline and not radians and self.input_radians:
for i from 0 <= i < npts:
j = stride*i
coords[j] *= _DG2RAD
coords[j+1] *= _DG2RAD
# radians to degrees
elif not self.is_pipeline and radians and not self.input_radians and self.input_geographic:
for i from 0 <= i < npts:
j = stride*i
coords[j] *= _RAD2DG
coords[j+1] *= _RAD2DG
if not switch:
x = coords
y = coords + 1
else:
x = coords + 1
y = coords
if stride == 2:
z = NULL
else:
z = coords + 2
proj_trans_generic (
self.projpj,
PJ_FWD,
x, stride*_DOUBLESIZE, npts,
y, stride*_DOUBLESIZE, npts,
z, stride*_DOUBLESIZE, npts,
NULL, 0, 0,
)
cdef int errno = proj_errno(self.projpj)
if errno:
raise ProjError("proj_trans_generic error: {}".format(
proj_errno_string(errno)))
# radians to degrees
if not self.is_pipeline and not radians and self.output_radians:
for i from 0 <= i < npts:
j = stride*i
coords[j] *= _RAD2DG
coords[j+1] *= _RAD2DG
# degrees to radians
elif not self.is_pipeline and radians and not self.output_radians and self.output_geographic:
for i from 0 <= i < npts:
j = stride*i
coords[j] *= _DG2RAD
coords[j+1] *= _DG2RAD
# -*- coding: utf-8 -*-
"""
Cython wrapper to provide python interfaces to
PROJ.4 (https://github.com/OSGeo/proj.4/wiki) functions.
Performs cartographic transformations and geodetic computations.
The Proj class can convert from geographic (longitude,latitude)
to native map projection (x,y) coordinates and vice versa, or
from one map projection coordinate system directly to another.
The module variable pj_list is a dictionary containing all the
available projections and their descriptions.
Input coordinates can be given as python arrays, lists/tuples,
scalars or numpy/Numeric/numarray arrays. Optimized for objects
that support the Python buffer protocol (regular python and
numpy array objects).
Download: http://python.org/pypi/pyproj
Contact: Jeffrey Whitaker <jeffrey.s.whitaker@noaa.gov
copyright (c) 2006 by Jeffrey Whitaker.
Permission to use, copy, modify, and distribute this software
and its documentation for any purpose and without fee is hereby
granted, provided that the above copyright notice appear in all
copies and that both the copyright notice and this permission
notice appear in supporting documentation. THE AUTHOR DISCLAIMS
ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT
SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR
CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. """
import re
import warnings
from pyproj import _proj
from pyproj.compat import cstrencode, pystrdecode
from pyproj.crs import CRS
from pyproj.utils import _convertback, _copytobuffer
# import numpy as np
proj_version_str = _proj.proj_version_str
pj_list = {
"aea": "Albers Equal Area",
"aeqd": "Azimuthal Equidistant",
"affine": "Affine transformation",
"airy": "Airy",
"aitoff": "Aitoff",
"alsk": "Mod. Stererographics of Alaska",
"apian": "Apian Globular I",
"august": "August Epicycloidal",
"bacon": "Bacon Globular",
"bertin1953": "Bertin 1953",
"bipc": "Bipolar conic of western hemisphere",
"boggs": "Boggs Eumorphic",
"bonne": "Bonne (Werner lat_1=90)",
"calcofi": "Cal Coop Ocean Fish Invest Lines/Stations",
"cart": "Geodetic/cartesian conversions",
"cass": "Cassini",
"cc": "Central Cylindrical",
"ccon": "Central Conic",
"cea": "Equal Area Cylindrical",
"chamb": "Chamberlin Trimetric",
"collg": "Collignon",
"comill": "Compact Miller",
"crast": "Craster Parabolic (Putnins P4)",
"deformation": "Kinematic grid shift",
"denoy": "Denoyer Semi-Elliptical",
"eck1": "Eckert I",
"eck2": "Eckert II",
"eck3": "Eckert III",
"eck4": "Eckert IV",
"eck5": "Eckert V",
"eck6": "Eckert VI",
"eqc": "Equidistant Cylindrical (Plate Caree)",
"eqdc": "Equidistant Conic",
"euler": "Euler",
"etmerc": "Extended Transverse Mercator",
"fahey": "Fahey",
"fouc": "Foucaut",
"fouc_s": "Foucaut Sinusoidal",
"gall": "Gall (Gall Stereographic)",
"geoc": "Geocentric Latitude",
"geocent": "Geocentric",
"geogoffset": "Geographic Offset",
"geos": "Geostationary Satellite View",
"gins8": "Ginsburg VIII (TsNIIGAiK)",
"gn_sinu": "General Sinusoidal Series",
"gnom": "Gnomonic",
"goode": "Goode Homolosine",
"gs48": "Mod. Stererographics of 48 U.S.",
"gs50": "Mod. Stererographics of 50 U.S.",
"hammer": "Hammer & Eckert-Greifendorff",
"hatano": "Hatano Asymmetrical Equal Area",
"healpix": "HEALPix",
"rhealpix": "rHEALPix",
"helmert": "3- and 7-parameter Helmert shift",
"hgridshift": "Horizontal grid shift",
"horner": "Horner polynomial evaluation",
"igh": "Interrupted Goode Homolosine",
"imw_p": "International Map of the World Polyconic",
"isea": "Icosahedral Snyder Equal Area",
"kav5": "Kavraisky V",
"kav7": "Kavraisky VII",
"krovak": "Krovak",
"labrd": "Laborde",
"laea": "Lambert Azimuthal Equal Area",
"lagrng": "Lagrange",
"larr": "Larrivee",
"lask": "Laskowski",
"lonlat": "Lat/long (Geodetic)",
"latlon": "Lat/long (Geodetic alias)",
"latlong": "Lat/long (Geodetic alias)",
"longlat": "Lat/long (Geodetic alias)",
"lcc": "Lambert Conformal Conic",
"lcca": "Lambert Conformal Conic Alternative",
"leac": "Lambert Equal Area Conic",
"lee_os": "Lee Oblated Stereographic",
"loxim": "Loximuthal",
"lsat": "Space oblique for LANDSAT",
"mbt_s": "McBryde-Thomas Flat-Polar Sine",
"mbt_fps": "McBryde-Thomas Flat-Pole Sine (No. 2)",
"mbtfpp": "McBride-Thomas Flat-Polar Parabolic",
"mbtfpq": "McBryde-Thomas Flat-Polar Quartic",
"mbtfps": "McBryde-Thomas Flat-Polar Sinusoidal",
"merc": "Mercator",
"mil_os": "Miller Oblated Stereographic",
"mill": "Miller Cylindrical",
"misrsom": "Space oblique for MISR",
"moll": "Mollweide",
"molobadekas": "Molodensky-Badekas transform",
"molodensky": "Molodensky transform",
"murd1": "Murdoch I",
"murd2": "Murdoch II",
"murd3": "Murdoch III",
"natearth": "Natural Earth",
"natearth2": "Natural Earth 2",
"nell": "Nell",
"nell_h": "Nell-Hammer",
"nicol": "Nicolosi Globular",
"nsper": "Near-sided perspective",
"nzmg": "New Zealand Map Grid",
"ob_tran": "General Oblique Transformation",
"ocea": "Oblique Cylindrical Equal Area",
"oea": "Oblated Equal Area",
"omerc": "Oblique Mercator",
"ortel": "Ortelius Oval",
"ortho": "Orthographic",
"patterson": "Patterson Cylindrical",
"pconic": "Perspective Conic",
"pipeline": "Transformation pipeline manager",
"poly": "Polyconic (American)",
"pop": "Retrieve coordinate value from pipeline stack",
"putp1": "Putnins P1",
"putp2": "Putnins P2",
"putp3": "Putnins P3",
"putp3p": "Putnins P3'",
"putp4p": "Putnins P4'",
"putp5": "Putnins P5",
"putp5p": "Putnins P5'",
"putp6": "Putnins P6",
"putp6p": "Putnins P6'",
"qua_aut": "Quartic Authalic",
"robin": "Robinson",
"rouss": "Roussilhe Stereographic",
"rpoly": "Rectangular Polyconic",
"sch": "Spherical Cross-track Height",
"sinu": "Sinusoidal (Sanson-Flamsteed)",
"somerc": "Swiss. Obl. Mercator",
"stere": "Stereographic",
"sterea": "Oblique Stereographic Alternative",
"gstmerc": "Gauss-Schreiber Transverse Mercator (aka Gauss-Laborde Reunion)",
"tcc": "Transverse Central Cylindrical",
"tcea": "Transverse Cylindrical Equal Area",
"times": "Times",
"tissot": "Tissot Conic",
"tmerc": "Transverse Mercator",
"tpeqd": "Two Point Equidistant",
"tpers": "Tilted perspective",
"ups": "Universal Polar Stereographic",
"urm5": "Urmaev V",
"urmfps": "Urmaev Flat-Polar Sinusoidal",
"utm": "Universal Transverse Mercator (UTM)",
"vandg": "van der Grinten (I)",
"vandg2": "van der Grinten II",
"vandg3": "van der Grinten III",
"vandg4": "van der Grinten IV",
"vitk1": "Vitkovsky I",
"wag1": "Wagner I (Kavraisky VI)",
"wag2": "Wagner II",
"wag3": "Wagner III",
"wag4": "Wagner IV",
"wag5": "Wagner V",
"wag6": "Wagner VI",
"wag7": "Wagner VII",
"webmerc": "Web Mercator / Pseudo Mercator",
"weren": "Werenskiold I",
"wink1": "Winkel I",
"wink2": "Winkel II",
"wintri": "Winkel Tripel",
}
class Proj(_proj.Proj):
"""
performs cartographic transformations (converts from
longitude,latitude to native map projection x,y coordinates and
vice versa) using proj (https://github.com/OSGeo/proj.4/wiki).
A Proj class instance is initialized with proj map projection
control parameter key/value pairs. The key/value pairs can
either be passed in a dictionary, or as keyword arguments,
or as a proj4 string (compatible with the proj command). See
http://www.remotesensing.org/geotiff/proj_list for examples of
key/value pairs defining different map projections.
Calling a Proj class instance with the arguments lon, lat will
convert lon/lat (in degrees) to x/y native map projection
coordinates (in meters). If optional keyword 'inverse' is True
(default is False), the inverse transformation from x/y to
lon/lat is performed. If optional keyword 'errcheck' is True (default is
False) an exception is raised if the transformation is invalid.
If errcheck=False and the transformation is invalid, no
exception is raised and 1.e30 is returned. If the optional keyword
'preserve_units' is True, the units in map projection coordinates
are not forced to be meters.
Works with numpy and regular python array objects, python
sequences and scalars.
"""
def __init__(self, projparams=None, preserve_units=True, **kwargs):
"""
initialize a Proj class instance.
See the proj documentation (https://github.com/OSGeo/proj.4/wiki)
for more information about projection parameters.
Parameters
----------
projparams: int, str, dict, pyproj.CRS
A proj.4 or WKT string, proj.4 dict, EPSG integer, or a pyproj.CRS instnace.
preserve_units: bool
If false, will ensure +units=m.
**kwargs:
proj.4 projection parameters.
Example usage:
>>> from pyproj import Proj
>>> p = Proj(proj='utm',zone=10,ellps='WGS84', preserve_units=False) # use kwargs
>>> x,y = p(-120.108, 34.36116666)
>>> 'x=%9.3f y=%11.3f' % (x,y)
'x=765975.641 y=3805993.134'
>>> 'lon=%8.3f lat=%5.3f' % p(x,y,inverse=True)
'lon=-120.108 lat=34.361'
>>> # do 3 cities at a time in a tuple (Fresno, LA, SF)
>>> lons = (-119.72,-118.40,-122.38)
>>> lats = (36.77, 33.93, 37.62 )
>>> x,y = p(lons, lats)
>>> 'x: %9.3f %9.3f %9.3f' % x
'x: 792763.863 925321.537 554714.301'
>>> 'y: %9.3f %9.3f %9.3f' % y
'y: 4074377.617 3763936.941 4163835.303'
>>> lons, lats = p(x, y, inverse=True) # inverse transform
>>> 'lons: %8.3f %8.3f %8.3f' % lons
'lons: -119.720 -118.400 -122.380'
>>> 'lats: %8.3f %8.3f %8.3f' % lats
'lats: 36.770 33.930 37.620'
>>> p2 = Proj('+proj=utm +zone=10 +ellps=WGS84', preserve_units=False) # use proj4 string
>>> x,y = p2(-120.108, 34.36116666)
>>> 'x=%9.3f y=%11.3f' % (x,y)
'x=765975.641 y=3805993.134'
>>> p = Proj(init="epsg:32667", preserve_units=False)
>>> 'x=%12.3f y=%12.3f (meters)' % p(-114.057222, 51.045)
'x=-1783506.250 y= 6193827.033 (meters)'
>>> p = Proj("+init=epsg:32667")
>>> 'x=%12.3f y=%12.3f (feet)' % p(-114.057222, 51.045)
'x=-5851386.754 y=20320914.191 (feet)'
>>> # test data with radian inputs
>>> p1 = Proj(init="epsg:4214")
>>> x1, y1 = p1(116.366, 39.867)
>>> '{:.3f} {:.3f}'.format(x1, y1)
'2.031 0.696'
>>> x2, y2 = p1(x1, y1, inverse=True)
>>> '{:.3f} {:.3f}'.format(x2, y2)
'116.366 39.867'
"""
self.crs = CRS.from_user_input(projparams if projparams is not None else kwargs)
# make sure units are meters if preserve_units is False.
if not preserve_units and self.crs.is_projected:
projstring = self.crs.to_proj4(4)
projstring = re.sub(r"\s\+units=[\w-]+", "", projstring)
projstring += " +units=m"
self.crs = CRS(projstring)
super(Proj, self).__init__(
cstrencode(self.crs.to_proj4().replace("+type=crs", "").strip())
)
def __call__(self, *args, **kw):
# ,lon,lat,inverse=False,errcheck=False):
"""
Calling a Proj class instance with the arguments lon, lat will
convert lon/lat (in degrees) to x/y native map projection
coordinates (in meters). If optional keyword 'inverse' is True
(default is False), the inverse transformation from x/y to
lon/lat is performed. If optional keyword 'errcheck' is True (default is
False) an exception is raised if the transformation is invalid.
If errcheck=False and the transformation is invalid, no
exception is raised and 1.e30 is returned.
Inputs should be doubles (they will be cast to doubles if they
are not, causing a slight performance hit).
Works with numpy and regular python array objects, python
sequences and scalars, but is fastest for array objects.
"""
inverse = kw.get("inverse", False)
errcheck = kw.get("errcheck", False)
# if len(args) == 1:
# latlon = np.array(args[0], copy=True,
# order='C', dtype=float, ndmin=2)
# if inverse:
# _proj.Proj._invn(self, latlon, radians=radians, errcheck=errcheck)
# else:
# _proj.Proj._fwdn(self, latlon, radians=radians, errcheck=errcheck)
# return latlon
lon, lat = args
# process inputs, making copies that support buffer API.
inx, xisfloat, xislist, xistuple = _copytobuffer(lon)
iny, yisfloat, yislist, yistuple = _copytobuffer(lat)
# call proj4 functions. inx and iny modified in place.
if inverse:
self._inv(inx, iny, errcheck=errcheck)
else:
self._fwd(inx, iny, errcheck=errcheck)
# if inputs were lists, tuples or floats, convert back.
outx = _convertback(xisfloat, xislist, xistuple, inx)
outy = _convertback(yisfloat, yislist, xistuple, iny)
return outx, outy
def is_latlong(self):
"""
Returns
-------
bool: True if projection in geographic (lon/lat) coordinates.
"""
warnings.warn("'is_latlong()' is deprecated. Please use 'crs.is_geographic'.")
return self.crs.is_geographic
def is_geocent(self):
"""
Returns
-------
bool: True if projection in geocentric (x/y) coordinates
"""
warnings.warn("'is_geocent()' is deprecated. Please use 'crs.is_geocent'.")
return self.is_geocent
def definition_string(self):
"""Returns formal definition string for projection
>>> Proj('+init=epsg:4326').definition_string()
'proj=longlat datum=WGS84 no_defs ellps=WGS84 towgs84=0,0,0'
>>>
"""
return pystrdecode(self.definition)
def to_latlong_def(self):
"""return the definition string of the geographic (lat/lon)
coordinate version of the current projection"""
# This is a little hacky way of getting a latlong proj object
# Maybe instead of this function the __cinit__ function can take a
# Proj object and a type (where type = "geographic") as the libproj
# java wrapper
return self.crs.to_geodetic().to_proj4(4)
# deprecated : using in transform raised a TypeError in release 1.9.5.1
# reported in issue #53, resolved in #73.
def to_latlong(self):
"""return a new Proj instance which is the geographic (lat/lon)
coordinate version of the current projection"""
return Proj(self.crs.to_geodetic())
# -*- coding: utf-8 -*-
"""
The transformer module is for performing cartographic transformations.
Copyright (c) 2019 pyproj Contributors.
Permission to use, copy, modify, and distribute this software
and its documentation for any purpose and without fee is hereby
granted, provided that the above copyright notice appear in all
copies and that both the copyright notice and this permission
notice appear in supporting documentation. THE AUTHOR DISCLAIMS
ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT
SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR
CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE."""
from array import array
from itertools import chain, islice
from pyproj._transformer import _Transformer
from pyproj.compat import cstrencode
from pyproj.utils import _convertback, _copytobuffer
try:
from future_builtins import zip # python 2.6+
except ImportError:
pass # python 3.x
class Transformer(object):
"""
The Transformer class is for facilitating re-using
transforms without needing to re-create them. The goal
is to make repeated transforms faster.
Additionally, it provides multiple methods for initialization.
"""
@staticmethod
def from_proj(proj_from, proj_to):
"""Make a Transformer from a :obj:`pyproj.Proj` or input used to create one.
Parameters
----------
proj_from: :obj:`pyproj.Proj` or input used to create one
Projection of input data.
proj_from: :obj:`pyproj.Proj` or input used to create one
Projection of output data.
Returns
-------
:obj:`pyproj.Transformer`
"""
transformer = Transformer()
transformer._transformer = _Transformer.from_proj(proj_from, proj_to)
return transformer
@staticmethod
def from_crs(crs_from, crs_to):
"""Make a Transformer from a :obj:`pyproj.CRS` or input used to create one.
Parameters
----------
proj_from: :obj:`pyproj.CRS` or input used to create one
Projection of input data.
proj_from: :obj:`pyproj.CRS` or input used to create one
Projection of output data.
Returns
-------
:obj:`pyproj.Transformer`
"""
transformer = Transformer()
transformer._transformer = _Transformer.from_crs(crs_from, crs_to)
return transformer
@staticmethod
def from_pipeline(proj_pipeline):
"""Make a Transformer from a PROJ pipeline string.
https://proj4.org/operations/pipeline.html
Parameters
----------
proj_pipeline: str
Projection pipeline string.
Returns
-------
:obj:`pyproj.Transformer`
"""
transformer = Transformer()
transformer._transformer = _Transformer.from_pipeline(cstrencode(proj_pipeline))
return transformer
def transform(self, xx, yy, zz=None, radians=False):
"""
Transform points between two coordinate systems.
Parameters
----------
xx: scalar or array (numpy or python)
Input x coordinate(s).
yy: scalar or array (numpy or python)
Input y coordinate(s).
zz: scalar or array (numpy or python), optional
Input z coordinate(s).
radians: boolean, optional
If True, will expect input data to be in radians and will return radians
if the projection is geographic. Default is False (degrees). Ignored for
pipeline transformations.
Example:
>>> from pyproj import Transformer
>>> transformer = Transformer.from_crs("epsg:4326", "epsg:3857")
>>> x3, y3 = transformer.transform(33, 98)
>>> "%.3f %.3f" % (x3, y3)
'10909310.098 3895303.963'
>>> pipeline_str = "+proj=pipeline +step +proj=longlat +ellps=WGS84 +step +proj=unitconvert +xy_in=rad +xy_out=deg"
>>> pipe_trans = Transformer.from_pipeline(pipeline_str)
>>> xt, yt = pipe_trans.transform(2.1, 0.001)
>>> "%.3f %.3f" % (xt, yt)
'120.321 0.057'
>>> transproj = Transformer.from_proj({"proj":'geocent', "ellps":'WGS84', "datum":'WGS84'}, '+init=EPSG:4326')
>>> xpj, ypj, zpj = transproj.transform(-2704026.010, -4253051.810, 3895878.820, radians=True)
>>> "%.3f %.3f %.3f" % (xpj, ypj, zpj)
'-2.137 0.661 -20.531'
>>> transprojr = Transformer.from_proj('+init=EPSG:4326', {"proj":'geocent', "ellps":'WGS84', "datum":'WGS84'})
>>> xpjr, ypjr, zpjr = transprojr.transform(xpj, ypj, zpj, radians=True)
>>> "%.3f %.3f %.3f" % (xpjr, ypjr, zpjr)
'-2704026.010 -4253051.810 3895878.820'
"""
# process inputs, making copies that support buffer API.
inx, xisfloat, xislist, xistuple = _copytobuffer(xx)
iny, yisfloat, yislist, yistuple = _copytobuffer(yy)
if zz is not None:
inz, zisfloat, zislist, zistuple = _copytobuffer(zz)
else:
inz = None
# call pj_transform. inx,iny,inz buffers modified in place.
self._transformer._transform(inx, iny, inz, radians)
# if inputs were lists, tuples or floats, convert back.
outx = _convertback(xisfloat, xislist, xistuple, inx)
outy = _convertback(yisfloat, yislist, xistuple, iny)
if inz is not None:
outz = _convertback(zisfloat, zislist, zistuple, inz)
return outx, outy, outz
else:
return outx, outy
def itransform(self, points, switch=False, radians=False):
"""
Iterator/generator version of the function pyproj.Transformer.transform.
Parameters
----------
points: list
List of point tuples.
switch: boolean, optional
If True x, y or lon,lat coordinates of points are switched to y, x
or lat, lon. Default is False.
radians: boolean, optional
If True, will expect input data to be in radians and will return radians
if the projection is geographic. Default is False (degrees). Ignored for
pipeline transformations.
Example:
>>> from pyproj import Transformer
>>> transformer = Transformer.from_crs(4326, 2100)
>>> points = [(22.95, 40.63), (22.81, 40.53), (23.51, 40.86)]
>>> for pt in transformer.itransform(points): '{:.3f} {:.3f}'.format(*pt)
'2221638.801 2637034.372'
'2212924.125 2619851.898'
'2238294.779 2703763.736'
>>> pipeline_str = "+proj=pipeline +step +proj=longlat +ellps=WGS84 +step +proj=unitconvert +xy_in=rad +xy_out=deg"
>>> pipe_trans = Transformer.from_pipeline(pipeline_str)
>>> for pt in pipe_trans.itransform([(2.1, 0.001)]): '{:.3f} {:.3f}'.format(*pt)
'120.321 0.057'
>>> transproj = Transformer.from_proj({"proj":'geocent', "ellps":'WGS84', "datum":'WGS84'}, '+init=EPSG:4326')
>>> for pt in transproj.itransform([(-2704026.010, -4253051.810, 3895878.820)], radians=True): '{:.3f} {:.3f} {:.3f}'.format(*pt)
'-2.137 0.661 -20.531'
>>> transprojr = Transformer.from_proj('+init=EPSG:4326', {"proj":'geocent', "ellps":'WGS84', "datum":'WGS84'})
>>> for pt in transprojr.itransform([(-2.137, 0.661, -20.531)], radians=True): '{:.3f} {:.3f} {:.3f}'.format(*pt)
'-2704214.394 -4254414.478 3894270.731'
"""
it = iter(points) # point iterator
# get first point to check stride
try:
fst_pt = next(it)
except StopIteration:
raise ValueError("iterable must contain at least one point")
stride = len(fst_pt)
if stride not in (2, 3):
raise ValueError("points can contain up to 3 coordinates")
# create a coordinate sequence generator etc. x1,y1,z1,x2,y2,z2,....
# chain so the generator returns the first point that was already acquired
coord_gen = chain(fst_pt, (coords[c] for coords in it for c in range(stride)))
while True:
# create a temporary buffer storage for the next 64 points (64*stride*8 bytes)
buff = array("d", islice(coord_gen, 0, 64 * stride))
if len(buff) == 0:
break
self._transformer._transform_sequence(stride, buff, switch, radians)
for pt in zip(*([iter(buff)] * stride)):
yield pt
def transform(p1, p2, x, y, z=None, radians=False):
"""
x2, y2, z2 = transform(p1, p2, x1, y1, z1)
Transform points between two coordinate systems defined by the
Proj instances p1 and p2.
The points x1,y1,z1 in the coordinate system defined by p1 are
transformed to x2,y2,z2 in the coordinate system defined by p2.
z1 is optional, if it is not set it is assumed to be zero (and
only x2 and y2 are returned). If the optional keyword
'radians' is True (default is False), then all input and
output coordinates will be in radians instead of the default
of degrees for geographic input/output projections.
In addition to converting between cartographic and geographic
projection coordinates, this function can take care of datum
shifts (which cannot be done using the __call__ method of the
Proj instances). It also allows for one of the coordinate
systems to be geographic (proj = 'latlong').
x,y and z can be numpy or regular python arrays, python
lists/tuples or scalars. Arrays are fastest. For projections in
geocentric coordinates, values of x and y are given in meters.
z is always meters.
Example usage:
>>> from pyproj import Proj, transform
>>> # projection 1: UTM zone 15, grs80 ellipse, NAD83 datum
>>> # (defined by epsg code 26915)
>>> p1 = Proj(init='epsg:26915', preserve_units=False)
>>> # projection 2: UTM zone 15, clrk66 ellipse, NAD27 datum
>>> p2 = Proj(init='epsg:26715', preserve_units=False)
>>> # find x,y of Jefferson City, MO.
>>> x1, y1 = p1(-92.199881,38.56694)
>>> # transform this point to projection 2 coordinates.
>>> x2, y2 = transform(p1,p2,x1,y1)
>>> '%9.3f %11.3f' % (x1,y1)
'569704.566 4269024.671'
>>> '%9.3f %11.3f' % (x2,y2)
'569722.342 4268814.028'
>>> '%8.3f %5.3f' % p2(x2,y2,inverse=True)
' -92.200 38.567'
>>> # process 3 points at a time in a tuple
>>> lats = (38.83,39.32,38.75) # Columbia, KC and StL Missouri
>>> lons = (-92.22,-94.72,-90.37)
>>> x1, y1 = p1(lons,lats)
>>> x2, y2 = transform(p1,p2,x1,y1)
>>> xy = x1+y1
>>> '%9.3f %9.3f %9.3f %11.3f %11.3f %11.3f' % xy
'567703.344 351730.944 728553.093 4298200.739 4353698.725 4292319.005'
>>> xy = x2+y2
>>> '%9.3f %9.3f %9.3f %11.3f %11.3f %11.3f' % xy
'567721.149 351747.558 728569.133 4297989.112 4353489.645 4292106.305'
>>> lons, lats = p2(x2,y2,inverse=True)
>>> xy = lons+lats
>>> '%8.3f %8.3f %8.3f %5.3f %5.3f %5.3f' % xy
' -92.220 -94.720 -90.370 38.830 39.320 38.750'
>>> # test datum shifting, installation of extra datum grid files.
>>> p1 = Proj(proj='latlong',datum='WGS84')
>>> x1 = -111.5; y1 = 45.25919444444
>>> p2 = Proj(proj="utm",zone=10,datum='NAD27', preserve_units=False)
>>> x2, y2 = transform(p1, p2, x1, y1)
>>> "%s %s" % (str(x2)[:9],str(y2)[:9])
'1402291.0 5076289.5'
>>> from pyproj import CRS
>>> c1 = CRS(proj='latlong',datum='WGS84')
>>> x1 = -111.5; y1 = 45.25919444444
>>> c2 = CRS(proj="utm",zone=10,datum='NAD27')
>>> x2, y2 = transform(c1, c2, x1, y1)
>>> "%s %s" % (str(x2)[:9],str(y2)[:9])
'1402291.0 5076289.5'
>>> pj = Proj(init="epsg:4214")
>>> pjx, pjy = pj(116.366, 39.867)
>>> xr, yr = transform(pj, Proj(4326), pjx, pjy, radians=True)
>>> "%.3f %.3f" % (xr, yr)
'2.031 0.696'
"""
return Transformer.from_proj(p1, p2).transform(x, y, z, radians)
def itransform(p1, p2, points, switch=False, radians=False):
"""
points2 = itransform(p1, p2, points1)
Iterator/generator version of the function pyproj.transform.
Transform points between two coordinate systems defined by the
Proj instances p1 and p2. This function can be used as an alternative
to pyproj.transform when there is a need to transform a big number of
coordinates lazily, for example when reading and processing from a file.
Points1 is an iterable/generator of coordinates x1,y1(,z1) or lon1,lat1(,z1)
in the coordinate system defined by p1. Points2 is an iterator that returns tuples
of x2,y2(,z2) or lon2,lat2(,z2) coordinates in the coordinate system defined by p2.
z are provided optionally.
Points1 can be:
- a tuple/list of tuples/lists i.e. for 2d points: [(xi,yi),(xj,yj),....(xn,yn)]
- a Nx3 or Nx2 2d numpy array where N is the point number
- a generator of coordinates (xi,yi) for 2d points or (xi,yi,zi) for 3d
If optional keyword 'switch' is True (default is False) then x, y or lon,lat coordinates
of points are switched to y, x or lat, lon. If the optional keyword 'radians' is True
(default is False), then all input and output coordinates will be in radians instead
of the default of degrees for geographic input/output projections.
Example usage:
>>> from pyproj import Proj, itransform
>>> # projection 1: WGS84
>>> # (defined by epsg code 4326)
>>> p1 = Proj(init='epsg:4326', preserve_units=False)
>>> # projection 2: GGRS87 / Greek Grid
>>> p2 = Proj(init='epsg:2100', preserve_units=False)
>>> # Three points with coordinates lon, lat in p1
>>> points = [(22.95, 40.63), (22.81, 40.53), (23.51, 40.86)]
>>> # transform this point to projection 2 coordinates.
>>> for pt in itransform(p1,p2,points): '%6.3f %7.3f' % pt
'411200.657 4498214.742'
'399210.500 4487264.963'
'458703.102 4523331.451'
>>> pj = Proj(init="epsg:4214")
>>> pjx, pjy = pj(116.366, 39.867)
>>> for pt in itransform(pj, Proj(4326), [(pjx, pjy)], radians=True): '{:.3f} {:.3f}'.format(*pt)
'2.031 0.696'
"""
return Transformer.from_proj(p1, p2).itransform(points, switch, radians)
......@@ -81,7 +81,6 @@ if "clean" not in sys.argv:
cythonize_options["compiler_directives"] = {"linetrace": True}
cythonize_options["annotate"] = True
proj_libdir = os.environ.get("PROJ_LIBDIR")
libdirs = []
if proj_libdir is None:
......@@ -102,7 +101,6 @@ if "clean" not in sys.argv:
):
package_data["pyproj"].append(os.path.join(BASE_INTERNAL_PROJ_DIR, "lib", "*"))
proj_incdir = os.environ.get("PROJ_INCDIR")
incdirs = []
if proj_incdir is None:
......@@ -135,6 +133,9 @@ if "clean" not in sys.argv:
Extension("pyproj._proj", ["pyproj/_proj.pyx"], **ext_options),
Extension("pyproj._geod", ["pyproj/_geod.pyx"], **ext_options),
Extension("pyproj._crs", ["pyproj/_crs.pyx"], **ext_options),
Extension(
"pyproj._transformer", ["pyproj/_transformer.pyx"], **ext_options
),
],
quiet=True,
**cythonize_options
......
......@@ -8,4 +8,5 @@ API Documentation
proj
crs
geod
transformer
datadir
......@@ -5,19 +5,8 @@ Proj
pyproj.Proj
-----------
.. autoclass:: pyproj.Proj
.. autoclass:: pyproj.proj.Proj
:members:
:inherited-members:
:special-members: __init__, __call__
:show-inheritance:
pyproj.transform
----------------
.. autofunction:: pyproj.transform
pyproj.itransform
-----------------
.. autofunction:: pyproj.itransform
Transformer
===========
pyproj.Transformer
------------------
.. autoclass:: pyproj.transformer.Transformer
:members:
pyproj.transform
----------------
.. autofunction:: pyproj.transformer.transform
pyproj.itransform
-----------------
.. autofunction:: pyproj.transformer.itransform
\ No newline at end of file
Change Log
==========
2.1.0
~~~~~
* Added :class:`pyproj.Transformer` to make repetitive transformations more efficient (issue #187)
* Added fix for using local datumgrids with transform (issue #191)
* Added :class:`pyproj.Transformer.from_pipeline` to support pipeline transformations.
* Added fix for conversion between radians/degrees for transformations (issues #192 & #195)
2.0.2
~~~~~
* add filter for boolean values in dict2string so "no_rot=True" works (issue #183).
......
......@@ -3,7 +3,7 @@ pyproj Documentation
Python interface to `PROJ.4 <https://proj4.org/>`_.
GitHub Repository: https://github.com/jswhit/pyproj
GitHub Repository: https://github.com/pyproj4/pyproj
.. toctree::
......
......@@ -92,7 +92,7 @@ From GitHub with `pip`:
.. code-block:: bash
pip install git+https://github.com/jswhit/pyproj.git
pip install git+https://github.com/pyproj4/pyproj.git
From cloned GitHub repo for development:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
......