Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if not isinstance(sys[i], (int, str, EPSG, ESRI)):
raise TypeError(
'Coordinate description for sys{} must be one of '
'(int, str, EPSG, ESRI); got {}'.format(i + 1, sys[i])
)
if code[i] not in ['epsg', 'esri']:
raise ValueError(
"`code` type for sys{} must be 'epsg' or 'esri'; "
"got {}".format(i + 1, code[i])
)
if code[i] == 'esri' and pyproj.__version__ >= '2':
raise ValueError(
'ESRI codes not supported anymore with pyproj >= 2.0'
)
prefix = '+init=' if pyproj.__version__ < '2.0' else ''
if isinstance(sys[i], int):
sys[i] = '{}{}:{:04d}'.format(prefix, code[i], sys[i])
elif isinstance(sys[i], EPSG):
sys[i] = '{}epsg:{:04d}'.format(prefix, sys[i].value)
elif isinstance(sys[i], ESRI):
sys[i] = '{:s}'.format(sys[i].value)
# pyproj is extremely buggy; need to come back to this soon
if pyproj.__version__ >= '2.0':
try:
proj1 = pyproj.Proj(init=sys[0], preserve_units=False)
except pyproj.exceptions.CRSError:
except ImportError:
v_mpi4py = None
else:
v_mpi4py = mpi4py.__version__
import fiona
v_fiona = fiona.__version__
import netCDF4
v_netcdf4 = netCDF4.__version__
import numpy
v_numpy = numpy.__version__
from ocgis import osgeo
v_gdal = osgeo.__version__
import six
v_six = six.__version__
import pyproj
v_pyproj = pyproj.__version__
try:
import nose
except ImportError:
v_nose = None
else:
v_nose = nose.__version__
try:
import xarray
except ImportError:
v_xarray = None
else:
v_xarray = xarray.__version__
import shapely
v_shapely = shapely.__version__
import setuptools
v_setuptools = setuptools.__version__
import pandas as pd
from pandas import Series
from pandas.core.internals import SingleBlockManager
import pyproj
from shapely.geometry.base import BaseGeometry
from shapely.ops import transform
from geopandas.base import GeoPandasBase, _delegate_property
from geopandas.plotting import plot_series
from .array import GeometryDtype, from_shapely
from .base import is_geometry_type
_PYPROJ_VERSION = LooseVersion(pyproj.__version__)
_SERIES_WARNING_MSG = """\
You are passing non-geometry data to the GeoSeries constructor. Currently,
it falls back to returning a pandas Series. But in the future, we will start
to raise a TypeError instead."""
def _geoseries_constructor_with_fallback(data=None, index=None, crs=None, **kwargs):
"""
A flexible constructor for GeoSeries._constructor, which needs to be able
to fall back to a Series (if a certain operation does not produce
geometries)
"""
try:
with warnings.catch_warnings():
# The master toctree document.
master_doc = "index"
# General information about the project.
project = u"pyproj"
copyright = u"2019, Jeffrey Whitaker"
author = u"Jeffrey Whitaker"
# The version info for the project you're documenting, acts as replacement
# for |version| and |release|, also used in various other places throughout
# the built documents.
#
# The short X.Y version.
version = pyproj.__version__
# The full version, including alpha/beta/rc tags.
release = pyproj.__version__
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This patterns also effect to html_static_path and html_extra_path
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", "**.ipynb_checkpoints"]
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = "sphinx"
def is_pyproj2():
"""Determine whether the current pyproj version is >= 2.0"""
return pyproj.__version__ >= '2'
import sys
import sqlalchemy
from lxml import etree
import shapely.geos
import pyproj
print '''pycsw system profile
--------------------
python version=%s
os=%s
sqlalchemy=%s
shapely=%s
lxml=%s
pyproj=%s ''' % (sys.version_info, sys.platform, sqlalchemy.__version__,
shapely.geos.geos_capi_version, etree.__version__, pyproj.__version__)
def get_transform_function(self, other):
""" Returns a function for transforming geometrical objects from one CRS to another. The function will support
transformations between any objects that pyproj supports.
For better time performance this method will cache results of 10 most recently used pairs of CRS classes.
:param self: Initial CRS
:type self: CRS
:param other: Target CRS
:type other: CRS
:return: A projection function obtained from pyproj package
:rtype: function
"""
if pyproj.__version__ >= '2':
return pyproj.Transformer.from_proj(self.projection(), other.projection(), skip_equivalent=True).transform
return functools.partial(pyproj.transform, self.projection(), other.projection())
def transform(epsg_in, epsg_out, x, y, use_old_version=False):
# import warnings
# warnings.filterwarnings("ignore", category=FutureWarning)
version = proj.__version__
if int(version[0]) < 2 or use_old_version:
# before version 2
crs_in = proj.Proj(init = epsg_in)
crs_out = proj.Proj(init = epsg_out)
xx, yy = proj.transform(crs_in, crs_out, x, y)
return xx, yy
else:
# version 2 and above
# https://pyproj4.github.io/pyproj/stable/gotchas.html#upgrading-to-pyproj-2-from-pyproj-1
transformer = proj.Transformer.from_crs(epsg_in, epsg_out, always_xy=True)
xx, yy = transformer.transform(x, y)
return xx,yy
def get_sysprof():
"""Get versions of dependencies"""
none = 'Module not found'
try:
import sqlalchemy
vsqlalchemy = sqlalchemy.__version__
except ImportError:
vsqlalchemy = none
try:
import pyproj
vpyproj = pyproj.__version__
except ImportError:
vpyproj = none
try:
import shapely
try:
vshapely = shapely.__version__
except AttributeError:
import shapely.geos
vshapely = shapely.geos.geos_capi_version
except ImportError:
vshapely = none
try:
import owslib
try:
source_suffix = ".rst"
# The master toctree document.
master_doc = "index"
# General information about the project.
project = u"pyproj"
copyright = u"2019, Jeffrey Whitaker"
author = u"Jeffrey Whitaker"
# The version info for the project you're documenting, acts as replacement
# for |version| and |release|, also used in various other places throughout
# the built documents.
#
# The short X.Y version.
version = pyproj.__version__
# The full version, including alpha/beta/rc tags.
release = pyproj.__version__
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This patterns also effect to html_static_path and html_extra_path
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", "**.ipynb_checkpoints"]
# The name of the Pygments (syntax highlighting) style to use.