Raster & rasterio

Reading, sampling and converting raster data in Python.

A raster as an array of rows and columns plus the affine transform that turns them into coordinates. an array of numbers, and one transform that makes it a placerow 1, col 1transform* (col, row)530034, 181169a placeEvery raster bug worth the name is an array and a transform that stopped agreeing

A raster is an array plus an affine transform. The array has rows and columns; the transform is the only thing that makes them a place. Nearly every raster bug worth the name is those two disagreeing — a window read without its transform updated, a reprojection that changed the CRS but not the grid, a resample that moved the origin by half a cell.

The second recurring theme is dtype and NoData. An integer array silently truncates a float calculation; a NoData value that collides with real data hides it; and a viewer that stretches to the full range shows you black where the file is fine. None of these raise.

Below: the concepts cover the data model, resampling and what each operation computes; the how-to guides read, window, sample, reproject, mosaic and convert; and the fixes are the outputs that come back black, empty, shifted or the wrong size.

Learning paths run through this topic too — see the end of this page.

🧭 Start with the concepts

The ideas the how-to guides below assume you already have.

Show every concept in this topic

⚙️ Then do the task

Step-by-step walkthroughs with code you can copy and adapt.

Show every how-to guide in this topic

🔧 When it breaks

The errors this topic produces, with the cause explained rather than just the command.

Show every fix in this topic

Related topics

Subjects that keep coming up alongside this one, most overlap first.

Keep browsing

Raster & rasterio sits in Analysis. Every topic on the site is listed on the topics index.