rasteraccess.py 549 B

1234567891011121314151617181920212223242526272829
  1. #!/usr/bin/python
  2. # run within GRASS Spearfish session
  3. import os, sys
  4. import python_grass7 as g7lib
  5. if not os.environ.has_key("GISBASE"):
  6. print "You must be in GRASS GIS to run this program."
  7. sys.exit(1)
  8. input = 'elevation.dem'
  9. mapset = 'PERMANENT'
  10. g7lib.G_gisinit('')
  11. infd = g7lib.G_open_cell_old(input, mapset)
  12. cell = g7lib.G_allocate_cell_buf()
  13. rown=0
  14. while 1:
  15. myrow = g7lib.G_get_map_row_nomask(infd, cell, rown)
  16. print rown,myrow[0:10]
  17. rown = rown+1
  18. if rown==476:break
  19. g7lib.G_close_cell(infd)
  20. g7lib.G_free(cell)