Giter VIP home page Giter VIP logo

Comments (4)

sgillies avatar sgillies commented on June 1, 2024

@m-richards fiona's path module was never intended to be used by other projects. It's only public by accident. If I had known geopandas was using them, I would have warned you all sooner. Geopandas should try to rely only on passing URIs to its reader/writer.

from geopandas.

jorisvandenbossche avatar jorisvandenbossche commented on June 1, 2024

Note that geopandas was not only using fiona.path, but also some objects that were exposed publicly in the top-level fiona namespace (i.e. fiona.parse_path). So if fiona wants to make those private, in geopandas we can of course update our code, but also for other users it might still be nice to first include a deprecation warning about the removal.

from geopandas.

jorisvandenbossche avatar jorisvandenbossche commented on June 1, 2024

Temporarily pinning to fiona 1.9 to get green CI -> #3208

from geopandas.

jorisvandenbossche avatar jorisvandenbossche commented on June 1, 2024

The main usage of fiona.path in our code is related to handling with zip files. It might also be that things have improved on fiona's side lately and not everything might still be needed.

We have this helper to check if a path points to a zip-file:

def _is_zip(path):
"""Check if a given path is a zipfile"""
parsed = fiona.path.ParsedPath.from_uri(path)
return (
parsed.archive.endswith(".zip")
if parsed.archive
else parsed.path.endswith(".zip")
)

and then if that is the case, we have the following piece of code to add "zip" to the path's scheme:

# Opening a file via URL or file-like-object above automatically detects a
# zipped file. In order to match that behavior, attempt to add a zip scheme
# if missing.
if _is_zip(str(path_or_bytes)):
parsed = fiona.parse_path(str(path_or_bytes))
if isinstance(parsed, fiona.path.ParsedPath):
# If fiona is able to parse the path, we can safely look at the scheme
# and update it to have a zip scheme if necessary.
schemes = (parsed.scheme or "").split("+")
if "zip" not in schemes:
parsed.scheme = "+".join(["zip"] + schemes)
path_or_bytes = parsed.name
elif isinstance(parsed, fiona.path.UnparsedPath) and not str(
path_or_bytes
).startswith("/vsi"):
# If fiona is unable to parse the path, it might have a Windows drive
# scheme. Try adding zip:// to the front. If the path starts with "/vsi"
# it is a legacy GDAL path type, so let it pass unmodified.
path_or_bytes = "zip://" + parsed.name

This is to make sure a user you can just pass a path to a zipfile like "path/to/file.zip", instead of needing to do "zip://./path/to/file.zip".

from geopandas.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.