[GRASS5] libgrass++

hello, i try to read a raster (1885 by 1382) with GetValue(..) of
GRASSRaster.h of Grass++ library. it would take more than 30 minutes just to
read one raster! but unfortunately after about 500 rows i get a core dump and
the display has only scaring signs till i booted again.

obviously GetValue() does a lot of Open() and Close() what might make it slow.
also i have to call this method for each pixel instead read data of required
window at once.

what shall i do to speed up this method and is there also a method to write a
grass raster after treating the data?

thank you. sabine

main():
  int n = 5227350;
  int s = 5180225;
  int w = 179000;
  int e = 213550;
  int xres = 25;
  int yres = 25;
  int cols = (int)(e - w) / xres;
  int rows = (int)(n - s) / yres;

  Window::setStandard(cols, rows, w, n, xres, yres);
   
  string filename = "dem";
  Raster raster = Raster(filename);

Raster::Raster(string filename)
{
..
  char* gisdbase = "/home/sabine/diss/grassdata";
  char* location = "oetztal";
  //char* map = filename;

  char* map = "dem";
  GRASSRaster grassraster(gisdbase, location, map);
  
grassraster.SetWindow(Window::getN(),Window::getS(),Window::getE(),Window::getW(),Window::getYSize(),Window::getXSize());
  grassraster.Open();

  for (int y = 0; y < data.size(); y++)
  {
    for (int x = 0; x < data[y].size(); x++)
    {
      double xx = Window::getW() + x *
Window::getXResolution();
      double yy = Window::getN() - y *
Window::getYResolution();
      grassraster.GetValue(xx, yy, &data[y]);
       
    }
    cout << y << ". row of " << Window::getYSize() << "\n";
  }
  grassraster.Dump();
  grassraster.Close();
}

libgrass++ was written for first, version of GRASS support in QGIS.
It was later partialy used in GRASS-QGIS provider/plugins and
partialy substituted by GDAL, so it is not developed any more.

You have to modify GRASSRaster::GetRowRGB to some GRASSRaster::GetRow.

GetValue() was realy for one or few points like d.what.rast.

Radim

On Thursday 08 July 2004 16:32, Sabine Grabner wrote:

hello, i try to read a raster (1885 by 1382) with GetValue(..) of
GRASSRaster.h of Grass++ library. it would take more than 30 minutes just
to read one raster! but unfortunately after about 500 rows i get a core
dump and the display has only scaring signs till i booted again.

obviously GetValue() does a lot of Open() and Close() what might make it
slow. also i have to call this method for each pixel instead read data of
required window at once.

what shall i do to speed up this method and is there also a method to write
a grass raster after treating the data?

thank you. sabine

main():
  int n = 5227350;
  int s = 5180225;
  int w = 179000;
  int e = 213550;
  int xres = 25;
  int yres = 25;
  int cols = (int)(e - w) / xres;
  int rows = (int)(n - s) / yres;

  Window::setStandard(cols, rows, w, n, xres, yres);

  string filename = "dem";
  Raster raster = Raster(filename);

Raster::Raster(string filename)
{
..
  char* gisdbase = "/home/sabine/diss/grassdata";
  char* location = "oetztal";
  //char* map = filename;

  char* map = "dem";
  GRASSRaster grassraster(gisdbase, location, map);

grassraster.SetWindow(Window::getN(),Window::getS(),Window::getE(),Window::
getW(),Window::getYSize(),Window::getXSize()); grassraster.Open();

  for (int y = 0; y < data.size(); y++)
  {
    for (int x = 0; x < data[y].size(); x++)
    {
      double xx = Window::getW() + x *
Window::getXResolution();
      double yy = Window::getN() - y *
Window::getYResolution();
      grassraster.GetValue(xx, yy, &data[y]);

    }
    cout << y << ". row of " << Window::getYSize() << "\n";
  }
  grassraster.Dump();
  grassraster.Close();
}

_______________________________________________
grass5 mailing list
grass5@grass.itc.it
http://grass.itc.it/mailman/listinfo/grass5