Skip to content

Raster commands process a large raster in pieces instead of reading it whole #2865

Done

Description

@Mavrick-F

Commands that make a raster (Raster Functions, Indices, Classification, Change Detection, Process, Suitability, Viewshed, Deep Learning) and the geoprocessing tools read their whole input before they work, then build their whole output. Since #2772 and #2862, a large local tiled GeoTIFF is read at the finest level that fits memory. For the 83517 × 78739 mosaic in #2761, that's the 1:8 level, 10439 × 9842. An NDVI over it takes 5.9 s and peaks at 1.8 GB:

  • 1.23 GB of input
  • 0.41 GB of output
  • the output's GeoTIFF bytes

The full-resolution image doesn't fit at all.

Most of these work cell by cell or over a small neighbourhood: band math, remaps, thresholds, classification by known means, clip and resample. They could read the input a block of tiles at a time and write each block of output as it's made. Peak memory would then be a few blocks, and the full-resolution image would be within reach.

What it takes:

  • A windowed read in the GeoTIFF reader: the pixels of one area at one level. Clip by extent needs this alone too; it now reads the whole level and then clips.
  • A block-wise path for the per-cell commands, with output written block by block (to a tiled GeoTIFF on disk rather than embedded bytes once it's large).
  • Commands that need the whole raster stay as they are: k-means, viewshed, and statistics that need every value. They read the finest level that fits, and say so.

Related: #2761, #2772, #2862, #2431 (memory).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions