[Git][debian-gis-team/python-geopandas][upstream] New upstream version 0.4.1

Bas Couwenberg gitlab at salsa.debian.org
Wed Mar 6 17:27:02 GMT 2019


Bas Couwenberg pushed to branch upstream at Debian GIS Project / python-geopandas


Commits:
0cf60cdd by Bas Couwenberg at 2019-03-06T16:17:45Z
New upstream version 0.4.1
- - - - -


29 changed files:

- .travis.yml
- CHANGELOG.md
- MANIFEST.in
- README.md
- appveyor.yml
- + ci/travis/27-dev.yaml
- + ci/travis/27-latest-conda-forge.yaml
- + ci/travis/27-latest-defaults.yaml
- + ci/travis/27-pd020.yaml
- + ci/travis/35-minimal.yaml
- + ci/travis/36-pd020.yaml
- + ci/travis/36-pd022.yaml
- + ci/travis/37-dev.yaml
- + ci/travis/37-latest-conda-forge.yaml
- + ci/travis/37-latest-defaults.yaml
- doc/environment.yml
- doc/source/conf.py
- doc/source/install.rst
- examples/plotting_with_geoplot.py
- geopandas/_version.py
- geopandas/io/file.py
- geopandas/io/tests/test_io.py
- geopandas/plotting.py
- geopandas/tests/test_overlay.py
- geopandas/tests/test_pandas_methods.py
- geopandas/tests/test_plotting.py
- geopandas/tools/overlay.py
- readthedocs.yml
- requirements.test.txt


Changes:

=====================================
.travis.yml
=====================================
@@ -2,31 +2,22 @@ language: python
 
 sudo: false
 
-
 matrix:
   include:
     # Only one test for these Python versions
-    - python: 3.5
-      env: PANDAS=0.20.2 MATPLOTLIB=1.5.3
+    - env: ENV_FILE="ci/travis/35-minimal.yaml"
 
     # Python 2.7 and 3.6 test all supported Pandas versions
-    - python: 2.7
-      env: PANDAS=0.19.2  MATPLOTLIB=1.5.3 SHAPELY=1.5
-    - python: 2.7
-      env: PANDAS=0.20.2  MATPLOTLIB=2.0.2
-    - python: 2.7
-      env: PANDAS=0.23.2  MATPLOTLIB=2.1.2
-    - python: 2.7
-      env: PANDAS=master  MATPLOTLIB=2.2.2
-
-    - python: 3.6
-      env: PANDAS=0.19.2  MATPLOTLIB=1.5.3 SHAPELY=1.5 CHANNEL=conda-forge
-    - python: 3.6
-      env: PANDAS=0.20.2  MATPLOTLIB=2.0.2
-    - python: 3.6
-      env: PANDAS=0.23.2  MATPLOTLIB=2.2.2
-    - python: 3.6
-      env: PANDAS=master  MATPLOTLIB=master
+    - env: ENV_FILE="ci/travis/27-pd020.yaml"
+    - env: ENV_FILE="ci/travis/27-latest-defaults.yaml"
+    - env: ENV_FILE="ci/travis/27-dev.yaml"
+
+    - env: ENV_FILE="ci/travis/36-pd020.yaml"
+    - env: ENV_FILE="ci/travis/36-pd022.yaml"
+
+    - env: ENV_FILE="ci/travis/37-latest-defaults.yaml"
+    - env: ENV_FILE="ci/travis/37-latest-conda-forge.yaml"
+    - env: ENV_FILE="ci/travis/37-dev.yaml"
 
 install:
   # Install conda
@@ -35,17 +26,12 @@ install:
   - export PATH="$HOME/miniconda/bin:$PATH"
   - conda config --set always_yes yes --set changeps1 no
   - conda update conda
-  - if [ -n "$CHANNEL" ]; then conda config --add channels $CHANNEL; fi
 
   # Install dependencies
-  - conda create -n test-geopandas -c conda-forge python=$TRAVIS_PYTHON_VERSION pytest matplotlib six psycopg2 sqlalchemy codecov pytest-cov mock
-  - source activate test-geopandas
-  - if [[ $MATPLOTLIB == 'master' ]]; then pip install git+https://github.com/matplotlib/matplotlib.git; fi
-  - if [ -n "$SHAPELY" ]; then conda install shapely=$SHAPELY; else conda install shapely; fi
-  - conda install pysal pyproj fiona descartes rtree
-
-  - if [[ $PANDAS != 'master' ]]; then conda install pandas==$PANDAS; fi
-  - if [[ $PANDAS == 'master' ]]; then conda install pandas cython; pip install git+https://github.com/pydata/pandas.git; fi
+  - conda env create --file="${ENV_FILE}"
+  - source activate test
+  - pip install -e .
+  - conda list
 
 script:
   - py.test geopandas --cov geopandas -v --cov-report term-missing


=====================================
CHANGELOG.md
=====================================
@@ -1,7 +1,19 @@
 Changes
 =======
 
-Version 0.4.0 (July 15, 2017)
+Version 0.4.1 (March 5, 2019)
+-----------------------------
+
+Small bug-fix release for compatibility with the latest Fiona and PySAL
+releases:
+
+* Compatibility with Fiona 1.8: fix deprecation warning (#854).
+* Compatibility with PySAL 2.0: switched to `mapclassify` instead of `PySAL` as
+  dependency for choropleth mapping with the `scheme` keyword (#872).
+* Fix for new `overlay` implementation in case the intersection is empty (#800).
+
+
+Version 0.4.0 (July 15, 2018)
 -----------------------------
 
 Improvements:


=====================================
MANIFEST.in
=====================================
@@ -1,2 +1,3 @@
 include versioneer.py
 include geopandas/_version.py
+include LICENSE.txt


=====================================
README.md
=====================================
@@ -28,9 +28,8 @@ Documentation is available at [geopandas.org](http://geopandas.org)
 Install
 --------
 
-**Requirements**
-
-For the installation of GeoPandas, the following packages are required:
+See the [installation docs](https://geopandas.readthedocs.io/en/latest/install.html)
+for all details. GeoPandas depends on the following packages:
 
 - ``pandas``
 - ``shapely``
@@ -39,40 +38,10 @@ For the installation of GeoPandas, the following packages are required:
 
 Further, ``descartes`` and ``matplotlib`` are optional dependencies, required
 for plotting, and [``rtree``](https://github.com/Toblerity/rtree) is an optional
-dependency, required for spatial joins. ``rtree`` requires the C library [``libspatialindex``](https://github.com/libspatialindex/libspatialindex). If using brew, you can install using ``brew install Spatialindex``.
-
-
-**Install**
-
-GeoPandas depends on several low-level libraries for geospatial analysis. Depending on the system and package
-manager that you use, this may cause dependency conflicts if you are not careful.
-
-*Using `conda`*
-
-We suggest that you use the [anaconda distribution](https://conda.io/docs/user-guide/install/download.html)
-to install GeoPandas (``miniconda`` is fine as well).
-
-Use ``conda`` and the ``conda-forge`` channel to install GeoPandas on a clean environment:
-
-```bash
-conda create -n geopandas
-source activate geopandas  # 'activate geopandas' on Windows
-conda install -c conda-forge geopandas
-```
-
-**NOTE:** Creating a new environment is not strictly necessary, but installing other geospatial packages
-from a *different* channel than ``conda-forge`` may cause dependency conflicts, so we recommend starting
-fresh if possible. See the [conda-forge gotcha page](https://conda-forge.org/docs/conda-forge_gotchas.html)
-for more information.
-
-*Using `pip`*
+dependency, required for spatial joins. ``rtree`` requires the C library [``libspatialindex``](https://github.com/libspatialindex/libspatialindex).
 
-GeoPandas is also pip-installable. If you choose to use `pip`, make sure that you have the proper non-python
-libraries installed and linked properly.
+Those packages depend on several low-level libraries for geospatial analysis, which can be a challenge to install. Therefore, we recommend to install GeoPandas using the [conda package manager](https://conda.io/en/latest/). See the [installation docs](https://geopandas.readthedocs.io/en/latest/install.html) for more details.
 
-```bash
-pip install geopandas
-```
 
 Examples
 --------


=====================================
appveyor.yml
=====================================
@@ -12,8 +12,8 @@ environment:
     - PYTHON_VERSION: "2.7"
       MINICONDA: C:\Miniconda-x64
 
-    - PYTHON_VERSION: "3.5"
-      MINICONDA: C:\Miniconda35-x64
+    - PYTHON_VERSION: "3.7"
+      MINICONDA: C:\Miniconda37-x64
 
 # all our python builds have to happen in tests_script...
 build: false


=====================================
ci/travis/27-dev.yaml
=====================================
@@ -0,0 +1,29 @@
+name: test
+channels:
+  - defaults
+dependencies:
+  - python=2.7
+  - six
+  - cython
+  # required
+  - pandas
+  - shapely
+  - fiona
+  - pyproj
+  # testing
+  - pytest
+  - pytest-cov
+  #- codecov
+  - mock
+  # optional
+  - rtree
+  - matplotlib
+  - descartes
+  #- geopy
+  - SQLalchemy
+  - psycopg2
+  - pip:
+    - git+https://github.com/pydata/pandas.git
+    - codecov
+    - geopy
+    - mapclassify==1.0.1


=====================================
ci/travis/27-latest-conda-forge.yaml
=====================================
@@ -0,0 +1,27 @@
+name: test
+channels:
+  - conda-forge
+dependencies:
+  - python=2.7
+  - six
+  # required
+  - pandas
+  - shapely
+  - fiona
+  - pyproj
+  # testing
+  - pytest
+  - pytest-cov
+  #- codecov
+  - mock
+  # optional
+  - rtree
+  - matplotlib
+  - descartes
+  - mapclassify==1.0.1
+  #- geopy
+  - SQLalchemy
+  - psycopg2
+  - pip:
+    - codecov
+    - geopy


=====================================
ci/travis/27-latest-defaults.yaml
=====================================
@@ -0,0 +1,27 @@
+name: test
+channels:
+  - defaults
+dependencies:
+  - python=2.7
+  - six
+  # required
+  - pandas
+  - shapely
+  - fiona
+  - pyproj
+  # testing
+  - pytest
+  - pytest-cov
+  #- codecov
+  - mock
+  # optional
+  - rtree
+  - matplotlib
+  - descartes
+  #- geopy
+  - SQLalchemy
+  - psycopg2
+  - pip:
+    - codecov
+    - geopy
+    - mapclassify==1.0.1


=====================================
ci/travis/27-pd020.yaml
=====================================
@@ -0,0 +1,26 @@
+name: test
+channels:
+  - conda-forge
+dependencies:
+  - python=2.7
+  - six
+  - numpy # need to list to get this from conda-forge
+  - gdal
+  # required
+  - pandas==0.20.2
+  - shapely
+  - fiona
+  - pyproj
+  # testing
+  - pytest
+  - pytest-cov
+  - codecov
+  - mock
+  # optional
+  - rtree
+  - matplotlib==2.0.2
+  - descartes
+  - pysal=1
+  - geopy
+  - SQLalchemy
+  - psycopg2


=====================================
ci/travis/35-minimal.yaml
=====================================
@@ -0,0 +1,24 @@
+name: test
+channels:
+  - defaults
+  - conda-forge
+dependencies:
+  - python=3.5
+  - six
+  # required
+  - pandas==0.19.2
+  - shapely=1.5
+  - fiona
+  - pyproj
+  # testing
+  - pytest
+  - pytest-cov
+  - codecov
+  # optional
+  - rtree
+  - matplotlib==1.5.3
+  - descartes
+  - mapclassify
+  - geopy
+  - SQLalchemy
+  - psycopg2


=====================================
ci/travis/36-pd020.yaml
=====================================
@@ -0,0 +1,25 @@
+name: test
+channels:
+  - conda-forge
+dependencies:
+  - python=3.6
+  - six
+  # required
+  - pandas==0.20.2
+  - nomkl
+  - shapely
+  - gdal=2.3
+  - fiona
+  - pyproj
+  # testing
+  - pytest
+  - pytest-cov
+  - codecov
+  # optional
+  - rtree
+  - matplotlib=2
+  - descartes
+  - mapclassify
+  - geopy
+  - SQLalchemy
+  - psycopg2


=====================================
ci/travis/36-pd022.yaml
=====================================
@@ -0,0 +1,26 @@
+name: test
+channels:
+  - defaults
+dependencies:
+  - python=3.6
+  - six
+  # required
+  - pandas=0.22
+  - shapely
+  - fiona
+  - pyproj
+  # testing
+  - pytest
+  - pytest-cov
+  #- codecov
+  # optional
+  - rtree
+  - matplotlib==2.0.2
+  - descartes
+  #- geopy
+  - SQLalchemy
+  - psycopg2
+  - pip:
+    - codecov
+    - geopy
+    - mapclassify


=====================================
ci/travis/37-dev.yaml
=====================================
@@ -0,0 +1,29 @@
+name: test
+channels:
+  - defaults
+dependencies:
+  - python=3.7
+  - six
+  - cython
+  # required
+  - pandas
+  - shapely
+  - fiona
+  - pyproj
+  # testing
+  - pytest
+  - pytest-cov
+  #- codecov
+  # optional
+  - rtree
+  - matplotlib
+  - descartes
+  #- geopy
+  - SQLalchemy
+  - psycopg2
+  - pip:
+    - git+https://github.com/matplotlib/matplotlib.git
+    - git+https://github.com/pydata/pandas.git
+    - codecov
+    - geopy
+    - mapclassify


=====================================
ci/travis/37-latest-conda-forge.yaml
=====================================
@@ -0,0 +1,23 @@
+name: test
+channels:
+  - conda-forge
+dependencies:
+  - python=3.7
+  - six
+  # required
+  - pandas
+  - shapely
+  - fiona
+  - pyproj
+  # testing
+  - pytest
+  - pytest-cov
+  - codecov
+  # optional
+  - rtree
+  - matplotlib
+  - descartes
+  - mapclassify
+  - geopy
+  - SQLalchemy
+  - psycopg2


=====================================
ci/travis/37-latest-defaults.yaml
=====================================
@@ -0,0 +1,26 @@
+name: test
+channels:
+  - defaults
+dependencies:
+  - python=3.7
+  - six
+  # required
+  - pandas
+  - shapely
+  - fiona
+  - pyproj
+  # testing
+  - pytest
+  - pytest-cov
+  #- codecov
+  # optional
+  - rtree
+  - matplotlib
+  - descartes
+  #- geopy
+  - SQLalchemy
+  - psycopg2
+  - pip:
+    - codecov
+    - geopy
+    - mapclassify


=====================================
doc/environment.yml
=====================================
@@ -2,25 +2,26 @@ name: geopandas_docs
 channels:
 - conda-forge
 dependencies:
-- python=3.6
-- pandas
-- shapely
-- fiona
-- pyproj
-- rtree
-- six
-- geopy
-- matplotlib
-- descartes
-- pysal
-- sphinx
-- sphinx_rtd_theme
-- numpydoc
-- ipython
-- pillow
-- mock
-- cartopy
-- contextily
-- geoplot
-- sphinx-gallery
-- jinja2
+- python=3.7
+- pandas=0.24.1
+- shapely=1.6.4
+- fiona=1.8.4
+- pyproj=1.9.6
+- rtree=0.8.3
+- six=1.12.0
+- geopy=1.18.1
+- matplotlib=3.0.3
+- descartes=1.1.0
+- mapclassify=2.0.1
+- sphinx=1.8.4
+- sphinx_rtd_theme=0.4.3
+- numpydoc=0.8.0
+- ipython=7.3.0
+- pillow=5.4.1
+- mock=2.0.0
+- cartopy=0.17.0
+- contextily=1.0rc1
+- rasterio=1.0.21
+- geoplot=0.2.3
+- sphinx-gallery=0.2.0
+- jinja2=2.10


=====================================
doc/source/conf.py
=====================================
@@ -34,6 +34,9 @@ extensions = ['IPython.sphinxext.ipython_console_highlighting',
               'numpydoc',
 ]
 
+# continue doc build and only print warnings/errors in examples
+ipython_warning_is_error = False
+
 # Fix issue with warnings from numpydoc (see discussion in PR #534)
 numpydoc_show_class_members = False
 


=====================================
doc/source/install.rst
=====================================
@@ -1,21 +1,108 @@
 Installation
 ============
 
-Installing GeoPandas
----------------------
+GeoPandas depends for its spatial functionality on a large geospatial, open
+source stack of libraries (`GEOS`_, `GDAL`_, `PROJ`_). See the
+:ref:`dependencies` section below for more details. Those base C
+libraries can sometimes be a challenge to install. Therefore, we advise you
+to closely follow the recommendations below to avoid installation problems.
 
-To install the released version, we recommend to use `conda`_ (from the conda-forge
-channel)::
+.. _install-conda:
 
-    conda install -c conda-forge geopandas
+Installing with Anaconda / conda
+--------------------------------
 
-Alternatively, you can also install GeoPandas with pip, but then you need
-to make sure that all dependencies are installed correctly:
+To install GeoPandas and all its dependencies, we recommend to use the `conda`_
+package manager. This can be obtained by installing the
+`Anaconda Distribution`_ (a free Python distribution for data science), or
+through `miniconda`_ (minimal distribution only containing Python and the
+`conda`_ package manager). See also the `installation docs
+<https://conda.io/docs/user-guide/install/download.html>`__ for more information
+on how to install Anaconda or miniconda locally.
+
+The advantage of using the `conda`_ package manager is that it provides
+pre-built binaries for all the required and optional dependencies of GeoPandas
+for all platforms (Windows, Mac, Linux).
+
+To install the latest version of GeoPandas, you can then do::
+
+    conda install geopandas
+
+
+Using the conda-forge channel
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+`conda-forge`_ is a community effort that provides conda packages for a wide
+range of software. It provides the *conda-forge* package channel for conda from
+which packages can be installed, in addition to the "*defaults*" channel
+provided by Anaconda.
+Depending on what other packages you are working with, the *defaults* channel
+or *conda-forge* channel may be better for your needs (e.g. some packages are
+available on *conda-forge* and not on *defaults*).
+
+GeoPandas and all its dependencies are available on the *conda-forge*
+channel, and can be installed as::
+
+    conda install --channel conda-forge geopandas
+
+.. note::
+
+    We strongly recommend to either install everything from the *defaults*
+    channel, or everything from the *conda-forge* channel. Ending up with a
+    mixture of packages from both channels for the dependencies of GeoPandas
+    can lead to import problems.
+    See the `conda-forge section on using multiple channels
+    <http://conda-forge.org/docs/user/tipsandtricks.html#using-multiple-channels>`__
+    for more details.
+
+
+Creating a new environment
+^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Creating a new environment is not strictly necessary, but given that installing
+other geospatial packages from different channels may cause dependency conflicts
+(as mentioned in the note above), it can be good practice to install the geospatial
+stack in a clean environment starting fresh. 
+
+The following commands create a new environment with the name ``geo_env``,
+configures it to install packages always from conda-forge, and installs
+GeoPandas in it::
+
+    conda create -n geo_env
+    conda activate geo_env
+    conda config --env --add channels conda-forge
+    conda config --env --set channel_priority strict
+    conda install python=3 geopandas
+
+
+.. _install-pip:
+
+Installing with pip
+-------------------
+
+GeoPandas can also be installed with pip, if all dependencies can be installed
+as well::
 
     pip install geopandas
 
+.. _install-deps:
+
+.. warning::
+
+    When using pip to install GeoPandas, you need to make sure that all dependencies are
+    installed correctly. `shapely`_ and `fiona`_ provide binary wheels with the
+    dependencies included for Mac and Linux, but not for Windows.
+    `pyproj`_ and `rtree`_ don't provide those.
+    So depending on your platform, you might need to compile and install their
+    C dependencies manually. We refer to the individual packages for more
+    details on installing those.
+    Using conda (see above) avoids the need to compile the dependencies yourself.
+
+Installing from source
+----------------------
+
 You may install the latest development version by cloning the
-`GitHub` repository and using the setup script::
+`GitHub` repository and using pip to install from the local directory::
 
     git clone https://github.com/geopandas/geopandas.git
     cd geopandas
@@ -26,34 +113,42 @@ directly from the GitHub repository with::
 
     pip install git+git://github.com/geopandas/geopandas.git
 
+For installing GeoPandas from source, the same :ref:`note <install-deps>` on
+the need to have all dependencies correctly installed applies. But, those
+dependencies can also be installed independently with conda before installing
+GeoPandas from source::
+
+    conda install pandas fiona shapely pyproj rtree
+
+See the :ref:`section on conda <install-conda>` above for more details on
+getting running with Anaconda.
+
+.. _dependencies:
+
 Dependencies
---------------
+------------
 
-Installation via `conda` should also install all dependencies, but a complete list is as follows:
+Required dependencies:
 
 - `numpy`_
-- `pandas`_ (version 0.15.2 or later)
-- `shapely`_
-- `fiona`_
+- `pandas`_ (version 0.19.1 or later)
+- `shapely`_ (interface to `GEOS`_)
+- `fiona`_ (interface to `GDAL`_)
+- `pyproj`_ (interface to `PROJ`_)
 - `six`_
-- `pyproj`_
 
 Further, optional dependencies are:
 
-- `geopy`_ 0.99 (optional; for geocoding)
+- `rtree`_ (optional; spatial index to improve performance and required for
+  overlay operations; interface to `libspatialindex`_)
 - `psycopg2`_ (optional; for PostGIS connection)
-- `rtree`_ (optional; spatial index to improve performance)
+- `geopy`_ (optional; for geocoding)
 
 For plotting, these additional packages may be used:
 
 - `matplotlib`_
 - `descartes`_
-- `pysal`_
-
-These can be installed independently via the following set of commands::
-
-    conda install -c conda-forge fiona shapely pyproj rtree
-    conda install pandas
+- `mapclassify`_
 
 
 .. _PyPI: https://pypi.python.org/pypi/geopandas
@@ -78,7 +173,7 @@ These can be installed independently via the following set of commands::
 
 .. _psycopg2: https://pypi.python.org/pypi/psycopg2
 
-.. _pysal: http://pysal.org
+.. _mapclassify: https://mapclassify.readthedocs.io/en/latest/
 
 .. _pyproj: https://github.com/jswhit/pyproj
 
@@ -88,4 +183,16 @@ These can be installed independently via the following set of commands::
 
 .. _Travis CI: https://travis-ci.org/geopandas/geopandas
 
-.. _conda: https://conda-forge.org/
+.. _conda: https://conda.io/en/latest/
+
+.. _Anaconda distribution: https://www.anaconda.com/distribution/
+
+.. _miniconda: https://docs.conda.io/en/latest/miniconda.html
+
+.. _conda-forge: https://conda-forge.org/
+
+.. _GDAL: https://www.gdal.org/
+
+.. _GEOS: https://geos.osgeo.org
+
+.. _PROJ: https://proj4.org/


=====================================
examples/plotting_with_geoplot.py
=====================================
@@ -74,7 +74,7 @@ geoplot.polyplot(boroughs, ax=ax)
 # using Voronoi tessellation.
 
 ax = geoplot.voronoi(
-    injurious_collisions.sample(1000),
+    injurious_collisions.sample(1000, random_state=42),
     hue='NUMBER OF PERSONS INJURED', cmap='Reds', scheme='fisher_jenks',
     clip=boroughs.geometry,
     linewidth=0)


=====================================
geopandas/_version.py
=====================================
@@ -23,8 +23,8 @@ def get_keywords():
     # setup.py/versioneer.py will grep for the variable names, so they must
     # each be defined on a line of their own. _version.py will just call
     # get_keywords().
-    git_refnames = " (tag: v0.4.0)"
-    git_full = "33c7a7cc572d5209dfb3da6dd1f967ebd0e34b2d"
+    git_refnames = " (tag: v0.4.1, 0.4.x)"
+    git_full = "5f60528d76b6c27b587a7ad7404f4c60848e4466"
     keywords = {"refnames": git_refnames, "full": git_full}
     return keywords
 


=====================================
geopandas/io/file.py
=====================================
@@ -4,6 +4,11 @@ import fiona
 import numpy as np
 import six
 
+try:
+    from fiona import Env as fiona_env
+except ImportError:
+    from fiona import drivers as fiona_env
+
 from geopandas import GeoDataFrame, GeoSeries
 
 # Adapted from pandas.io.common
@@ -62,18 +67,19 @@ def read_file(filename, bbox=None, **kwargs):
         path_or_bytes = filename
         reader = fiona.open
 
-    with reader(path_or_bytes, **kwargs) as features:
-        crs = features.crs
-        if bbox is not None:
-            if isinstance(bbox, GeoDataFrame) or isinstance(bbox, GeoSeries):
-                bbox = tuple(bbox.to_crs(crs).total_bounds)
-            assert len(bbox) == 4
-            f_filt = features.filter(bbox=bbox)
-        else:
-            f_filt = features
+    with fiona_env():
+        with reader(path_or_bytes, **kwargs) as features:
+            crs = features.crs
+            if bbox is not None:
+                if isinstance(bbox, GeoDataFrame) or isinstance(bbox, GeoSeries):
+                    bbox = tuple(bbox.to_crs(crs).total_bounds)
+                assert len(bbox) == 4
+                f_filt = features.filter(bbox=bbox)
+            else:
+                f_filt = features
 
-        columns = list(features.meta["schema"]["properties"]) + ["geometry"]
-        gdf = GeoDataFrame.from_features(f_filt, crs=crs, columns=columns)
+            columns = list(features.meta["schema"]["properties"]) + ["geometry"]
+            gdf = GeoDataFrame.from_features(f_filt, crs=crs, columns=columns)
 
     return gdf
 
@@ -105,7 +111,7 @@ def to_file(df, filename, driver="ESRI Shapefile", schema=None,
     if schema is None:
         schema = infer_schema(df)
     filename = os.path.abspath(os.path.expanduser(filename))
-    with fiona.drivers():
+    with fiona_env():
         with fiona.open(filename, 'w', driver=driver, crs=df.crs,
                         schema=schema, **kwargs) as colxn:
             colxn.writerecords(df.iterfeatures())
@@ -120,7 +126,7 @@ def infer_schema(df):
     def convert_type(column, in_type):
         if in_type == object:
             return 'str'
-        out_type = type(np.asscalar(np.zeros(1, in_type))).__name__
+        out_type = type(np.zeros(1, in_type).item()).__name__
         if out_type == 'long':
             out_type = 'int'
         if out_type == 'bool':


=====================================
geopandas/io/tests/test_io.py
=====================================
@@ -8,6 +8,7 @@ from shapely.geometry import box
 
 import geopandas
 from geopandas import read_postgis, read_file
+from geopandas.io.file import fiona_env
 from geopandas.tests.util import connect, create_postgis, validate_boro_df
 
 
@@ -172,7 +173,7 @@ class TestIO:
 
         fname = str(tmpdir.join("test_empty.shp"))
 
-        with fiona.drivers():
+        with fiona_env():
             with fiona.open(fname, 'w', **meta) as _:
                 pass
 


=====================================
geopandas/plotting.py
=====================================
@@ -346,10 +346,10 @@ def plot_dataframe(df, column=None, cmap=None, color=None, ax=None,
     legend : bool (default False)
         Plot a legend. Ignored if no `column` is given, or if `color` is given.
     scheme : str (default None)
-        Name of a choropleth classification scheme (requires PySAL).
-        A pysal.esda.mapclassify.Map_Classifier object will be used
-        under the hood. Supported schemes: 'Equal_interval', 'Quantiles',
-        'Fisher_Jenks'
+        Name of a choropleth classification scheme (requires mapclassify).
+        A mapclassify.Map_Classifier object will be used
+        under the hood. Supported schemes: 'Quantiles',
+        'Equal_Interval', 'Fisher_Jenks', 'Fisher_Jenks_Sampled'
     k : int (default 5)
         Number of classes (ignored if scheme is None)
     vmin : None or float (default None)
@@ -442,7 +442,7 @@ def plot_dataframe(df, column=None, cmap=None, color=None, ax=None,
         values = np.array([valuemap[k] for k in values])
 
     if scheme is not None:
-        binning = __pysal_choro(values, scheme, k=k)
+        binning = _mapclassify_choro(values, scheme, k=k)
         # set categorical to True for creating the legend
         categorical = True
         binedges = [values.min()] + binning.bins.tolist()
@@ -509,17 +509,18 @@ def plot_dataframe(df, column=None, cmap=None, color=None, ax=None,
     return ax
 
 
-def __pysal_choro(values, scheme, k=5):
+def _mapclassify_choro(values, scheme, k=5):
     """
-    Wrapper for choropleth schemes from PySAL for use with plot_dataframe
+    Wrapper for choropleth schemes from mapclassify for use with plot_dataframe
 
     Parameters
     ----------
     values
         Series to be plotted
     scheme : str
-        One of pysal.esda.mapclassify classification schemes
-        Options are 'Equal_interval', 'Quantiles', 'Fisher_Jenks'
+        One of mapclassify classification schemes
+        Options are 'Quantiles', 'Equal_Interval', 'Fisher_Jenks',
+        'Fisher_Jenks_Sampled'
     k : int
         number of classes (2 <= k <=9)
 
@@ -531,17 +532,33 @@ def __pysal_choro(values, scheme, k=5):
 
     """
     try:
-        from pysal.esda.mapclassify import (
-            Quantiles, Equal_Interval, Fisher_Jenks)
-        schemes = {}
-        schemes['equal_interval'] = Equal_Interval
-        schemes['quantiles'] = Quantiles
-        schemes['fisher_jenks'] = Fisher_Jenks
-        scheme = scheme.lower()
-        if scheme not in schemes:
-            raise ValueError("Invalid scheme. Scheme must be in the"
-                             " set: %r" % schemes.keys())
-        binning = schemes[scheme](values, k)
-        return binning
+        from mapclassify import (
+            Quantiles, Equal_Interval, Fisher_Jenks,
+            Fisher_Jenks_Sampled)
     except ImportError:
-        raise ImportError("PySAL is required to use the 'scheme' keyword")
+        try:
+            from mapclassify.api import (
+                Quantiles, Equal_Interval, Fisher_Jenks,
+                Fisher_Jenks_Sampled)
+        except ImportError:
+            try:
+                from pysal.esda.mapclassify import (
+                    Quantiles, Equal_Interval, Fisher_Jenks,
+                    Fisher_Jenks_Sampled)
+            except ImportError:
+                raise ImportError(
+                    "The 'mapclassify' package is required to use the "
+                    "'scheme' keyword")
+
+    schemes = {}
+    schemes['equal_interval'] = Equal_Interval
+    schemes['quantiles'] = Quantiles
+    schemes['fisher_jenks'] = Fisher_Jenks
+    schemes['fisher_jenks_sampled'] = Fisher_Jenks_Sampled
+
+    scheme = scheme.lower()
+    if scheme not in schemes:
+        raise ValueError("Invalid scheme. Scheme must be in the"
+                         " set: %r" % schemes.keys())
+    binning = schemes[scheme](values, k)
+    return binning


=====================================
geopandas/tests/test_overlay.py
=====================================
@@ -293,3 +293,12 @@ def test_preserve_crs(dfs, how):
     df2.crs = crs
     result = overlay(df1, df2, how=how)
     assert result.crs == crs
+
+def test_empty_intersection(dfs):
+    df1, df2 = dfs
+    polys3 = GeoSeries([Polygon([(-1,-1), (-3,-1), (-3,-3), (-1,-3)]),
+                        Polygon([(-3,-3), (-5,-3), (-5,-5), (-3,-5)])])
+    df3 = GeoDataFrame({'geometry': polys3, 'col3':[1,2]})
+    expected = GeoDataFrame([], columns=['col1', 'col3', 'geometry'])
+    result = overlay(df1, df3)
+    assert_geodataframe_equal(result, expected, check_like=True)


=====================================
geopandas/tests/test_pandas_methods.py
=====================================
@@ -1,6 +1,7 @@
 from __future__ import absolute_import
 
 from distutils.version import LooseVersion
+import os
 
 from six import PY3
 
@@ -106,7 +107,7 @@ def test_astype(s):
 def test_to_csv(df):
 
     exp = ('geometry,value1,value2\nPOINT (0 0),0,1\nPOINT (1 1),1,2\n'
-           'POINT (2 2),2,1\n')
+           'POINT (2 2),2,1\n').replace('\n', os.linesep)
     assert df.to_csv(index=False) == exp
 
 


=====================================
geopandas/tests/test_plotting.py
=====================================
@@ -12,6 +12,7 @@ from shapely.affinity import rotate
 from shapely.geometry import MultiPolygon, Polygon, LineString, Point, MultiPoint
 
 from geopandas import GeoSeries, GeoDataFrame, read_file
+from geopandas.datasets import get_path
 
 import pytest
 
@@ -386,37 +387,40 @@ class TestNonuniformGeometryPlotting:
         assert ax.collections[2].get_sizes() == [10]
 
 
-class TestPySALPlotting:
+class TestMapclassifyPlotting:
 
     @classmethod
     def setup_class(cls):
         try:
-            import pysal as ps
+            import mapclassify
         except ImportError:
-            raise pytest.skip("PySAL is not installed")
-
-        pth = ps.examples.get_path("columbus.shp")
+            try:
+                import pysal
+            except ImportError:
+                pytest.skip("Mapclassify/PySAL not available")
+        pth = get_path('naturalearth_lowres')
         cls.df = read_file(pth)
         cls.df['NEGATIVES'] = np.linspace(-10, 10, len(cls.df.index))
 
     def test_legend(self):
-        ax = self.df.plot(column='CRIME', scheme='QUANTILES', k=3,
+        ax = self.df.plot(column='pop_est', scheme='QUANTILES', k=3,
                           cmap='OrRd', legend=True)
         labels = [t.get_text() for t in ax.get_legend().get_texts()]
-        expected = [u'0.18 - 26.07', u'26.07 - 41.97', u'41.97 - 68.89']
+        expected = [u'-99.00 - 4579438.67', u'4579438.67 - 16639804.33',
+                    u'16639804.33 - 1338612970.00']
         assert labels == expected
 
     def test_negative_legend(self):
         ax = self.df.plot(column='NEGATIVES', scheme='FISHER_JENKS', k=3,
                           cmap='OrRd', legend=True)
         labels = [t.get_text() for t in ax.get_legend().get_texts()]
-        expected = [u'-10.00 - -3.33', u'-3.33 - 3.33', u'3.33 - 10.00']
+        expected = [u'-10.00 - -3.41', u'-3.41 - 3.30', u'3.30 - 10.00']
         assert labels == expected
 
     def test_invalid_scheme(self):
         with pytest.raises(ValueError):
             scheme = 'invalid_scheme_*#&)(*#'
-            self.df.plot(column='CRIME', scheme=scheme, k=3,
+            self.df.plot(column='gdp_md_est', scheme=scheme, k=3,
                          cmap='OrRd', legend=True)
 
 


=====================================
geopandas/tools/overlay.py
=====================================
@@ -241,7 +241,7 @@ def _overlay_intersection(df1, df2):
     else:
         return GeoDataFrame(
             [],
-            columns=list(set(df1.columns).union(df2.columns)),
+            columns=list(set(df1.columns).union(df2.columns)) + ['__idx1', '__idx2'],
             crs=df1.crs)
 
 


=====================================
readthedocs.yml
=====================================
@@ -1,7 +1,9 @@
-formats:
-    - none
+version: 2
+formats: []
 conda:
-    file: doc/environment.yml
+    environment: doc/environment.yml
 python:
     version: 3
-    setup_py_install: true
+    install:
+        - method: pip
+          path: .


=====================================
requirements.test.txt
=====================================
@@ -1,6 +1,6 @@
 psycopg2>=2.5.1
 SQLAlchemy>=0.8.3
-geopy==1.10.0
+geopy
 matplotlib>=1.2.1
 descartes>=1.0
 mock>=1.0.1  # technically not need for python >= 3.3
@@ -8,4 +8,4 @@ pytest>=3.1.0
 pytest-cov
 codecov
 rtree>=0.8
-pysal
+mapclassify



View it on GitLab: https://salsa.debian.org/debian-gis-team/python-geopandas/commit/0cf60cdda6eab9d7f6cbd20a409114e69125e67b

-- 
View it on GitLab: https://salsa.debian.org/debian-gis-team/python-geopandas/commit/0cf60cdda6eab9d7f6cbd20a409114e69125e67b
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-grass-devel/attachments/20190306/fa62a18d/attachment-0001.html>


More information about the Pkg-grass-devel mailing list