Tried fixing gdal bullshit in steepnes method

This commit is contained in:
Trygve 2024-05-07 19:38:34 +02:00
parent c47565eabb
commit 97c52ecef3
2 changed files with 7 additions and 15 deletions

View File

@ -33,6 +33,7 @@ HeightMap::HeightMap(const char* filepath)
//https://gdal.org/api/gdaldataset_cpp.html#_CPPv4N11GDALDataset15GetGeoTransformEPd
this->geotransform = (double *) CPLMalloc(sizeof(double)*6);
this->reference_system = *(file->GetSpatialRef());
this->filepath = filepath;
file->GetGeoTransform(this->geotransform);
@ -175,11 +176,13 @@ void HeightMap::calculate_steepness()
steepness[i] = max - min;
}
}
GDALAllRegister();
GDALDataset *original_file = (GDALDataset *) GDALOpen( filepath, GA_ReadOnly );
const char * filename = "steepness.tif";
auto driver = GetGDALDriverManager()->GetDriverByName("GeoRaster");
GDALDataset *file;
file = driver->Create("steepness.tif", this->width, this->height, 1, GDT_Float32, NULL);
GDALRegister_GTiff();
file = driver->CreateCopy("steepness.tif", original_file, FALSE, NULL, NULL, NULL);
file->AddBand(GDT_Float32, NULL);
GDALRasterBand *band = file->GetRasterBand(0);
@ -188,14 +191,3 @@ void HeightMap::calculate_steepness()
0, 0 );
GDALClose(file);
}
//namespace plt = matplotlibcpp;
//matplotlibcpp::plot(x, y);
//plt::loglog(x, y);
/*
int main() {
}*/

View File

@ -16,8 +16,8 @@ class HeightMap
float min; //!< Minimum value in image
float max; //!< Maximum value in image
OGRSpatialReference reference_system;
HeightMap(const char* filepath);
const char* filepath;
float get_pixel(int x,int y);
void blur(float standard_deviation);
void statistics();