Hi Glynn, Martin, Hamish and rest of GRASS mailing list Thanks for your feedback. Unfortunely, I was "analyzing" my problem in the wrong way... WHat I need is to: - Export raster values in an ASCII file written from left to right and bottom to top and each line only includes Raster value (not X neither Y). Is this possible in GRASS with a Python Script?
Also I will need to import raster values written in ASCII file written from left to right and bottom to top where each line is a single raster value without X and Y. Is there any easy-to-implement solution? Thanks Best regards and sorry for my previous mistake, Kim 2011/3/9 Glynn Clements <[email protected]> > > Martin Landa wrote: > > > > so just flipping all the rows in the file you can get now? > > > > > > don't know how to do that in python, but if unix shell powertools are > > > available: > > > r.out.ascii | tac > > > print os.linesep.join(reversed(grass.read_command('r.out.ascii', > > FWIW, both of these are sub-optimal. > > The Python approach reads everything into memory then generates a > reversed copy, so you need enough memory to hold two copies of the > output from r.out.ascii. > > When given a file, tac reads the input file backwards a block at a > time, so it only needs enough memory to hold a complete line, rounded > up to a whole number of blocks. > > However, it can't do this when reading from a pipe; it has to store > everything in memory. > > If you want to reverse a large file without storing everything in > memory, the simplest solution is e.g.: > > r.out.ascii ... > tmp.txt > tac tmp.txt > reversed.txt > rm tmp.txt > > If this was likely to be a common operation, r.out.ascii could easily > be modified to flip the row number passed to Rast_get_row(). However, > while that will be optimal for native GRASS rasters, it may be > sub-optimal (or even fail) for "linked" (r.external) rasters; many > raster formats have to be read top-to-bottom (I don't know how GDAL > handles out-of-order reads for such formats). > > -- > Glynn Clements <[email protected]> >
_______________________________________________ grass-user mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/grass-user
