Skip to content

Commit

Permalink
Recommit bugfix #13
Browse files Browse the repository at this point in the history
loading raster files with decimal digits for cellsize caused R crashing (caused by terra R package)
reading it now in as double and then transform it to integer
  • Loading branch information
JetteReeg committed Jul 4, 2024
1 parent 7aefe7a commit 4a3854f
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions Landscape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,12 @@ int InitDist::readDistribution(string distfile) {
#endif
if (!dfile.is_open()) return 21;

// read landscape data from header records of distribution file
// NB headers of all files have already been compared
dfile >> header >> ncols >> header >> nrows >> header >> minEast >> header >> minNorth
>> header >> resol >> header >> nodata;
// read landscape data from header records of distribution file
// NB headers of all files have already been compared
double tmpresol;
dfile >> header >> ncols >> header >> nrows >> header >> minEast >> header >> minNorth
>> header >> tmpresol >> header >> nodata;
resol = (int) tmpresol;
#if RS_RCPP
if (!dfile.good()) {
// corrupt file stream
Expand Down Expand Up @@ -1796,10 +1798,12 @@ int Landscape::readLandscape(int fileNum, string habfile, string pchfile, string
}
}

// read landscape data from header records of habitat file
// NB headers of all files have already been compared
hfile >> header >> ncols >> header >> nrows >> header >> minEast >> header >> minNorth
>> header >> resol >> header >> habnodata;
// read landscape data from header records of habitat file
// NB headers of all files have already been compared
double tmpresol;
hfile >> header >> ncols >> header >> nrows >> header >> minEast >> header >> minNorth
>> header >> tmpresol >> header >> habnodata;
resol = (int) tmpresol;

#if RS_RCPP
if (!hfile.good()) {
Expand Down

0 comments on commit 4a3854f

Please sign in to comment.