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

[API] GDALRasterBand: add convenience ReadRaster() methods #10475

Merged
merged 3 commits into from
Aug 15, 2024

Conversation

rouault
Copy link
Member

@rouault rouault commented Jul 23, 2024

(on top of bugfix #10468)

/** Read a region of image data for this band.
 *
 * This is a slightly more convenient alternative to GDALRasterBand::RasterIO()
 * for common use cases, like reading a whole band.
 * It infers the GDAL data type of the buffer from the C/C++ type of the buffer.
 * This template is instantiated for the following types: [u?]int[8|16|32|64]_t,
 * float, double, std::complex<float|double>.
 *
 * To read a whole raster (assuming it fits into memory), as a vector of double:
 *
\code
 std::vector<double> myArray;
 if (poBand->ReadRaster(myArray) == CE_None)
 {
    // do something
 }
\endcode
 *
 * To read 128x128 pixels starting at (col=12, line=24) as a vector of double:
 *
\code{.cpp}
 std::vector<double> myArray;
 if (poBand->ReadRaster(myArray, 12, 24, 128, 128) == CE_None)
 {
    // do something
 }
\endcode
 *

@rouault rouault added this to the 3.10.0 milestone Jul 23, 2024
@rouault rouault changed the title GDALRasterBand: add convenience ReadPixels() methods GDALRasterBand: add convenience ReadRaster() methods Jul 23, 2024
@rouault rouault changed the title GDALRasterBand: add convenience ReadRaster() methods [API] GDALRasterBand: add convenience ReadRaster() methods Jul 23, 2024
@rouault rouault force-pushed the ReadPixels branch 3 times, most recently from 53d1033 to a4c802a Compare July 23, 2024 16:57
@coveralls
Copy link
Collaborator

coveralls commented Jul 23, 2024

Coverage Status

coverage: 69.31% (+0.02%) from 69.295%
when pulling a3f9d6d on rouault:ReadPixels
into 3122857 on OSGeo:master.

```cpp
/** Read a region of image data for this band.
 *
 * This is a slightly more convenient alternative to GDALRasterBand::RasterIO()
 * for common use cases, like reading a whole band.
 * It infers the GDAL data type of the buffer from the C/C++ type of the buffer.
 * This template is instantiated for the following types: [u?]int[8|16|32|64]_t,
 * float, double, std::complex<float|double>.
 *
 * To read a whole raster (assuming it fits into memory), as a vector of double:
 *
\code
 std::vector<double> myArray;
 if (poBand->ReadRaster(myArray) == CE_None)
 {
    // do something
 }
\endcode
 *
 * To read 128x128 pixels starting at (col=12, line=24) as a vector of double:
 *
\code{.cpp}
 std::vector<double> myArray;
 if (poBand->ReadRaster(myArray, 12, 24, 128, 128) == CE_None)
 {
    // do something
 }
\endcode
 *
```
@mdsumner
Copy link
Contributor

Nice, much appreciated

@rouault rouault merged commit 26f4672 into OSGeo:master Aug 15, 2024
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants