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.0rc2.tar.gz (439.4 kB view details)

Uploaded Source

Built Distributions

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

Uploaded CPython 3.13 Windows x86-64

rasterio-1.4.0rc2-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.0rc2-cp313-cp313-macosx_11_0_arm64.whl (18.9 MB view details)

Uploaded CPython 3.13 macOS 11.0+ ARM64

rasterio-1.4.0rc2-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.0rc2-cp312-cp312-win_amd64.whl (25.1 MB view details)

Uploaded CPython 3.12 Windows x86-64

rasterio-1.4.0rc2-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.0rc2-cp312-cp312-macosx_11_0_arm64.whl (18.9 MB view details)

Uploaded CPython 3.12 macOS 11.0+ ARM64

rasterio-1.4.0rc2-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.0rc2-cp311-cp311-win_amd64.whl (25.2 MB view details)

Uploaded CPython 3.11 Windows x86-64

rasterio-1.4.0rc2-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.0rc2-cp311-cp311-macosx_11_0_arm64.whl (18.9 MB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

rasterio-1.4.0rc2-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.0rc2-cp310-cp310-win_amd64.whl (25.2 MB view details)

Uploaded CPython 3.10 Windows x86-64

rasterio-1.4.0rc2-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.0rc2-cp310-cp310-macosx_11_0_arm64.whl (18.9 MB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

rasterio-1.4.0rc2-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.0rc2-cp39-cp39-win_amd64.whl (25.2 MB view details)

Uploaded CPython 3.9 Windows x86-64

rasterio-1.4.0rc2-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.0rc2-cp39-cp39-macosx_11_0_arm64.whl (18.9 MB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

rasterio-1.4.0rc2-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.0rc2.tar.gz.

File metadata

  • Download URL: rasterio-1.4.0rc2.tar.gz
  • Upload date:
  • Size: 439.4 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.0rc2.tar.gz
Algorithm Hash digest
SHA256 530481583e76083d848539fc527030b5ae468ae4e2ade7efaa704db82282eafd
MD5 4758b1b72991a96c32519be35e4e682c
BLAKE2b-256 754f450b8b3b7de1f044ef6c813b099e3357d6b0af157e4d8b0abd34c76adcf8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rasterio-1.4.0rc2-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 66a7547a927b7803b7cddaf79307fbd57263bf4b1b34935b363c2eb1724dfec9
MD5 e008851d786caec9e5e3e803700a4f3e
BLAKE2b-256 4fcebe9fa4815f6b00ad32356741fe46ed0dee55734be71034ca7d32cf4c58bc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rasterio-1.4.0rc2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 db859b1bc4be23aa0126e114345eccfd6af358b8e28b6bdcb62ea783d1d2aeaf
MD5 76ffc2bba424c37289d5c07e7b1c7428
BLAKE2b-256 6b5e62385bb7b7cf3ab1fc49d925f705fc5ce40b207092ba7efa78d08111d86f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rasterio-1.4.0rc2-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fe2c0ed4eced223f38a46c4c7cd8e43052e832dc4a7c60d429421d1783b88615
MD5 69872d67ffdb56a6d872190d41ed73b0
BLAKE2b-256 7740311589224e963a58b85633f54c3b0b2c88994660f0c39b9196997e3f9afa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rasterio-1.4.0rc2-cp313-cp313-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 addf7b6f7054e9e867db47db818bd221a1fdf997799bd8fb83264329c9159289
MD5 d6f4dff54f76f062f7f88e1d01bc2a4e
BLAKE2b-256 bad8dc4f6371648ebdc73a05c98eefaa2bcd470a22deba18ef7347d98cf342b8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rasterio-1.4.0rc2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 22f23100275724ac117dc806eb311d3289519eb30c15400461cb5402b22dbb49
MD5 0255ed08af505463bf89583ea67d4cf0
BLAKE2b-256 131b6c6f7ddfc3378ffb4dc6031396b9301ec9f73d1e4a28f357c73e99a37b55

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rasterio-1.4.0rc2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0b9d46e16d32f0743ebadf90af67c390d350ae88a8f99799b631a188280fff00
MD5 a89716c95e3e9ea392f5a564787c5dd2
BLAKE2b-256 300eeb957b15533dc347a39b7390428700439b1f6d13d1d4e3820fea74089644

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rasterio-1.4.0rc2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ea29fb2bcabd0756779a7d534db523d7ed09ad70ed761113aaea9e386b3251dc
MD5 51098ebda762abf557c7dd761292d951
BLAKE2b-256 11dfae65ac5d56a24a03048aa9b118d0f32a562e08a570d99e6b21b27d90a1f8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rasterio-1.4.0rc2-cp312-cp312-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 f8d09427556b9fdfefcb6941483cfee780acd9b0793e8f6081b08150e228cdf5
MD5 aeae244f5a1c9990488a6285b29761aa
BLAKE2b-256 76e322a4243ee61ab47249a78197b98ab50c1f00d8a13e6292cf2f3a2d57f49e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rasterio-1.4.0rc2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 f61487d38a2765bcab5c554ef0fb984eb86b8454aa74cb7271881bc0c2635b1e
MD5 854d4622b88f616f8e8fbb484fed88cc
BLAKE2b-256 5a539560afcbde4938746c469c2e023d08e2fe4d18ef654803f52028985ce314

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rasterio-1.4.0rc2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d128993bcc0933da51a48c0b557a510dc0864a31143a3bb549496deb620e5980
MD5 d88819346ea0dbc50e93e4e294a06179
BLAKE2b-256 2eb6e3863a4900173b9ac3d7780843c02c43be6b1000e65ddd9bb2cb4ffc67fb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rasterio-1.4.0rc2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6a53f2717c71876b2f7383b83dd2f72b6b2bbc6fffaebb750cb5ea4113d60ebe
MD5 9da45c7e42edac4d4f1524e76948cb16
BLAKE2b-256 8ff2dfd0d489e7626cc64ea0fe073e507549341d718905d081681f0d71696281

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rasterio-1.4.0rc2-cp311-cp311-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 069e0c30c5007d78d4ca105a3ece3ea46bf83cf94f2037f6cfd0c9842f6aefc1
MD5 b218b4ab276c2731f6e7231b98cafc05
BLAKE2b-256 a56ded4eb19906c9bdfb7a5b7c3c998d8827f0a3bfc16e0689f48e07ff6f914a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rasterio-1.4.0rc2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 dd285f847ebd7edd0d22f4d20e6679254816ce1d4044b12788a501061359716f
MD5 ad170c093d553cdfa7ea9c00169f3d55
BLAKE2b-256 2dca3668e0e84e35d04843ebf3a7fb7ff2a3db576f85cfe0b637f72292705a36

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rasterio-1.4.0rc2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a3901124b36b8183f1e7d6d19812eec22efff42308d7ab83411a55ee8b6b622f
MD5 961c4b084d7afc34dc6b451b76a61525
BLAKE2b-256 52a1577474a7e66ec1882e7655f2b6b9e69f1d9acd6018c53a2fe7eaa0866503

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rasterio-1.4.0rc2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 363ac9a3c1f4e60573befc2eb334cd4de0e27744062d94f6af7b703b7c18822f
MD5 e06b72d8ffaa5c9f3df99376129c35d2
BLAKE2b-256 2ae93abf34997f3c8742057a9c0d3a8560cfd52d5c7da09cb52d8fd5fee67c07

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rasterio-1.4.0rc2-cp310-cp310-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 a885e2fad94a5ae830f1482aeb59cf7f9c69a4d718c379bc5cf6aa9ab53b2424
MD5 e1217dc609526407e2d312250740453e
BLAKE2b-256 56547c9784a7502094fb3f6d2dbcd83ec2a20d7a6e1d10b7f7e9d55b60bf6378

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rasterio-1.4.0rc2-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 d4c0eee69ba2518a2c457c7e02c073c8f93b31b3d7896eee5979f6bd914e3f54
MD5 4056b645df875311c7fb3ddc294c85ee
BLAKE2b-256 9cbc3a36cd78bc5abc59aabcedb13b9a3b81934413c297cf199a3cc3280b2931

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rasterio-1.4.0rc2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8854136ea02b49ab50f45552fb4b9e43e909f23072d3b2b664fee3061c41d90e
MD5 d7fd24d9d12e07d4252409cc68496b4b
BLAKE2b-256 5cf342799dc456e35ef3caf8c74b655918784bb1e92d9e8917d50bd31da5f06a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rasterio-1.4.0rc2-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ed750ff27244472e0b075c4ff3433a8cdab3dda0e87ad33636bf68c43900d9c3
MD5 d1d88f2e25d91bc72e9aebbaff3fa42d
BLAKE2b-256 fa6395b6d428ede99f1ca8ead83c12436a17e644b62bdc93bc4dcd83da6e820a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rasterio-1.4.0rc2-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 a4614e2700c1288f49a683a667b64f81fe8b50f9afa15f0078ff3d1771a5506b
MD5 f6e5a01ed44429c5db4f21f46bb3bb68
BLAKE2b-256 eaa13cf378bd863a2b6c8bdfb11d7fe2369908010fc8051041cef016582b4067

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