[GRASS-SVN] r35524 - grass/trunk/swig/python/examples
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Jan 20 16:18:01 EST 2009
Author: neteler
Date: 2009-01-20 16:18:01 -0500 (Tue, 20 Jan 2009)
New Revision: 35524
Modified:
grass/trunk/swig/python/examples/rasteraccess.py
Log:
updated but still fails
Modified: grass/trunk/swig/python/examples/rasteraccess.py
===================================================================
--- grass/trunk/swig/python/examples/rasteraccess.py 2009-01-20 21:10:55 UTC (rev 35523)
+++ grass/trunk/swig/python/examples/rasteraccess.py 2009-01-20 21:18:01 UTC (rev 35524)
@@ -3,26 +3,34 @@
# run within GRASS Spearfish session
import os, sys
-import python_grass7 as g7lib
+import swig.grass as grasslib
+import swig.raster as grassrast
if not os.environ.has_key("GISBASE"):
print "You must be in GRASS GIS to run this program."
sys.exit(1)
-input = 'elevation.dem'
+if len(sys.argv)==2:
+ input = sys.argv[1]
+else:
+ input = raw_input("Raster Map Name? ")
mapset = 'PERMANENT'
-g7lib.G_gisinit('')
-infd = g7lib.G_open_cell_old(input, mapset)
+# initialize
+grasslib.G_gisinit('')
-cell = g7lib.G_allocate_cell_buf()
+# determine the inputmap type (CELL/FCELL/DCELL) */
+data_type = grasslib.G_raster_map_type(input, mapset)
+infd = grasslib.G_open_cell_old(input, mapset)
+inrast = grasslib.G_allocate_raster_buf(data_type)
+
rown=0
while 1:
- myrow = g7lib.G_get_map_row_nomask(infd, cell, rown)
+ myrow = grasslib.G_get_raster_row(infd, inrast, rown, data_type)
print rown,myrow[0:10]
rown = rown+1
if rown==476:break
-g7lib.G_close_cell(infd)
-g7lib.G_free(cell)
+grasslib.G_close_cell(inrast)
+grasslib.G_free(cell)
More information about the grass-commit
mailing list