Skip to content

Conversation

@rouault
Copy link
Member

@rouault rouault commented Jan 31, 2026

@rouault rouault added this to the 3.13.0 milestone Jan 31, 2026
@rouault rouault added enhancement funded through GSP Work funded through the GDAL Sponsorship Program gdal_cli Anything related to the new 3.11 "gdal" CLI frontend labels Jan 31, 2026
@rouault rouault force-pushed the pixel_info_input_output_vector_dataset branch 3 times, most recently from 4dce49c to 529e04b Compare January 31, 2026 02:21
@rouault rouault changed the title gdal raster pixel-info: add --coordinate-dataset and --output vector datasets gdal raster pixel-info: add --coordinate-dataset and --output vector arguments Jan 31, 2026
@rouault rouault changed the title gdal raster pixel-info: add --coordinate-dataset and --output vector arguments gdal raster pixel-info: add --coordinate-dataset and --output arguments Jan 31, 2026
@rouault rouault force-pushed the pixel_info_input_output_vector_dataset branch from 529e04b to 28c9ab3 Compare January 31, 2026 02:28
@coveralls
Copy link
Collaborator

coveralls commented Jan 31, 2026

Coverage Status

coverage: 71.674% (+0.001%) from 71.673%
when pulling 159997c on rouault:pixel_info_input_output_vector_dataset
into 13d08a3 on OSGeo:master.

Otherwise, coordinates are assumed to be in the CRS raster dataset if it has
a CRS.

Otherwise, coordinates are assumed to be expressed in the column,line raster space.
Copy link
Collaborator

@jratike80 jratike80 Jan 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if the raster has a CRS but user wants to get pixel values from a bunch of pixels as column,line pairs? I think that option like --position-crs=none would work for that use case, but is it supported? Or does the existing --position-crs pixel https://gdal.org/en/stable/programs/gdal_raster_pixel_info.html#cmdoption-position-crs work also with a dataset input?
I see that CRS values "null" or "none" are supported in https://gdal.org/en/stable/programs/gdal_raster_edit.html#cmdoption-crs, but can they be used in other utilities?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if the raster has a CRS but user wants to get pixel values from a bunch of pixels as column,line pairs?

specify --position-crs=pixel. I've added a unit test for that scenario

@geographika
Copy link
Collaborator

@rouault - great work!

One question, in the example:

gdal raster pixel-info --coordinate-dataset input.gpkg --input byte.tif --output output.gpkg

Does output.gpkg contain all the fields of features in input.gpkg? Being able to link raster values (e.g. DEM values to point locations) is an important use case (apologies I've not had a chance to build / test this PR).

For future reference, this new feature replaces a more convulted way of applying values from a raster to vector features:

export OGR_SQLITE_ALLOW_EXTERNAL_ACCESS="YES"
gdal vector sql points.gpkg \
    points-dem.gpkg \
    --sql "SELECT *, gdal_get_pixel_value('./dem.tif', 1, 'georef', ST_X(geometry), ST_Y(geometry)) as pixel FROM points" \
    --dialect SQLITE \
    --overwrite

@rouault rouault force-pushed the pixel_info_input_output_vector_dataset branch from 28c9ab3 to 159997c Compare January 31, 2026 13:46
@rouault
Copy link
Member Author

rouault commented Jan 31, 2026

Does output.gpkg contain all the fields of features in input.gpkg?

yes it does. Documentation updated to mention that

@rouault rouault force-pushed the pixel_info_input_output_vector_dataset branch 4 times, most recently from eec7949 to 8ce4dd8 Compare January 31, 2026 17:05
@rouault rouault force-pushed the pixel_info_input_output_vector_dataset branch from 8ce4dd8 to f6ad97d Compare January 31, 2026 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement funded through GSP Work funded through the GDAL Sponsorship Program gdal_cli Anything related to the new 3.11 "gdal" CLI frontend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants