[GRASS5] libgrass++

Sabine Grabner csab7771 at uibk.ac.at
Thu Jul 8 10:32:57 EDT 2004


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][x]); 
			 
		} 
		cout << y << ". row of " << Window::getYSize() << "\n"; 
	} 
	grassraster.Dump(); 
	grassraster.Close(); 
} 




More information about the grass-dev mailing list