Skip to content

Doc: Add pipeline examples of raster clipping#14661

Open
geographika wants to merge 3 commits into
OSGeo:masterfrom
geographika:mixed-pipeline
Open

Doc: Add pipeline examples of raster clipping#14661
geographika wants to merge 3 commits into
OSGeo:masterfrom
geographika:mixed-pipeline

Conversation

@geographika
Copy link
Copy Markdown
Collaborator

@geographika geographika commented May 26, 2026

Adds the following to the docs:

  • a new pipeline example showing a mixed raster/vector pipeline with nesting (following the fix provided in Failing mixed raster vector pipeline #14637). I added in a diagram, and the resulting output image to brighten up the docs (it could be removed, but is only 26KB): preview
  • also added 2 other examples of clipping a raster using vector features: preview
  • linked to all 3 from the cookbook: preview

The gdal_vector_pipeline.rst page was missing one of its final step options export-schema. There are a few other steps that are missing. I can add these in manually to the pipeline pages, but maybe we want to try and automate which tools are available in pipelines?

See "potential steps" sections at https://gdal.org/en/latest/programs/gdal_vector_pipeline.html and https://gdal.org/en/latest/programs/gdal_raster_pipeline.html (and also https://gdal.org/en/latest/programs/gdal_pipeline.html#gdal-pipeline). Thoughts @dbaston @rouault ?

Comment thread doc/source/programs/gdal_pipeline.rst Outdated
@dbaston
Copy link
Copy Markdown
Member

dbaston commented May 26, 2026

but maybe we want to try and automate which tools are available in pipelines?

I'd probably have gdal pipeline link to gdal vector pipeline and gdal raster pipeline for a list of the available steps, rather than duplicating them.

@geographika
Copy link
Copy Markdown
Collaborator Author

Maybe also show how the same operation could be done by reading the vector as the first step and piping it into raster clip.

@dbaston - is this possible? I think it has to use _PIPE_, but I can't get it to work (seems like vector clip is used?)
My attempt below:

gdal pipeline \
  ! read natural_earth_vector.gpkg --layer "ne_50m_admin_0_countries" \
  ! filter --where "ADMIN='Romania'" \
  ! buffer --distance=1 \
  ! clip --input "NE2_50M_SR_W.tif" --like _PIPE_ \
  ! write romania.png  --overwrite

ERROR 4: `NE2_50M_SR_W.tif' not recognized as being in a supported file format

@geographika
Copy link
Copy Markdown
Collaborator Author

but maybe we want to try and automate which tools are available in pipelines?

I'd probably have gdal pipeline link to gdal vector pipeline and gdal raster pipeline for a list of the available steps, rather than duplicating them.

The pipeline page only contains descriptions of steps common to both vector and raster. I guess the steps won't change often so it might be easiest to manually update them. Or maybe use the output of gdal vector pipeline --help and gdal raster pipeline --help (and gdal pipeline --help) although that might be too verbose.

@rouault
Copy link
Copy Markdown
Member

rouault commented May 26, 2026

is this possible? I think it has to use _PIPE_, but I can't get it to work (seems like vector clip is used?)

I'm looking at that. The pipeline building logic is confused here and wrongly selects the vector clip algorithm.

@rouault
Copy link
Copy Markdown
Member

rouault commented May 26, 2026

'm looking at that

addressed in #14663

rouault added a commit to rouault/gdal that referenced this pull request May 26, 2026
… clip --input raster_dataset --like _PIPE_ ! write output_raster'

Fixes OSGeo#14661 (comment)
rouault added a commit to rouault/gdal that referenced this pull request May 26, 2026
… clip --input raster_dataset --like _PIPE_ ! write output_raster'

Fixes OSGeo#14661 (comment)
@geographika
Copy link
Copy Markdown
Collaborator Author

I have added a buffer step, and also an equivalent example using __PIPE__ as suggested by @dbaston.
I need to check the __PIPE__ example works with the latest GDAL build and the fix from @rouault in #14663, and will then mark as ready to review.

@geographika geographika marked this pull request as draft May 27, 2026 08:14
rouault added a commit to rouault/gdal that referenced this pull request May 27, 2026
… clip --input raster_dataset --like _PIPE_ ! write output_raster'

Fixes OSGeo#14661 (comment)
rouault added a commit to rouault/gdal that referenced this pull request May 27, 2026
… clip --input raster_dataset --like _PIPE_ ! write output_raster'

Fixes OSGeo#14661 (comment)
rouault added a commit to rouault/gdal that referenced this pull request May 27, 2026
… clip --input raster_dataset --like _PIPE_ ! write output_raster'

Fixes OSGeo#14661 (comment)
rouault added a commit to rouault/gdal that referenced this pull request May 27, 2026
… clip --input raster_dataset --like _PIPE_ ! write output_raster'

Fixes OSGeo#14661 (comment)
@geographika
Copy link
Copy Markdown
Collaborator Author

@rouault - did you mean to close this as well as #14663 ?

@rouault
Copy link
Copy Markdown
Member

rouault commented May 28, 2026

did you mean to close this as well as #14663 ?

ah sorry, my commit message only mentioned fixing this particular comment #14661 (comment), but github decided to close this whole PR. Re-opening it...

@rouault rouault reopened this May 28, 2026
@geographika
Copy link
Copy Markdown
Collaborator Author

__PIPE__ example tested on latest Windows / Conda and Linux / Docker - all work fine with #14663.

PR ready from my side.

@geographika geographika marked this pull request as ready for review May 29, 2026 06:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants