Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQLITE/GPKG: add a gdal_get_pixel_value() SQL function. #6877

Merged
merged 2 commits into from Dec 10, 2022

Conversation

rouault
Copy link
Member

@rouault rouault commented Dec 8, 2022

Applies to both SQL SQLite dialect and GPKG

The gdal_get_pixel_value() function (added in GDAL 3.7) can be used to extract the value of a pixel in a GDAL dataset. It requires the configuration option OGR_SQLITE_ALLOW_EXTERNAL_ACCESS to be set to YES (for security reasons).

It takes 5 arguments:

  • a string with the dataset name
  • a band number (numbering starting at 1)
  • a string being "georef" to indicate that subsequent values will be georeferenced coordinates, or "pixel" to indicate that subsequent values will be in column, line pixel space
  • georeferenced X value or column number
  • georeferenced Y value or line number

Example:

SELECT gdal_get_pixel_value('../gcore/data/byte.tif', 1, 'georef', 440720, 3751320)
SELECT gdal_get_pixel_value('../gcore/data/byte.tif', 1, 'pixel', 0, 0)

@rouault rouault added this to the 3.7.0 milestone Dec 8, 2022
@rouault rouault force-pushed the gdal_get_pixel_value branch 2 times, most recently from 60827f7 to a69ac6b Compare December 8, 2022 22:16
@rouault rouault changed the title OGR/GPKG: add a gdal_get_pixel_value() SQL function. SQLITE/GPKG: add a gdal_get_pixel_value() SQL function. Dec 8, 2022
Applies to both SQL SQLite dialect and GPKG

The ``gdal_get_pixel_value()`` function (added in GDAL 3.7) can be used to extract the value
of a pixel in a GDAL dataset. It requires the configuration option OGR_SQLITE_ALLOW_EXTERNAL_ACCESS
to be set to YES (for security reasons).

It takes 5 arguments:

* a string with the dataset name
* a band number (numbering starting at 1)
* a string being "georef" to indicate that subsequent values will be georeferenced
  coordinates, or "pixel" to indicate that subsequent values will be in column, line
  pixel space
* georeferenced X value or column number
* georeferenced Y value or line number

.. code-block::

    SELECT gdal_get_pixel_value('../gcore/data/byte.tif', 1, 'georef', 440720, 3751320)
    SELECT gdal_get_pixel_value('../gcore/data/byte.tif', 1, 'pixel', 0, 0)
@rouault
Copy link
Member Author

rouault commented Dec 8, 2022

build-windows-conda failure is unrelated to this PR and related to conda-forge/xz-feedstock#31

@rouault rouault merged commit b2f5982 into OSGeo:master Dec 10, 2022
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.

None yet

2 participants