Skip to content

[Feature]: Clip Raster and Mosaic Rasters work without the Imagery extension, beside Project Raster and Polygons to Raster #2823

Done

Description

@elpidioassinaturas

Before you start

  • I searched the existing issues and the roadmap and did not find a duplicate request.

What problem does this solve?

Clipping a raster by a polygon layer (raster.process clip) and merging raster tiles (raster.mosaic) belong to the Imagery extension (#1764), which is off by default in the desktop and web apps. With it off, the app has no command of its own left that clips a raster by a polygon or merges tiles of different extents, and both are refused:

raster.process: raster.process is part of the Imagery extension, which is off; turn it on in Plugins › Extensions (extension.enable)
raster.mosaic: raster.mosaic is part of the Imagery extension, which is off; turn it on in Plugins › Extensions (extension.enable)

The two are general raster steps, for elevation, soil, rainfall or land cover as much as for imagery. #1764 left the steps that go with them outside the extension: Project Raster and Polygons to Raster (#821) and the raster functions stay on, under Analyze › Raster. So with Imagery off, RustGIS can put a raster on a grid and burn polygons into that grid, but can't cut the raster by the same polygons.

A plugin feels it most:

  • It can't turn the extension on for its user (extension.enable is Reserved), and it can't count on the user having done so.
  • Its author doesn't notice, because a CLI or Python session starts with every extension on. BrasilData, which clips almost every raster it adds to the user's work area, passed its CLI tests; in an app with Imagery off, a clip of the state of Minas Gerais (4800 × 4019 cells) then took 95 s through GeoLibre, and failed without it.

Without Imagery, two ways are left:

  • GeoLibre's clip_raster_to_polygon, if the user has GeoLibre installed.
  • A chain of three commands: raster.rasterize of the polygons on the raster's grid, cube.reduce of the raster and the mask with first and minValid 1, then raster.function bandMath.

I measured them in RustGIS 0.8.0 (rustgis-cli, Windows 11) on a made-up raster of 4800 × 4019 cells and a polygon of 4,192 vertices. The times include starting the CLI and opening both layers (0.8 s on their own):

Way Time Result
raster.process clip, exported 0.9 s trimmed to 4596 × 3777, the layer's no-data kept
The three commands, exported 1.3–1.4 s whole 4800 × 4019, no-data −3.4e38; same 11,280,236 cells with data, same values
geolibre:clip_raster_to_polygon, not exported 157 s one run, with light work beside it; cells not compared

The chain also turns an 8-bit raster into Float32 (the clip keeps it 8-bit), handles one band at a time, and stops at what cube.reduce writes (cells × outputs): 32 million cells for one output on the desktop and 8 million in the web app.

Proposed solution

Take raster.process and raster.mosaic off the Imagery extension's list, as raster.project and raster.rasterize already are, so they run whether or not it is on. They keep their ids, parameters and results.

  • Engine: the two ids leave extensions::IMAGERY.commands, and their locations become Analyze › Raster.
  • UI: process leaves analysispane::section_extension, so its Workflows section always shows. Its Process button moves from Imagery › Imagery Tools to the Raster group of the Analyze tab, after Function Editor. Mosaic Rasters has no button today and gets none here.
  • Docs: the Analyze and Extensions rows of the user guide, and the places in analysis.md.
  • Tests: with Imagery off, raster.process (clip by a polygon, and resample) and raster.mosaic run, while raster.classify and the other Imagery commands are still refused; the Workflows pane shows Process.

Choices in this proposal

  • Both commands whole, not only the polygon clip. The gate goes by command id. raster.process is clip and resample, and neither is about imagery. A separate raster.clip would leave two commands for one job.
  • The other 20 commands stay in Imagery: ortho and reality mapping, georeferencing, image analysis and classification, deep learning, indices, the Pixel Editor, mensuration and hosted imagery.
  • The default stays off, so the Imagery tab stays hidden as now. Only one small button is added to Analyze.
  • The button moves instead of being in two places, so the Imagery Tools group keeps Indices and Pixel Editor.

Any of these can change if you prefer another way.

Estimated scope

Small: a minor tweak, small UI change, or text adjustment

Alternatives considered

  • Asking the user to turn Imagery on. It works, but adds a tab and 22 commands for one clip.
  • A plugin declaring that it needs an extension. More general, but it still turns on a whole extension for a basic step, and people without a plugin gain nothing.
  • The three-command chain above. It is what BrasilData will do for 0.8.0 and earlier.

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