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

Bas Couwenberg (@sebastic) gitlab at salsa.debian.org
Tue Jun 6 11:42:51 BST 2023



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


Commits:
47522943 by Bas Couwenberg at 2023-06-06T12:25:50+02:00
New upstream version 0.13.2
- - - - -


7 changed files:

- .github/workflows/tests.yaml
- CHANGELOG.md
- ci/envs/38-minimal.yaml
- geopandas/_version.py
- geopandas/geodataframe.py
- geopandas/io/file.py
- geopandas/io/tests/test_file.py


Changes:

=====================================
.github/workflows/tests.yaml
=====================================
@@ -37,8 +37,8 @@ jobs:
         env:
           - ci/envs/38-minimal.yaml
           - ci/envs/39-no-optional-deps.yaml
-          - ci/envs/38-pd12-defaults.yaml
-          - ci/envs/38-latest-defaults.yaml
+          # - ci/envs/38-pd12-defaults.yaml
+          # - ci/envs/38-latest-defaults.yaml
           - ci/envs/38-latest-conda-forge.yaml
           - ci/envs/39-pd13-conda-forge.yaml
           - ci/envs/39-latest-conda-forge.yaml
@@ -68,22 +68,19 @@ jobs:
     steps:
       - uses: actions/checkout at v3
 
-      - name: Setup Conda
-        uses: conda-incubator/setup-miniconda at v2
+      - name: Install Conda environment with Micromamba
+        uses: mamba-org/setup-micromamba at v1
         with:
           environment-file: ${{ matrix.env }}
-          miniforge-version: latest
-          miniforge-variant: Mambaforge
-          use-mamba: true
 
       - name: Check and Log Environment
         run: |
           python -V
           python -c "import geopandas; geopandas.show_versions();"
-          conda info
+          micromamba info
           # save conda list to file and print out
           # so that we can do the HAS_PYGEOS check without calling conda again
-          conda list 2>&1 | tee conda.txt
+          micromamba list 2>&1 | tee conda.txt
           if ( cat conda.txt | grep -q pygeos  )
           then
             echo "Setting HAS_PYGEOS=1"


=====================================
CHANGELOG.md
=====================================
@@ -1,5 +1,29 @@
 # Changelog
 
+## Development version
+
+New features and improvements:
+
+
+Bug fixes:
+
+
+## Version 0.13.2 (Jun 6, 2023)
+
+Bug fix:
+
+- Fix a regression in reading from local file URIs (``file://..``) using
+  ``geopandas.read_file`` (#2948).
+
+## Version 0.13.1 (Jun 5, 2023)
+
+Bug fix:
+
+- Fix a regression in reading from URLs using ``geopandas.read_file`` (#2908). This
+  restores the behaviour to download all data up-front before passing it to the
+  underlying engine (fiona or pyogrio), except if the server supports partial requests
+  (to support reading a subset of a large file).
+
 ## Version 0.13 (May 6, 2023)
 
 New methods:


=====================================
ci/envs/38-minimal.yaml
=====================================
@@ -1,6 +1,5 @@
 name: test
 channels:
-  - defaults
   - conda-forge
 dependencies:
   - python=3.8


=====================================
geopandas/_version.py
=====================================
@@ -25,9 +25,9 @@ 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.13.0)"
-    git_full = "aa5abc316f99c5370b0d8c88f38468145311e1a0"
-    git_date = "2023-05-06 14:21:15 +0200"
+    git_refnames = " (HEAD -> main, tag: v0.13.2)"
+    git_full = "d5add48e966bb4e711d2399721df88349a358904"
+    git_date = "2023-06-06 10:58:39 +0200"
     keywords = {"refnames": git_refnames, "full": git_full, "date": git_date}
     return keywords
 


=====================================
geopandas/geodataframe.py
=====================================
@@ -2098,7 +2098,6 @@ individually so that features may have different properties
 
     @doc(_explore)
     def explore(self, *args, **kwargs):
-        """Interactive map based on folium/leaflet.js"""
         return _explore(self, *args, **kwargs)
 
     def sjoin(self, df, *args, **kwargs):


=====================================
geopandas/io/file.py
=====================================
@@ -14,11 +14,15 @@ from shapely.geometry.base import BaseGeometry
 from geopandas import GeoDataFrame, GeoSeries
 
 # Adapted from pandas.io.common
+from urllib.parse import urlparse as parse_url
 from urllib.parse import uses_netloc, uses_params, uses_relative
+import urllib.request
 
 
 _VALID_URLS = set(uses_relative + uses_netloc + uses_params)
 _VALID_URLS.discard("")
+# file:// URIs are supported by fiona/pyogrio -> don't already open + read the file here
+_VALID_URLS.discard("file")
 
 
 fiona = None
@@ -149,6 +153,14 @@ def _expand_user(path):
     return path
 
 
+def _is_url(url):
+    """Check to see if *url* has a valid protocol."""
+    try:
+        return parse_url(url).scheme in _VALID_URLS
+    except Exception:
+        return False
+
+
 def _is_zip(path):
     """Check if a given path is a zipfile"""
     parsed = fiona.path.ParsedPath.from_uri(path)
@@ -228,16 +240,37 @@ def _read_file(filename, bbox=None, mask=None, rows=None, engine=None, **kwargs)
     The format drivers will attempt to detect the encoding of your data, but
     may fail. In this case, the proper encoding can be specified explicitly
     by using the encoding keyword parameter, e.g. ``encoding='utf-8'``.
+
+    When specifying a URL, geopandas will check if the server supports reading
+    partial data and in that case pass the URL as is to the underlying engine,
+    which will then use the network file system handler of GDAL to read from
+    the URL. Otherwise geopandas will download the data from the URL and pass
+    all data in-memory to the underlying engine.
+    If you need more control over how the URL is read, you can specify the
+    GDAL virtual filesystem manually (e.g. ``/vsicurl/https://...``). See the
+    GDAL documentation on filesystems for more details
+    (https://gdal.org/user/virtual_file_systems.html#vsicurl-http-https-ftp-files-random-access).
+
     """
     engine = _check_engine(engine, "'read_file' function")
 
     filename = _expand_user(filename)
 
+    from_bytes = False
+    if _is_url(filename):
+        # if it is a url that supports random access -> pass through to
+        # pyogrio/fiona as is (to support downloading only part of the file)
+        # otherwise still download manually because pyogrio/fiona don't support
+        # all types of urls (https://github.com/geopandas/geopandas/issues/2908)
+        with urllib.request.urlopen(filename) as response:
+            if not response.headers.get("Accept-Ranges") == "bytes":
+                filename = response.read()
+                from_bytes = True
+
     if engine == "pyogrio":
         return _read_file_pyogrio(filename, bbox=bbox, mask=mask, rows=rows, **kwargs)
 
     elif engine == "fiona":
-        from_bytes = False
         if pd.api.types.is_file_like(filename):
             data = filename.read()
             path_or_bytes = data.encode("utf-8") if isinstance(data, str) else data


=====================================
geopandas/io/tests/test_file.py
=====================================
@@ -557,22 +557,29 @@ def test_read_file(engine):
 
 
 @pytest.mark.web
-def test_read_file_remote_geojson_url(engine):
-    url = (
+ at pytest.mark.parametrize(
+    "url",
+    [
+        # geojson url
         "https://raw.githubusercontent.com/geopandas/geopandas/"
-        "main/geopandas/tests/data/null_geom.geojson"
-    )
+        "main/geopandas/tests/data/null_geom.geojson",
+        # url to zip file
+        "https://raw.githubusercontent.com/geopandas/geopandas/"
+        "main/geopandas/datasets/nybb_16a.zip",
+        # url to zipfile without extension
+        "https://geonode.goosocean.org/download/480",
+        # url to web service
+        "https://demo.pygeoapi.io/stable/collections/obs/items",
+    ],
+)
+def test_read_file_url(engine, url):
     gdf = read_file(url, engine=engine)
     assert isinstance(gdf, geopandas.GeoDataFrame)
 
 
- at pytest.mark.web
-def test_read_file_remote_zipfile_url(engine):
-    url = (
-        "https://raw.githubusercontent.com/geopandas/geopandas/"
-        "main/geopandas/datasets/nybb_16a.zip"
-    )
-    gdf = read_file(url, engine=engine)
+def test_read_file_local_uri(file_path, engine):
+    local_uri = "file://" + file_path
+    gdf = read_file(local_uri, engine=engine)
     assert isinstance(gdf, geopandas.GeoDataFrame)
 
 



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

-- 
View it on GitLab: https://salsa.debian.org/debian-gis-team/python-geopandas/-/commit/47522943c7e384c9023dd74c04894a0a869d6c5c
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/20230606/aaa87b4d/attachment-0001.htm>


More information about the Pkg-grass-devel mailing list