Skip to content

Commit

Permalink
c
Browse files Browse the repository at this point in the history
  • Loading branch information
rhijmans committed Dec 19, 2024
1 parent f6f5554 commit 545fb19
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
29 changes: 29 additions & 0 deletions src/gdal_algs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,35 @@
#include <sstream>


/*
GDAL 3.10
std::vector<double> SpatRaster::extract_interpolate(std::vector<double> x, std::vector<double> y, std::string algo) {
GDALRIOResampleAlg eInterpolation = GRIORA_Bilinear ;
size_t n = x.size();
std::vector<double> out(n, NAN);
double value;
GDALDatasetH hDs;
SpatOptions opt;
if (!open_gdal(hDs, 0, false, opt)) {
setError("cannot open dataset");
return(out);
}
GDALRasterBandH poBand = GDALGetRasterBand(hDs, 1);
for (size_t i=0; i<n; i++) {
if (GDALInterpolateAtPoint(pbBand, x[i], y[1], eInterpolation, &value) == CE_None) {
out[i] = value;
}
}
GDALClose( hDs );
return out;
}
*/


SpatGeom getPolygonsGeom2(OGRGeometry *poGeometry) {
SpatGeom g(polygons);
OGRPoint ogrPt;
Expand Down
2 changes: 2 additions & 0 deletions src/spatRaster.h
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,8 @@ class SpatRaster {
std::vector<std::vector<std::vector<double>>> extractVector(SpatVector v, bool touches, bool small, std::string method, bool cells, bool xy, bool weights, bool exact, SpatOptions &opt);
std::vector<double> extractVectorFlat(SpatVector v, std::vector<std::string> funs, bool narm, bool touches, bool small, std::string method, bool cells, bool xy, bool weights, bool exact, SpatOptions &opt);

// std::vector<double> extract_interpolate(std::vector<double> x, std::vector<double> y, std::string algo);


std::vector<double> vectCells(SpatVector v, bool touches, bool small, std::string method, bool weights, bool exact, SpatOptions &opt);
std::vector<double> extCells(SpatExtent ext);
Expand Down
3 changes: 1 addition & 2 deletions src/write_gdal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1139,7 +1139,6 @@ bool SpatRaster::update_meta(bool names, bool crs, bool ext, SpatOptions &opt) {
return false;
}
GDALDatasetH hDS;
GDALRasterBandH poBand;
size_t n=0;
for (size_t i=0; i<nsrc(); i++) {
if (source[i].memory) continue;
Expand All @@ -1150,7 +1149,7 @@ bool SpatRaster::update_meta(bool names, bool crs, bool ext, SpatOptions &opt) {
}
if (names) {
for (size_t b=0; b < source[i].nlyr; b++) {
poBand = GDALGetRasterBand(hDS, b+1);
GDALRasterBandH poBand = GDALGetRasterBand(hDS, b+1);
if (GDALGetRasterAccess(poBand) == GA_Update) {
GDALSetDescription(poBand, source[i].names[b].c_str());
}
Expand Down

0 comments on commit 545fb19

Please sign in to comment.