Skip to main content

Fast and direct raster I/O for use with Numpy and SciPy

Project description

Rasterio reads and writes geospatial raster data.

https://github.com/rasterio/rasterio/actions/workflows/tests.yaml/badge.svg https://github.com/rasterio/rasterio/actions/workflows/test_gdal_latest.yaml/badge.svg https://github.com/rasterio/rasterio/actions/workflows/test_gdal_tags.yaml/badge.svg https://img.shields.io/pypi/v/rasterio

Geographic information systems use GeoTIFF and other formats to organize and store gridded, or raster, datasets. Rasterio reads and writes these formats and provides a Python API based on N-D arrays.

Rasterio 1.4 works with Python >= 3.9, Numpy >= 1.24, and GDAL >= 3.5. Official binary packages for Linux, macOS, and Windows with most built-in format drivers plus HDF5, netCDF, and OpenJPEG2000 are available on PyPI.

Read the documentation for more details: https://rasterio.readthedocs.io/.

Example

Here’s an example of some basic features that Rasterio provides. Three bands are read from an image and averaged to produce something like a panchromatic band. This new band is then written to a new single band TIFF.

import numpy as np
import rasterio

# Read raster bands directly to Numpy arrays.
#
with rasterio.open('tests/data/RGB.byte.tif') as src:
    r, g, b = src.read()

# Combine arrays in place. Expecting that the sum will
# temporarily exceed the 8-bit integer range, initialize it as
# a 64-bit float (the numpy default) array. Adding other
# arrays to it in-place converts those arrays "up" and
# preserves the type of the total array.
total = np.zeros(r.shape)

for band in r, g, b:
    total += band

total /= 3

# Write the product as a raster band to a new 8-bit file. For
# the new file's profile, we start with the meta attributes of
# the source file, but then change the band count to 1, set the
# dtype to uint8, and specify LZW compression.
profile = src.profile
profile.update(dtype=rasterio.uint8, count=1, compress='lzw')

with rasterio.open('example-total.tif', 'w', **profile) as dst:
    dst.write(total.astype(rasterio.uint8), 1)

The output:

http://farm6.staticflickr.com/5501/11393054644_74f54484d9_z_d.jpg

API Overview

Rasterio gives access to properties of a geospatial raster file.

with rasterio.open('tests/data/RGB.byte.tif') as src:
    print(src.width, src.height)
    print(src.crs)
    print(src.transform)
    print(src.count)
    print(src.indexes)

# Printed:
# (791, 718)
# {u'units': u'm', u'no_defs': True, u'ellps': u'WGS84', u'proj': u'utm', u'zone': 18}
# Affine(300.0379266750948, 0.0, 101985.0,
#        0.0, -300.041782729805, 2826915.0)
# 3
# [1, 2, 3]

A rasterio dataset also provides methods for getting read/write windows (like extended array slices) given georeferenced coordinates.

with rasterio.open('tests/data/RGB.byte.tif') as src:
    window = src.window(*src.bounds)
    print(window)
    print(src.read(window=window).shape)

# Printed:
# Window(col_off=0.0, row_off=0.0, width=791.0000000000002, height=718.0)
# (3, 718, 791)

Rasterio CLI

Rasterio’s command line interface, named “rio”, is documented at cli.rst. Its rio insp command opens the hood of any raster dataset so you can poke around using Python.

$ rio insp tests/data/RGB.byte.tif
Rasterio 0.10 Interactive Inspector (Python 3.4.1)
Type "src.meta", "src.read(1)", or "help(src)" for more information.
>>> src.name
'tests/data/RGB.byte.tif'
>>> src.closed
False
>>> src.shape
(718, 791)
>>> src.crs
{'init': 'epsg:32618'}
>>> b, g, r = src.read()
>>> b
masked_array(data =
 [[-- -- -- ..., -- -- --]
 [-- -- -- ..., -- -- --]
 [-- -- -- ..., -- -- --]
 ...,
 [-- -- -- ..., -- -- --]
 [-- -- -- ..., -- -- --]
 [-- -- -- ..., -- -- --]],
             mask =
 [[ True  True  True ...,  True  True  True]
 [ True  True  True ...,  True  True  True]
 [ True  True  True ...,  True  True  True]
 ...,
 [ True  True  True ...,  True  True  True]
 [ True  True  True ...,  True  True  True]
 [ True  True  True ...,  True  True  True]],
       fill_value = 0)

>>> np.nanmin(b), np.nanmax(b), np.nanmean(b)
(0, 255, 29.94772668847656)

Rio Plugins

Rio provides the ability to create subcommands using plugins. See cli.rst for more information on building plugins.

See the plugin registry for a list of available plugins.

Installation

See docs/installation.rst

Support

The primary forum for questions about installation and usage of Rasterio is https://rasterio.groups.io/g/main. The authors and other users will answer questions when they have expertise to share and time to explain. Please take the time to craft a clear question and be patient about responses.

Please do not bring these questions to Rasterio’s issue tracker, which we want to reserve for bug reports and other actionable issues.

Development and Testing

See CONTRIBUTING.rst.

Documentation

See docs/.

License

See LICENSE.txt.

Authors

The rasterio project was begun at Mapbox and was transferred to the rasterio Github organization in October 2021.

See AUTHORS.txt.

Changes

See CHANGES.txt.

Who is Using Rasterio?

See here.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rasterio-1.4.0rc1.tar.gz (440.3 kB view details)

Uploaded Source

Built Distributions

rasterio-1.4.0rc1-cp313-cp313-win_amd64.whl (25.1 MB view details)

Uploaded CPython 3.13 Windows x86-64

rasterio-1.4.0rc1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (22.2 MB view details)

Uploaded CPython 3.13 manylinux: glibc 2.17+ x86-64

rasterio-1.4.0rc1-cp313-cp313-macosx_11_0_arm64.whl (18.9 MB view details)

Uploaded CPython 3.13 macOS 11.0+ ARM64

rasterio-1.4.0rc1-cp313-cp313-macosx_10_15_x86_64.whl (21.5 MB view details)

Uploaded CPython 3.13 macOS 10.15+ x86-64

rasterio-1.4.0rc1-cp312-cp312-win_amd64.whl (25.1 MB view details)

Uploaded CPython 3.12 Windows x86-64

rasterio-1.4.0rc1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (22.2 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

rasterio-1.4.0rc1-cp312-cp312-macosx_11_0_arm64.whl (18.9 MB view details)

Uploaded CPython 3.12 macOS 11.0+ ARM64

rasterio-1.4.0rc1-cp312-cp312-macosx_10_15_x86_64.whl (21.5 MB view details)

Uploaded CPython 3.12 macOS 10.15+ x86-64

rasterio-1.4.0rc1-cp311-cp311-win_amd64.whl (25.2 MB view details)

Uploaded CPython 3.11 Windows x86-64

rasterio-1.4.0rc1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (22.2 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

rasterio-1.4.0rc1-cp311-cp311-macosx_11_0_arm64.whl (18.9 MB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

rasterio-1.4.0rc1-cp311-cp311-macosx_10_15_x86_64.whl (21.5 MB view details)

Uploaded CPython 3.11 macOS 10.15+ x86-64

rasterio-1.4.0rc1-cp310-cp310-win_amd64.whl (25.2 MB view details)

Uploaded CPython 3.10 Windows x86-64

rasterio-1.4.0rc1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (22.2 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

rasterio-1.4.0rc1-cp310-cp310-macosx_11_0_arm64.whl (18.9 MB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

rasterio-1.4.0rc1-cp310-cp310-macosx_10_15_x86_64.whl (21.5 MB view details)

Uploaded CPython 3.10 macOS 10.15+ x86-64

rasterio-1.4.0rc1-cp39-cp39-win_amd64.whl (25.2 MB view details)

Uploaded CPython 3.9 Windows x86-64

rasterio-1.4.0rc1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (22.2 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

rasterio-1.4.0rc1-cp39-cp39-macosx_11_0_arm64.whl (18.9 MB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

rasterio-1.4.0rc1-cp39-cp39-macosx_10_15_x86_64.whl (21.5 MB view details)

Uploaded CPython 3.9 macOS 10.15+ x86-64

File details

Details for the file rasterio-1.4.0rc1.tar.gz.

File metadata

  • Download URL: rasterio-1.4.0rc1.tar.gz
  • Upload date:
  • Size: 440.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.6

File hashes

Hashes for rasterio-1.4.0rc1.tar.gz
Algorithm Hash digest
SHA256 315294c114a17c45f2c502b030ab49899a437380af62e8e4175677655463da7b
MD5 ab7f0430326a17873cf12114cd2465da
BLAKE2b-256 17223769f7248166ff157ea84be1ae667514c614e37674637caee530c5434c10

See more details on using hashes here.

File details

Details for the file rasterio-1.4.0rc1-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for rasterio-1.4.0rc1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 393cde49cd3a9c1b3027526d265d23edb7dbbacb3c62e9717deefb89aaf5c2e9
MD5 0d47e4a93bf6f588aa7eaa41cfccf427
BLAKE2b-256 c96b30a9364c07bfe9feaa59e1678a2b2547cb56f05e398b8cdf39b8f1b56635

See more details on using hashes here.

File details

Details for the file rasterio-1.4.0rc1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rasterio-1.4.0rc1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 bc16b72d0f2b1f5ba497098a1b97a5eb932df14c04c6b45a936772ccf2ca0fe2
MD5 19c5d36e25c36254a942575c21578f4b
BLAKE2b-256 6452743f8726c76f57e36023ad1b51cfe9bcd30e1646261654cd2c6a2a46a4ef

See more details on using hashes here.

File details

Details for the file rasterio-1.4.0rc1-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rasterio-1.4.0rc1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 97b64c5af1c546f750ca37566d4efc766667a25433ce5e19c9f2fb1026451f62
MD5 98e0146d39d39aa31e861581435dd3c1
BLAKE2b-256 6b5f57bdab5e0afba66a5e6b2700ee515eb4d9d6b3c1846a16258881afae36ad

See more details on using hashes here.

File details

Details for the file rasterio-1.4.0rc1-cp313-cp313-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for rasterio-1.4.0rc1-cp313-cp313-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 6b22eb9acd07d670b60c7d94fc87eb7bc170a070b8f6d2f295ec0e48df04d7d5
MD5 ea4d4e4c055af499b5b2a55b59bc9be5
BLAKE2b-256 c4882eb437cc9ac84500e876ec3533c146c8defb2b7be481cdef9449a3a7bdaf

See more details on using hashes here.

File details

Details for the file rasterio-1.4.0rc1-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for rasterio-1.4.0rc1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 026f10e9c942e31806130deabc9bd1bb92fca1060186146eb2aeb702876b823e
MD5 1d3fff62ac9dd880445f04ea8e45151d
BLAKE2b-256 290f19a8723a08f9c0cbcaf7f15a1ce222089b3b645a8825b103036b4c162c0e

See more details on using hashes here.

File details

Details for the file rasterio-1.4.0rc1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rasterio-1.4.0rc1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 50017c6ced0fbf984125771b0e52dbcc210a77d50cba3d4336a8e9acd9fa8345
MD5 8660e022641adce4333b6a10b483b02f
BLAKE2b-256 a3d61251f9cdd500da8b5c9ecb0352e43a6661835f1a11a491478e9ec0ade9cb

See more details on using hashes here.

File details

Details for the file rasterio-1.4.0rc1-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rasterio-1.4.0rc1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 71f1f51fa936598f19fcfea0b0a50799e79f064bec4a26f445fdd2d615a685ea
MD5 8ee7c62c07ab542c2d99f9dcc30c2c9e
BLAKE2b-256 80e98f32ea60996ae8a093fb72f2876be8cbf22a615a39c44a52b629199dd17f

See more details on using hashes here.

File details

Details for the file rasterio-1.4.0rc1-cp312-cp312-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for rasterio-1.4.0rc1-cp312-cp312-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 b0f23824757dda70bf0d12655137c16ea39bbedc9f9015b18b4a0ae5d7172536
MD5 a676923a1b68c73613d81d56ab9c0dfa
BLAKE2b-256 48aae48aac2d37b7e852f27aa190e552f9d9dd011b83cc149401616e965c9d61

See more details on using hashes here.

File details

Details for the file rasterio-1.4.0rc1-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for rasterio-1.4.0rc1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 57d71123918a80cc9adb2950d31ce2facfbbe7a2e31f1ff5256812a1dba4d9ee
MD5 c3a8d6613ba74b0ab0ff684b8286f8ff
BLAKE2b-256 5682e289fa14146ef56afed1f422c9c3592578f0fe74c20225957f29563c94ba

See more details on using hashes here.

File details

Details for the file rasterio-1.4.0rc1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rasterio-1.4.0rc1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 92de69c11667515ad6535ec7729ccc637bf8ba6a618d282b4479fad1f7e25b8f
MD5 d7b5b9b8fcb485b5b0b0c4de83768414
BLAKE2b-256 e79649ca807ad557ee3102fc7d42b670d54249137790ab56459804a5ea7c27c6

See more details on using hashes here.

File details

Details for the file rasterio-1.4.0rc1-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rasterio-1.4.0rc1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a259abd72f551e502140c641549d547c22a667a94b0ba269984ee2869ab033ea
MD5 bca9cf8884e4c5dda8848eda904d9ff3
BLAKE2b-256 b4674ebd7453cfd6ba617efd4daec995b1a3b2733f94cd928e2c345b1a441145

See more details on using hashes here.

File details

Details for the file rasterio-1.4.0rc1-cp311-cp311-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for rasterio-1.4.0rc1-cp311-cp311-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 41ccf6973a556e1b794e1ccfa593ec2e449b4f50b17299b6baabd356ab65e2bd
MD5 d43f0a430ea603c288ea0468a181d8c5
BLAKE2b-256 122450a32b8e319c5d6dab5dfb362c2e110a45df577fa67eccb316719968078d

See more details on using hashes here.

File details

Details for the file rasterio-1.4.0rc1-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for rasterio-1.4.0rc1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 3488b575c0642c2f7d149b111023896f3c375781dbad265eede7dceeb297caac
MD5 7b0acb8341cd7ff875973e6d7d49aff6
BLAKE2b-256 b345e5b00ba20c71036cdad662d711fc2ae853804634304dde72ac08dcc43cea

See more details on using hashes here.

File details

Details for the file rasterio-1.4.0rc1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rasterio-1.4.0rc1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5f542946c8a3b7ba9ac7fc2cda4859f835de075161f0720bf49393c0aaa04c4e
MD5 960920fc3635f3830496b83fc7052051
BLAKE2b-256 a9ef74512f575b98f31e69ff0c00fa4b1c4c444b7068067c376bdb9f8124396a

See more details on using hashes here.

File details

Details for the file rasterio-1.4.0rc1-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rasterio-1.4.0rc1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 02f24b093952a0632dcb7635834f010acab605e5cf53c8e0f6bb4bd4cf9d1ad2
MD5 c40de0ebef50e53376d66586cf33b53b
BLAKE2b-256 b600579dfb166d09e2f13f34fc4387db2b76a4935984ffbc75269c54011bc2ff

See more details on using hashes here.

File details

Details for the file rasterio-1.4.0rc1-cp310-cp310-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for rasterio-1.4.0rc1-cp310-cp310-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 db1587f972639e280d626d54b2d9dc195a4ae8547adc4059340fa2148b1bb17e
MD5 4adccba1fd7308f0636484baa9f288b0
BLAKE2b-256 5a458316eb01f0a655d0a46e4b0366bd11135ece39f53635c27bd0f0684a884b

See more details on using hashes here.

File details

Details for the file rasterio-1.4.0rc1-cp39-cp39-win_amd64.whl.

File metadata

File hashes

Hashes for rasterio-1.4.0rc1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 546107e7fd44104d3b225cea68ec52d3c283f9bd63ff9ef9fb39e950ed7bd095
MD5 db3005c0146f68a7b741630aa9deb99d
BLAKE2b-256 860cac24420bc4479e4d1eaaced4a412d18fddb28b8532f9985ba9220fb80dd5

See more details on using hashes here.

File details

Details for the file rasterio-1.4.0rc1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rasterio-1.4.0rc1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3f48b89009eaab03e2270568fd6f3a5f40f6b9ed5dfec866820b7866e5038dd1
MD5 a0b5cb6a62fb78a741f74231593f6888
BLAKE2b-256 ea13eb1bd862395fe9093c5941e0ee21f847c4492ad4abc675408a9c28b29234

See more details on using hashes here.

File details

Details for the file rasterio-1.4.0rc1-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rasterio-1.4.0rc1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0ab69bc549ef96fe3712d8d409aa3f01d56a1db9a757d538c2cc478aa8e961f5
MD5 34c25c0ca52aca6c7522193547acd1e5
BLAKE2b-256 fd0a73cb27b45b3a0f9c521d5d90c8b8108ae4bca76bd975653e5d9e4d2e4d39

See more details on using hashes here.

File details

Details for the file rasterio-1.4.0rc1-cp39-cp39-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for rasterio-1.4.0rc1-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 ca511c3eaaab2ac524d552635e1e50ab849ab31741bfeea3ff88f455b033bc7a
MD5 e90199fabc308c066c0d576999764d21
BLAKE2b-256 08fc5717229fe216cd059b88b37cc3c6240ea0c750d6dc910bcff68beb97fabb

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page