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.21+, and GDAL 3.3+. 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.4b2.tar.gz (441.2 kB view details)

Uploaded Source

Built Distributions

rasterio-1.4b2-cp313-cp313-win_amd64.whl (25.1 MB view details)

Uploaded CPython 3.13 Windows x86-64

rasterio-1.4b2-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.4b2-cp313-cp313-macosx_11_0_arm64.whl (18.9 MB view details)

Uploaded CPython 3.13 macOS 11.0+ ARM64

rasterio-1.4b2-cp313-cp313-macosx_10_15_x86_64.whl (21.5 MB view details)

Uploaded CPython 3.13 macOS 10.15+ x86-64

rasterio-1.4b2-cp312-cp312-win_amd64.whl (25.1 MB view details)

Uploaded CPython 3.12 Windows x86-64

rasterio-1.4b2-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.4b2-cp312-cp312-macosx_11_0_arm64.whl (18.9 MB view details)

Uploaded CPython 3.12 macOS 11.0+ ARM64

rasterio-1.4b2-cp312-cp312-macosx_10_15_x86_64.whl (21.5 MB view details)

Uploaded CPython 3.12 macOS 10.15+ x86-64

rasterio-1.4b2-cp311-cp311-win_amd64.whl (25.2 MB view details)

Uploaded CPython 3.11 Windows x86-64

rasterio-1.4b2-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.4b2-cp311-cp311-macosx_11_0_arm64.whl (18.9 MB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

rasterio-1.4b2-cp311-cp311-macosx_10_15_x86_64.whl (21.5 MB view details)

Uploaded CPython 3.11 macOS 10.15+ x86-64

rasterio-1.4b2-cp310-cp310-win_amd64.whl (25.2 MB view details)

Uploaded CPython 3.10 Windows x86-64

rasterio-1.4b2-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.4b2-cp310-cp310-macosx_11_0_arm64.whl (18.9 MB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

rasterio-1.4b2-cp310-cp310-macosx_10_15_x86_64.whl (21.5 MB view details)

Uploaded CPython 3.10 macOS 10.15+ x86-64

rasterio-1.4b2-cp39-cp39-win_amd64.whl (25.2 MB view details)

Uploaded CPython 3.9 Windows x86-64

rasterio-1.4b2-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.4b2-cp39-cp39-macosx_11_0_arm64.whl (18.9 MB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

rasterio-1.4b2-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.4b2.tar.gz.

File metadata

  • Download URL: rasterio-1.4b2.tar.gz
  • Upload date:
  • Size: 441.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for rasterio-1.4b2.tar.gz
Algorithm Hash digest
SHA256 86b97342bd44f53470f6c56b00b247e2163bfcc2e7113152b61394ebe8513f02
MD5 474fd6ea59702ed6e6f3de590d7f3201
BLAKE2b-256 777b26044ea91eba24429ce25586f64f85a421df14c1da3ffc909d7134e62597

See more details on using hashes here.

File details

Details for the file rasterio-1.4b2-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: rasterio-1.4b2-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 25.1 MB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for rasterio-1.4b2-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 f4828be7da9d4b85c5110ce3da4342372016872ca118501d8fac600cdd96c808
MD5 b1ca17820074096e43d3e7f410a53449
BLAKE2b-256 b600881c72a60c0843599b12ed7e073cde43ad15511bbd8f580ce48ce316b247

See more details on using hashes here.

File details

Details for the file rasterio-1.4b2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rasterio-1.4b2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 907c35494fb9acdc6f1d0a276178adbb035020a9dc672bc336cb3e06447012cc
MD5 1264aa09935a88cd3fff11d387c4b551
BLAKE2b-256 57ed0e9d26c7c5e7a68904a0c0152bf91bfcfbd0fd659ba7b8ef8e8f8a90b245

See more details on using hashes here.

File details

Details for the file rasterio-1.4b2-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rasterio-1.4b2-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7b08273051fb39121734df959a1c1afb87ebe620151d1f0b40ccc2811ed296f6
MD5 114decfb7f7dc9960bb8cbc0540535d6
BLAKE2b-256 32cda822740ad1bf24195242d3b22a611ed9b49941f82677ff246b969947909e

See more details on using hashes here.

File details

Details for the file rasterio-1.4b2-cp313-cp313-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for rasterio-1.4b2-cp313-cp313-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 8eec82eb151adf9b4252fc69fffa1da50d211b9b6d2b559ef2ffed0aab7ad63c
MD5 1347a7aa5b8c73fbb2a41597a8a5dccc
BLAKE2b-256 1f3d8d84780d45e8e35ba860b158b8e292f57af9fafa9d1f2273a2a11b1611b3

See more details on using hashes here.

File details

Details for the file rasterio-1.4b2-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: rasterio-1.4b2-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 25.1 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for rasterio-1.4b2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 83e88f768221eb7d050a734271a5f7692fb48a33d70c4a0432857eff42f26466
MD5 d227ae041440f32e014c543f82d96730
BLAKE2b-256 f58aae55855d5a424f439523023710c2c3ba318610c6169bd36a5141b9b4a71f

See more details on using hashes here.

File details

Details for the file rasterio-1.4b2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rasterio-1.4b2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 bd5a9112aba9480c322e59bbfde7805d16527af7badf6493b341807e01025a69
MD5 7a78eb7f02b95d9e47ac5b92a9f1b5f8
BLAKE2b-256 2b6d0c7f3262ab4c1d16f999f00962b5c322788e3f683b54dd0cf964b4e47b0b

See more details on using hashes here.

File details

Details for the file rasterio-1.4b2-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rasterio-1.4b2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d0bc86b1371292af81d5701e96f96ced0595c84bcdd08dd7075deaaea4c8ddc1
MD5 64f27177a0448e89cb9c3b6e784386e8
BLAKE2b-256 d6da3de2621f6609f3a423008fd533713736399be2d4d25b252122f706284461

See more details on using hashes here.

File details

Details for the file rasterio-1.4b2-cp312-cp312-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for rasterio-1.4b2-cp312-cp312-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 c34c9d676e0c06a8df270b7b49c4da3839be7fb27243ca809f827ec5c888a758
MD5 79d722f2a5befad06d4d771583cc2136
BLAKE2b-256 0bac39b403e396a5587158db3ddcba361ddd4cc5fd813890286e4c63285413f2

See more details on using hashes here.

File details

Details for the file rasterio-1.4b2-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: rasterio-1.4b2-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 25.2 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for rasterio-1.4b2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 b81398291f9e0e936596a936fb3ac2a1a8fb19acb48a1aec4930107609e1a37c
MD5 ef2cc570f6bf6c2c791496c54e547ec8
BLAKE2b-256 51697f1bb78d7f525458cdd8cd3e840ef7260901b9851f0d10a01579eaf434f0

See more details on using hashes here.

File details

Details for the file rasterio-1.4b2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rasterio-1.4b2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b382ee91302822c630294bdc841fd7ab971dbb4d11c670b884f445332f4a9d12
MD5 aa807f6ea3e07ef44386201fbff079d1
BLAKE2b-256 fe968196bf790a7d9badfa630b1526010a5cf952a365fa238123b72a3a69ea66

See more details on using hashes here.

File details

Details for the file rasterio-1.4b2-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rasterio-1.4b2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5d5b64afeaa5f6422691b3ff42bc69871dba1388d8b3c1b4893c78670f6d0e04
MD5 088f97758114d54536d3c858b5cfc1e4
BLAKE2b-256 795a6365c6e88aac0ad840ff38591fc8bd62ab972879dc60ee810518603aa0ea

See more details on using hashes here.

File details

Details for the file rasterio-1.4b2-cp311-cp311-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for rasterio-1.4b2-cp311-cp311-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 e951ccfab31867fc204dd5fbe31008d93dceb5de3e59a95821937b67136587ba
MD5 d5d488ad4207a3029ae27fff0c94fa6d
BLAKE2b-256 fc66dea59d5b324a4abdf8b8ca6399713b5436f4ae6e691e9a500bec6c3e8540

See more details on using hashes here.

File details

Details for the file rasterio-1.4b2-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: rasterio-1.4b2-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 25.2 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for rasterio-1.4b2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 00d3e2e6afeebb2b06bb4200cc9f261073e4fc2cfb737327c042bd78008c4308
MD5 66e15dfeec3b034bbf1233866bb9f407
BLAKE2b-256 e18da32600331622ad12298f5af4bbdd0f25aa4b865a1a63882d3ec8a47b9624

See more details on using hashes here.

File details

Details for the file rasterio-1.4b2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rasterio-1.4b2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f3e5386730d3b103bbfe62c6192dae1eabb297d6e4e715b15da45576735eb4e7
MD5 9e4ce4444c4c51b3afacff0846c805c1
BLAKE2b-256 128c07336e595a9b4614621c3665f85d5c7e0ecb75d0c5660c8f4f822434e869

See more details on using hashes here.

File details

Details for the file rasterio-1.4b2-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rasterio-1.4b2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0bd5bd625edf80e9cdc6e92abe894a253205dab06ebe9230fc53cd6af81cc8df
MD5 f8e98f48c4c2cb30cd97ce02d601cf3b
BLAKE2b-256 8271fbbddb543d53d642f099166de6edd5308e478ea62518e0bb4c3ef9934b72

See more details on using hashes here.

File details

Details for the file rasterio-1.4b2-cp310-cp310-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for rasterio-1.4b2-cp310-cp310-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 5a1f1c3a04ef2e861f271fef1904ac4d0c7e19555b121a723d7b32e3f763526f
MD5 9cc7ccda8bb33b849a4fb623b49f56d0
BLAKE2b-256 f4b9090028d14482ecc7b2081d10d45baaee241adf69bb403e69542d889adb06

See more details on using hashes here.

File details

Details for the file rasterio-1.4b2-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: rasterio-1.4b2-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 25.2 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for rasterio-1.4b2-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 969997e11732593e8b92a8b1cf5e37c50e9bb4ee1e5c7759cd796e29a1df88b9
MD5 146cb418902b797d1c83de2d8985eb38
BLAKE2b-256 5a76f81d36002d48dd540d346d62be7a2f41e0bae129e988586c341fe1fdc025

See more details on using hashes here.

File details

Details for the file rasterio-1.4b2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rasterio-1.4b2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d82f122a881e35a7b9b895485d97b530c364cb9fce37a47d654f3acaf421a8da
MD5 77e3db70c6d76312d5604a2278a1ff66
BLAKE2b-256 c9208b4778564cac408be6172e1c25ff3d86ed9d652887adb921d5c5ae7d5bc2

See more details on using hashes here.

File details

Details for the file rasterio-1.4b2-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rasterio-1.4b2-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a3d724d8df95d15699712e6cc12a531d8e0a82da446784ecbe62eb7dc99e1bda
MD5 031a112b18a67e447038a808d37b0dbf
BLAKE2b-256 b1e7bf02176d516508b96f50587fff38c8f974dfef9c41131f4216ee8e427592

See more details on using hashes here.

File details

Details for the file rasterio-1.4b2-cp39-cp39-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for rasterio-1.4b2-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 9e6e271dcd00286595a7902cb24915ea6e018a10b70099eb706a467401806968
MD5 205279c0f3b108fec8e2fefe63a667f4
BLAKE2b-256 6a47a455cde6c4209e225f828d171870d8c314512be1785f402f47fee88f07fd

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