Registry / data / fiona
library1.10.1pypypi✓ verified 26d ago

Fiona is a Python library for reading and writing spatial data files, providing a high-level API built on GDAL/OGR. It enables seamless interaction with various vector data formats like Shapefile, GeoJSON, and KML. The current version is 1.10.1, with an active development cycle that includes regular bug fixes, feature additions, and pre-releases leading up to major versions.

pip install fiona
INSTALL
IMPORT
SIG · FIONA
F
fiona
datapythonv1.10.1
Install
2.7s avg
Import
Disk
69MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.10.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
build_error
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.7s · import 0.000s · 71MB
69MB installed
● package 69MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

fiona
import fiona
open
import fiona # ... fiona.open(...)
CRS
from fiona.crs import CRS
path
import os.path
import fiona.path
The `fiona.path` module and its members were deprecated and removed in 1.10.0; use standard `os.path` instead.

This quickstart demonstrates how to create a simple GeoJSON file using Fiona, write a feature to it, and then read the data back. It covers defining schema, CRS, and using the `fiona.open` context manager for file operations.

import fiona import os # Create a dummy GeoJSON file for demonstration geoj_feature = { 'type': 'Feature', 'geometry': {'type': 'Point', 'coordinates': (10, 20)}, 'properties': {'name': 'test_point'} } # Define the schema for the output file schema = { 'geometry': 'Point', 'properties': {'name': 'str'}, } # Define the Coordinate Reference System (CRS) crs = 'EPSG:4326' # Define the driver (file format) driver = 'GeoJSON' output_file = 'temp_fiona_test.geojson' # Write data to a new GeoJSON file with fiona.open( output_file, 'w', driver=driver, crs=crs, schema=schema ) as collection: collection.write(geoj_feature) print(f"Successfully wrote data to {output_file}") # Read data from the created file with fiona.open(output_file, 'r') as collection: print(f"\nDriver: {collection.driver}") print(f"CRS: {collection.crs}") print(f"Schema: {collection.schema}") for feature in collection: print(f"Read Feature: {feature}") # Clean up the dummy file os.remove(output_file) print(f"Cleaned up {output_file}")
fio --version
Debug
Known issues
breakingThe `fiona.path` module and its members (e.g., `fiona.fspath`, `fiona.BytesIOResource`) were removed in Fiona 1.10.0. Code relying on these for path manipulation or in-memory resources will break.
fix
Replace usages of `fiona.path` functions with standard Python equivalents, such as `os.path` for path manipulation or the `io` module for in-memory resources.
affects: >=1.10.0
deprecatedMutable item access to `Feature`, `Geometry`, and `Properties` instances is deprecated. Instances of these classes will become immutable in a future major version (2.0), leading to `TypeError` if modification is attempted.
fix
Avoid direct mutation of these objects. For modifications, create new instances with updated values, or use methods provided by Fiona for safer data manipulation if available.
affects: >=1.10.0
gotchaFiona relies on underlying C libraries (GDAL, PROJ, GEOS). While `pip install fiona` typically provides wheels bundling these for common platforms, issues can arise on specific systems, custom environments, or when mixing with system-installed GDAL versions, leading to import errors or runtime crashes.
fix
Ensure a compatible GDAL/PROJ/GEOS installation. Consider using Conda (e.g., `conda install -c conda-forge fiona`) for robust dependency management on non-standard setups, or building from source with specific GDAL versions if necessary.
affects: <all>
deprecatedAttributes like `fiona.schema.FIELD_TYPES`, `FIELD_TYPES_MAP`, and `FIELD_TYPES_MAP_REV` are deprecated and will be removed in Fiona 2.0.
fix
Refactor code to avoid direct reliance on these internal schema attributes. Refer to the official documentation for recommended ways to inspect or manage field types.
affects: >=1.10.0
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'fiona'
The Fiona library is not installed in the Python environment or the environment where the code is run is not activated.
fix
Install the fiona library using pip or conda: `pip install fiona` or `conda install fiona`.
OSError: Could not find or access the GDAL library. Ensure that GDAL is installed and available in your system's PATH, or set the GDAL_LIBRARY_PATH environment variable.
Fiona cannot locate its underlying GDAL dependency, often due to an incomplete or incorrectly configured GDAL installation, or missing environment variables pointing to the GDAL library.
fix
Ensure GDAL is properly installed (e.g., `conda install gdal` or using a pre-compiled wheel for your OS if pip installing) and its binaries are in the system PATH, or manually set `os.environ['GDAL_LIBRARY_PATH']` to the GDAL library's full path before importing fiona.
fiona.errors.DriverError: 'path/to/file.shp' cannot be opened.
Fiona cannot access the specified spatial data file, possibly due to an incorrect file path, insufficient read/write permissions, the file being locked by another process, or file corruption.
fix
Verify the file path is correct and accessible, ensure the file is not in use by another application, and check directory/file permissions for read/write access.
fiona.errors.CRSError: CRS must be a dict or a fiona.crs.CRS object, got None
The Coordinate Reference System (CRS) parameter passed to `fiona.open()` or related functions is either missing or an invalid type, such as `None`, when a dictionary or `fiona.crs.CRS` object is expected.
fix
Provide a valid CRS dictionary or `fiona.crs.CRS` object, for example `{'init': 'epsg:4326'}` or `fiona.crs.from_epsg(4326)` when opening or creating a dataset.
fiona.errors.DriverError: The 'GeoJSON' driver is not available for writing.
The underlying GDAL/OGR installation Fiona is using does not have the specified driver (e.g., GeoJSON, ESRI Shapefile) compiled or enabled, preventing the reading or writing of that specific file format.
fix
Install a GDAL/OGR distribution that includes support for the required driver, or use a different file format and corresponding driver that is available with your current GDAL installation (e.g., `conda install gdal` often provides a comprehensive build).
Upgrade
Version history
1.10.1latest on PyPI · released Sep 16, 2024
Audit
Dependencies
pythonrequiredRequires Python 3.8 or higher.
Agent activity
29 hits · last 30 days
node
24
Resources
fiona — pip install fiona · libregistry