Skip to content
Commits on Source (5)
......@@ -80,8 +80,7 @@ install:
script:
- python -c "import pyproj; pyproj.Proj(init='epsg:4269')"
- nose2 -v
- nose2 --coverage pyproj --coverage-report xml # coverage report on separate line as does not show failures
- py.test --cov-report term-missing --cov=pyproj -v -s
after_success:
- coveralls
......
......@@ -117,7 +117,7 @@ install:
test_script:
# Run the project tests
- "%CMD_IN_ENV% python -c \"import pyproj; pyproj.Proj(init='epsg:4269')\""
- "%CMD_IN_ENV% python unittest/test.py -v"
- "%CMD_IN_ENV% py.test --cov-report term-missing --cov=pyproj -v -s"
after_test:
# If tests are successful, create binary packages for the project.
......
python-pyproj (2.1.3+ds-1~exp1) experimental; urgency=medium
* New upstream release.
* Update packaging to use pytest instead of nose2.
-- Bas Couwenberg <sebastic@debian.org> Fri, 05 Apr 2019 06:59:30 +0200
python-pyproj (2.1.2+ds-1~exp1) experimental; urgency=medium
* New upstream release.
......
......@@ -13,15 +13,15 @@ Build-Depends: debhelper (>= 9),
python-all-dev,
python-setuptools,
python-mock,
python-nose2,
python-numpy,
python-pytest,
python-pytest-cov,
python3-all-dev,
python3-setuptools,
python3-mock,
python3-nose2,
python3-numpy,
python3-pytest
python3-pytest,
python3-pytest-cov
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
......
......@@ -8,6 +8,7 @@
export DEB_BUILD_MAINT_OPTIONS=hardening=+all
export PYBUILD_NAME=pyproj
export PYBUILD_TEST_PYTEST=1
# Path to system installed PROJ data.
export PROJ_DIR=/usr
......@@ -24,12 +25,8 @@ include /usr/share/dpkg/architecture.mk
override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
ifneq (,$(filter $(DEB_BUILD_ARCH),i386 hppa hurd-i386 kfreebsd-i386 powerpc))
PYBUILD_SYSTEM=custom \
PYBUILD_TEST_ARGS="PYTHONPATH={build_dir} {interpreter} /usr/bin/nose2 -v" \
dh_auto_test || echo "Ignoring test failures"
else
PYBUILD_SYSTEM=custom \
PYBUILD_TEST_ARGS="PYTHONPATH={build_dir} {interpreter} /usr/bin/nose2 -v" \
dh_auto_test
endif
endif
......
[unittest]
start-dir = unittest
[coverage]
always-on = True
coverage = pyproj/_proj.pyx
pyproj
coverage-report = term
......@@ -47,7 +47,7 @@ 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. """
__version__ = "2.1.2"
__version__ = "2.1.3"
__all__ = [
"Proj",
"Geod",
......@@ -79,7 +79,7 @@ def test(**kwargs):
pyproj.transformer, verbose=verbose
)
return failure_count + failure_count_crs + failure_count_geod
return failure_count + failure_count_crs + failure_count_geod + failure_count_transform
if __name__ == "__main__":
......
......@@ -351,7 +351,7 @@ cdef class _CRS:
"""
Returns
-------
Ellipsoid: The CRS ellipsoid object with associated attributes.
Ellipsoid: The ellipsoid object with associated attributes.
"""
if self._ellipsoid is not None:
return self._ellipsoid
......@@ -363,7 +363,7 @@ cdef class _CRS:
"""
Returns
-------
AreaOfUse: The CRS area of use object with associated attributes.
AreaOfUse: The area of use object with associated attributes.
"""
if self._area_of_use is not None:
return self._area_of_use
......@@ -387,7 +387,7 @@ cdef class _CRS:
"""
Returns
-------
:obj:`pyproj.CRS`: The datum as a CRS.
pyproj.CRS: The datum as a CRS.
"""
cdef PJ *projobj = proj_crs_get_datum(self.projctx, self.projobj)
if projobj == NULL:
......@@ -436,8 +436,13 @@ cdef class _CRS:
return None
def to_geodetic(self):
"""return a new CRS instance which is the geographic (lat/lon)
coordinate version of the current projection"""
"""
Returns
-------
pyproj.CRS: The geographic (lat/lon) CRS from the current CRS.
"""
cdef PJ * projobj
projobj = proj_crs_get_geodetic_crs(self.projctx, self.projobj)
if projobj == NULL:
......@@ -451,6 +456,15 @@ cdef class _CRS:
"""
Convert the projection to a WKT string.
Version options:
- WKT2_2015
- WKT2_2015_SIMPLIFIED
- WKT2_2018
- WKT2_2018_SIMPLIFIED
- WKT1_GDAL
- WKT1_ESRI
Parameters
----------
version: str
......
import os
from libc.stdlib cimport malloc, free
......@@ -15,7 +16,7 @@ cdef void pyproj_log_function(void *user_data, int level, const char *error_msg)
cdef PJ_CONTEXT* get_pyproj_context():
data_dir = get_data_dir()
data_dir_list = data_dir.split(";")
data_dir_list = data_dir.split(os.pathsep)
cdef PJ_CONTEXT* pyproj_context = NULL
cdef char **c_data_dir = <char **>malloc(len(data_dir_list) * sizeof(char*))
try:
......
......@@ -91,7 +91,7 @@ cdef class Proj:
if errcheck:
err = proj_errno(self.projpj)
if err != 0:
raise ProjError(proj_errno_string(err))
raise ProjError(pystrdecode(proj_errno_string(err)))
# since HUGE_VAL can be 'inf',
# change it to a real (but very large) number.
# also check for NaNs.
......@@ -149,7 +149,7 @@ cdef class Proj:
if errcheck:
err = proj_errno(self.projpj)
if err != 0:
raise ProjError(proj_errno_string(err))
raise ProjError(pystrdecode(proj_errno_string(err)))
# since HUGE_VAL can be 'inf',
# change it to a real (but very large) number.
# also check for NaNs.
......
......@@ -39,14 +39,14 @@ cdef class _Transformer:
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),
cstrencode(proj_from.crs.srs),
cstrencode(proj_to.crs.srs),
NULL)
if transformer.projpj is NULL:
raise ProjError("Error creating CRS to CRS.")
transformer.set_radians_io()
transformer.projections_exact_same = proj_from.is_exact_same(proj_to)
transformer.projections_equivalent = proj_from == proj_to
transformer.projections_exact_same = proj_from.crs.is_exact_same(proj_to.crs)
transformer.projections_equivalent = proj_from.crs == proj_to.crs
transformer.skip_equivalent = skip_equivalent
transformer.is_pipeline = False
return transformer
......@@ -62,17 +62,6 @@ cdef class _Transformer:
transformer.output_geographic = proj_to.crs.is_geographic
return transformer
@staticmethod
def from_crs(crs_from, crs_to, skip_equivalent=False):
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, skip_equivalent=skip_equivalent)
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()
......@@ -85,33 +74,19 @@ cdef class _Transformer:
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.crs.srs)
return cstrencode(in_proj.srs)
def _transform(self, inx, iny, inz, radians, errcheck=False):
def _transform(self, inx, iny, inz, intime, radians, errcheck=False):
if self.projections_exact_same or (self.projections_equivalent and self.skip_equivalent):
return
# private function to call pj_transform
cdef void *xdata
cdef void *ydata
cdef void *zdata
cdef void *tdata
cdef double *xx
cdef double *yy
cdef double *zz
cdef Py_ssize_t buflenx, bufleny, buflenz, npts, i
cdef double *tt
cdef Py_ssize_t buflenx, bufleny, buflenz, buflent, npts, iii
cdef int err
if PyObject_AsWriteBuffer(inx, &xdata, &buflenx) <> 0:
raise ProjError
......@@ -122,54 +97,66 @@ cdef class _Transformer:
raise ProjError
else:
buflenz = bufleny
if not (buflenx == bufleny == buflenz):
raise ProjError('x,y and z must be same size')
if intime is not None:
if PyObject_AsWriteBuffer(intime, &tdata, &buflent) <> 0:
raise ProjError
else:
buflent = bufleny
if not buflenx or not (buflenx == bufleny == buflenz == buflent):
raise ProjError('x,y,z, and time must be same size')
xx = <double *>xdata
yy = <double *>ydata
if inz is not None:
zz = <double *>zdata
else:
zz = NULL
if intime is not None:
tt = <double *>tdata
else:
tt = 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
for iii from 0 <= iii < npts:
xx[iii] = xx[iii]*_DG2RAD
yy[iii] = yy[iii]*_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
for iii from 0 <= iii < npts:
xx[iii] = xx[iii]*_RAD2DG
yy[iii] = yy[iii]*_RAD2DG
proj_trans_generic(
cdef int err_count = proj_trans_generic(
self.projpj,
PJ_FWD,
xx, _DOUBLESIZE, npts,
yy, _DOUBLESIZE, npts,
zz, _DOUBLESIZE, npts,
NULL, 0, 0,
tt, _DOUBLESIZE, npts,
)
cdef int errno = proj_errno(self.projpj)
if errno and errcheck:
raise ProjError("proj_trans_generic error: {}".format(
pystrdecode(proj_errno_string(errno))))
elif err_count and errcheck:
raise ProjError("{} proj_trans_generic error(s)".format(err_count))
# 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
for iii from 0 <= iii < npts:
xx[iii] = xx[iii]*_RAD2DG
yy[iii] = yy[iii]*_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
for iii from 0 <= iii < npts:
xx[iii] = xx[iii]*_DG2RAD
yy[iii] = yy[iii]*_DG2RAD
def _transform_sequence(self, Py_ssize_t stride, inseq, bint switch,
radians, errcheck=False):
time_3rd, radians, errcheck=False):
if self.projections_exact_same or (self.projections_equivalent and self.skip_equivalent):
return
# private function to itransform function
......@@ -179,7 +166,8 @@ cdef class _Transformer:
double *x
double *y
double *z
Py_ssize_t buflen, npts, i, j
double *tt
Py_ssize_t buflen, npts, iii, jjj
int err
if stride < 2:
......@@ -192,16 +180,16 @@ cdef class _Transformer:
# 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
for iii from 0 <= iii < npts:
jjj = stride*iii
coords[jjj] *= _DG2RAD
coords[jjj+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
for iii from 0 <= iii < npts:
jjj = stride*iii
coords[jjj] *= _RAD2DG
coords[jjj+1] *= _RAD2DG
if not switch:
x = coords
......@@ -210,34 +198,44 @@ cdef class _Transformer:
x = coords + 1
y = coords
if stride == 2:
# z coordinate
if stride == 4 or (stride == 3 and not time_3rd):
z = coords + 2
else:
z = NULL
# time
if stride == 3 and time_3rd:
tt = coords + 2
elif stride == 4:
tt = coords + 3
else:
z = coords + 2
tt = NULL
proj_trans_generic (
cdef int err_count = proj_trans_generic (
self.projpj,
PJ_FWD,
x, stride*_DOUBLESIZE, npts,
y, stride*_DOUBLESIZE, npts,
z, stride*_DOUBLESIZE, npts,
NULL, 0, 0,
tt, stride*_DOUBLESIZE, npts,
)
cdef int errno = proj_errno(self.projpj)
if errno and errcheck:
raise ProjError("proj_trans_generic error: {}".format(
proj_errno_string(errno)))
pystrdecode(proj_errno_string(errno))))
elif err_count and errcheck:
raise ProjError("{} proj_trans_generic error(s)".format(err_count))
# 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
for iii from 0 <= iii < npts:
jjj = stride*iii
coords[jjj] *= _RAD2DG
coords[jjj+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
for iii from 0 <= iii < npts:
jjj = stride*iii
coords[jjj] *= _DG2RAD
coords[jjj+1] *= _DG2RAD
......@@ -160,7 +160,7 @@ class CRS(_CRS):
Returns
-------
CRS
~CRS
"""
if int(code) <= 0:
raise CRSError("EPSG codes are positive integers")
......@@ -177,7 +177,7 @@ class CRS(_CRS):
Returns
-------
CRS
~CRS
"""
if not proj_string:
raise CRSError("CRS is empty or invalid: {!r}".format(proj_string))
......@@ -214,7 +214,7 @@ class CRS(_CRS):
Returns
-------
CRS
~CRS
"""
if isinstance(value, _CRS):
return value
......@@ -233,7 +233,7 @@ class CRS(_CRS):
"""
Returns
-------
:obj:`pyproj.Geod`: Geod object based on the CRS.ellipsoid.
~pyproj.geod.Geod: Geod object based on the ellipsoid.
"""
if self.ellipsoid is None or not self.ellipsoid.ellipsoid_loaded:
return None
......
......@@ -35,7 +35,7 @@ def append_data_dir(proj_data_dir):
proj_data_dir: str
The path to rhe PROJ.4 data directory.
"""
set_data_dir(";".join([get_data_dir(), proj_data_dir]))
set_data_dir(os.pathsep.join([get_data_dir(), proj_data_dir]))
def get_data_dir():
......@@ -73,7 +73,7 @@ def get_data_dir():
def valid_data_dirs(potential_data_dirs):
if potential_data_dirs is None:
return False
for proj_data_dir in potential_data_dirs.split(";"):
for proj_data_dir in potential_data_dirs.split(os.pathsep):
if valid_data_dir(proj_data_dir):
return True
break
......
......@@ -351,7 +351,10 @@ class Proj(_proj.Proj):
-------
bool: True if projection in geographic (lon/lat) coordinates.
"""
warnings.warn("'is_latlong()' is deprecated. Please use 'crs.is_geographic'.")
warnings.warn(
"'is_latlong()' is deprecated and will be removed in version 2.2.0. "
"Please use 'crs.is_geographic'."
)
return self.crs.is_geographic
def is_geocent(self):
......@@ -360,7 +363,10 @@ class Proj(_proj.Proj):
-------
bool: True if projection in geocentric (x/y) coordinates
"""
warnings.warn("'is_geocent()' is deprecated. Please use 'crs.is_geocent'.")
warnings.warn(
"'is_geocent()' is deprecated and will be removed in version 2.2.0. "
"Please use 'crs.is_geocent'."
)
return self.is_geocent
def definition_string(self):
......
......@@ -17,6 +17,7 @@ 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 warnings
from array import array
from itertools import chain, islice
......@@ -41,13 +42,13 @@ class Transformer(object):
@staticmethod
def from_proj(proj_from, proj_to, skip_equivalent=False):
"""Make a Transformer from a :obj:`pyproj.Proj` or input used to create one.
"""Make a Transformer from a :obj:`~pyproj.proj.Proj` or input used to create one.
Parameters
----------
proj_from: :obj:`pyproj.Proj` or input used to create one
proj_from: :obj:`~pyproj.proj.Proj` or input used to create one
Projection of input data.
proj_from: :obj:`pyproj.Proj` or input used to create one
proj_to: :obj:`~pyproj.proj.Proj` or input used to create one
Projection of output data.
skip_equivalent: bool, optional
If true, will skip the transformation operation if input and output
......@@ -55,7 +56,7 @@ class Transformer(object):
Returns
-------
:obj:`pyproj.Transformer`
:obj:`~Transformer`
"""
......@@ -67,13 +68,16 @@ class Transformer(object):
@staticmethod
def from_crs(crs_from, crs_to, skip_equivalent=False):
"""Make a Transformer from a :obj:`pyproj.CRS` or input used to create one.
"""Make a Transformer from a :obj:`~pyproj.crs.CRS` or input used to create one.
.. warning:: `from_crs` is deprecated and will be removed in 2.2.0.
Please use :meth:`~Transformer.from_proj` instead.
Parameters
----------
proj_from: :obj:`pyproj.CRS` or input used to create one
crs_from: ~pyproj.crs.CRS or input used to create one
Projection of input data.
proj_from: :obj:`pyproj.CRS` or input used to create one
crs_to: ~pyproj.crs.CRS or input used to create one
Projection of output data.
skip_equivalent: bool, optional
If true, will skip the transformation operation if input and output
......@@ -81,14 +85,14 @@ class Transformer(object):
Returns
-------
:obj:`pyproj.Transformer`
:obj:`~Transformer`
"""
transformer = Transformer()
transformer._transformer = _Transformer.from_crs(
crs_from, crs_to, skip_equivalent
warnings.warn(
"`from_crs` is deprecated and will be removed in 2.2.0. "
"Please use `from_proj` instead."
)
return transformer
return Transformer.from_proj(crs_from, crs_to, skip_equivalent=skip_equivalent)
@staticmethod
def from_pipeline(proj_pipeline):
......@@ -103,14 +107,14 @@ class Transformer(object):
Returns
-------
:obj:`pyproj.Transformer`
~Transformer
"""
transformer = Transformer()
transformer._transformer = _Transformer.from_pipeline(cstrencode(proj_pipeline))
return transformer
def transform(self, xx, yy, zz=None, radians=False, errcheck=False):
def transform(self, xx, yy, zz=None, tt=None, radians=False, errcheck=False):
"""
Transform points between two coordinate systems.
......@@ -122,6 +126,8 @@ class Transformer(object):
Input y coordinate(s).
zz: scalar or array (numpy or python), optional
Input z coordinate(s).
tt: scalar or array (numpy or python), optional
Input time 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
......@@ -152,7 +158,7 @@ class Transformer(object):
>>> xpjr, ypjr, zpjr = transprojr.transform(xpj, ypj, zpj, radians=True)
>>> "%.3f %.3f %.3f" % (xpjr, ypjr, zpjr)
'-2704026.010 -4253051.810 3895878.820'
>>> transformer = Transformer.from_crs("epsg:4326", 4326, skip_equivalent=True)
>>> transformer = Transformer.from_proj("epsg:4326", 4326, skip_equivalent=True)
>>> xeq, yeq = transformer.transform(33, 98)
>>> "%.0f %.0f" % (xeq, yeq)
'33 98'
......@@ -165,18 +171,27 @@ class Transformer(object):
inz, zisfloat, zislist, zistuple = _copytobuffer(zz)
else:
inz = None
if tt is not None:
intime, tisfloat, tislist, tistuple = _copytobuffer(tt)
else:
intime = None
# call pj_transform. inx,iny,inz buffers modified in place.
self._transformer._transform(inx, iny, inz, radians, errcheck=errcheck)
self._transformer._transform(
inx, iny, inz=inz, intime=intime, radians=radians, errcheck=errcheck
)
# if inputs were lists, tuples or floats, convert back.
outx = _convertback(xisfloat, xislist, xistuple, inx)
outy = _convertback(yisfloat, yislist, xistuple, iny)
return_data = (outx, outy)
if inz is not None:
outz = _convertback(zisfloat, zislist, zistuple, inz)
return outx, outy, outz
else:
return outx, outy
return_data += (_convertback(zisfloat, zislist, zistuple, inz),)
if intime is not None:
return_data += (_convertback(tisfloat, tislist, tistuple, intime),)
return return_data
def itransform(self, points, switch=False, radians=False, errcheck=False):
def itransform(
self, points, switch=False, time_3rd=False, radians=False, errcheck=False
):
"""
Iterator/generator version of the function pyproj.Transformer.transform.
......@@ -188,6 +203,8 @@ class Transformer(object):
switch: boolean, optional
If True x, y or lon,lat coordinates of points are switched to y, x
or lat, lon. Default is False.
time_3rd: boolean, optional
If the input coordinates are 3 dimensional and the 3rd dimension is time.
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
......@@ -217,7 +234,7 @@ class Transformer(object):
>>> 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'
>>> transproj_eq = Transformer.from_proj('+init=EPSG:4326', 4326, skip_equivalent=True)
>>> transproj_eq = Transformer.from_proj('+init=EPSG:4326', '+proj=longlat +datum=WGS84 +no_defs +type=crs', skip_equivalent=True)
>>> for pt in transproj_eq.itransform([(-2.137, 0.661)]): '{:.3f} {:.3f}'.format(*pt)
'-2.137 0.661'
......@@ -230,8 +247,11 @@ class Transformer(object):
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")
if stride not in (2, 3, 4):
raise ValueError("points can contain up to 4 coordinates")
if time_3rd and stride != 3:
raise ValueError("'time_3rd' is only valid for 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
......@@ -244,7 +264,12 @@ class Transformer(object):
break
self._transformer._transform_sequence(
stride, buff, switch, radians, errcheck=errcheck
stride,
buff,
switch=switch,
time_3rd=time_3rd,
radians=radians,
errcheck=errcheck,
)
for pt in zip(*([iter(buff)] * stride)):
......@@ -252,7 +277,7 @@ class Transformer(object):
def transform(
p1, p2, x, y, z=None, radians=False, errcheck=False, skip_equivalent=False
p1, p2, x, y, z=None, tt=None, radians=False, errcheck=False, skip_equivalent=False
):
"""
x2, y2, z2 = transform(p1, p2, x1, y1, z1)
......@@ -334,22 +359,24 @@ def transform(
>>> 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, errcheck=True)
>>> "%.3f %.3f" % (xr, yr)
'0.696 2.031'
>>> xeq, yeq = transform(4326, 4326, 30, 60, skip_equivalent=True)
>>> "%.0f %.0f" % (xeq, yeq)
'30 60'
"""
return Transformer.from_proj(p1, p2, skip_equivalent=skip_equivalent).transform(
x, y, z, radians, errcheck=errcheck
xx=x, yy=y, zz=z, tt=tt, radians=radians, errcheck=errcheck
)
def itransform(
p1, p2, points, switch=False, radians=False, errcheck=False, skip_equivalent=False
p1,
p2,
points,
switch=False,
time_3rd=False,
radians=False,
errcheck=False,
skip_equivalent=False,
):
"""
points2 = itransform(p1, p2, points1)
......@@ -396,14 +423,10 @@ def itransform(
'411050.470 4497928.574'
'399060.236 4486978.710'
'458553.243 4523045.485'
>>> pj = Proj(init="epsg:4214")
>>> pjx, pjy = pj(116.366, 39.867)
>>> for pt in itransform(pj, Proj(4326), [(pjx, pjy)], radians=True, errcheck=True): '{:.3f} {:.3f}'.format(*pt)
'0.696 2.031'
>>> for pt in itransform(4326, 4326, [(30, 60)], skip_equivalent=True): '{:.0f} {:.0f}'.format(*pt)
'30 60'
"""
return Transformer.from_proj(p1, p2, skip_equivalent=skip_equivalent).itransform(
points, switch, radians, errcheck=errcheck
points, switch=switch, time_3rd=time_3rd, radians=radians, errcheck=errcheck
)
cython>=0.28.4
mock
nose2[coverage_plugin]>=0.6.5
pytest
cov-core
coverage>=4.0
pytest>3.6
pytest-cov
numpy
......@@ -14,6 +14,6 @@ pyproj.datadir.set_data_dir
pyproj.datadir.append_data_dir
---------------------------
------------------------------
.. autofunction:: pyproj.datadir.append_data_dir
Exceptions
==========
.. automodule:: pyproj.exceptions
:members:
......@@ -10,3 +10,4 @@ API Documentation
geod
transformer
datadir
exceptions
\ No newline at end of file
Transformer
===========
.. warning:: The axis order may be swapped if the source and destination
CRS's are defined as having the first coordinate component point in a
northerly direction (See PROJ FAQ on
`axis order <https://proj4.org/faq.html#why-is-the-axis-ordering-in-proj-not-consistent>`_).
You can check the axis order with the `pyproj.CRS` class.
pyproj.Transformer
------------------
......