[GRASS-SVN] r30631 - in grass/trunk/swig/python: . examples
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Mar 19 06:07:49 EDT 2008
Author: hamish
Date: 2008-03-19 06:07:48 -0400 (Wed, 19 Mar 2008)
New Revision: 30631
Added:
grass/trunk/swig/python/examples/rasteraccess.py
grass/trunk/swig/python/examples/vectoraccess.py
Removed:
grass/trunk/swig/python/rasteraccess.py
grass/trunk/swig/python/vectoraccess.py
Log:
move examples into own dir
Copied: grass/trunk/swig/python/examples/rasteraccess.py (from rev 30630, grass/trunk/swig/python/rasteraccess.py)
===================================================================
--- grass/trunk/swig/python/examples/rasteraccess.py (rev 0)
+++ grass/trunk/swig/python/examples/rasteraccess.py 2008-03-19 10:07:48 UTC (rev 30631)
@@ -0,0 +1,28 @@
+#!/usr/bin/python
+
+# run within GRASS Spearfish session
+
+import os, sys
+import python_grass6 as g6lib
+
+if not os.environ.has_key("GISBASE"):
+ print "You must be in GRASS GIS to run this program."
+ sys.exit(1)
+
+input = 'elevation.dem'
+mapset = 'PERMANENT'
+
+g6lib.G_gisinit('')
+infd = g6lib.G_open_cell_old(input, mapset)
+
+cell = g6lib.G_allocate_cell_buf()
+
+rown=0
+while 1:
+ myrow = g6lib.G_get_map_row_nomask(infd, cell, rown)
+ print rown,myrow[0:10]
+ rown = rown+1
+ if rown==476:break
+
+g6lib.G_close_cell(infd)
+g6lib.G_free(cell)
Copied: grass/trunk/swig/python/examples/vectoraccess.py (from rev 30630, grass/trunk/swig/python/vectoraccess.py)
===================================================================
--- grass/trunk/swig/python/examples/vectoraccess.py (rev 0)
+++ grass/trunk/swig/python/examples/vectoraccess.py 2008-03-19 10:07:48 UTC (rev 30631)
@@ -0,0 +1,47 @@
+#!/usr/bin/python
+
+# run within GRASS Spearfish session
+
+import os, sys
+import python_grass6 as g6lib
+
+if not os.environ.has_key("GISBASE"):
+ print "You must be in GRASS GIS to run this program."
+ sys.exit(1)
+
+if len(sys.argv)==2:
+ input = sys.argv[1]
+else:
+ input = raw_input("Vector Map Name? ")
+
+mapset = 'PERMANENT'
+
+# initialize
+g6lib.G_gisinit('')
+
+# define map structure
+map = g6lib.Map_info()
+
+# define open level (level 2: topology)
+g6lib.Vect_set_open_level (2)
+
+# open existing map
+g6lib.Vect_open_old(map, input, mapset)
+
+# query
+print 'Vect map: ', input
+print 'Vect is 3D: ', g6lib.Vect_is_3d (map)
+print 'Vect DB links: ', g6lib.Vect_get_num_dblinks(map)
+print 'Map Scale: 1:', g6lib.Vect_get_scale(map)
+# misleading:
+# print 'Number of lines:', g6lib.Vect_get_num_lines(map)
+print 'Number of points: ', g6lib.Vect_get_num_primitives(map,g6lib.GV_POINT)
+# confusing:
+#print 'Number of lines: ', g6lib.Vect_get_num_primitives(map,g6lib.GV_LINE)
+#print 'Number of areas:', g6lib.Vect_get_num_primitives(map,g6lib.GV_AREA)
+print 'Number of areas:', g6lib.Vect_get_num_areas(map)
+
+# close map
+g6lib.Vect_close(map)
+## end of the python script
+
Deleted: grass/trunk/swig/python/rasteraccess.py
===================================================================
--- grass/trunk/swig/python/rasteraccess.py 2008-03-19 07:13:13 UTC (rev 30630)
+++ grass/trunk/swig/python/rasteraccess.py 2008-03-19 10:07:48 UTC (rev 30631)
@@ -1,28 +0,0 @@
-#!/usr/bin/python
-
-# run within GRASS Spearfish session
-
-import os, sys
-import python_grass6 as g6lib
-
-if not os.environ.has_key("GISBASE"):
- print "You must be in GRASS GIS to run this program."
- sys.exit(1)
-
-input = 'elevation.dem'
-mapset = 'PERMANENT'
-
-g6lib.G_gisinit('')
-infd = g6lib.G_open_cell_old(input, mapset)
-
-cell = g6lib.G_allocate_cell_buf()
-
-rown=0
-while 1:
- myrow = g6lib.G_get_map_row_nomask(infd, cell, rown)
- print rown,myrow[0:10]
- rown = rown+1
- if rown==476:break
-
-g6lib.G_close_cell(infd)
-g6lib.G_free(cell)
Deleted: grass/trunk/swig/python/vectoraccess.py
===================================================================
--- grass/trunk/swig/python/vectoraccess.py 2008-03-19 07:13:13 UTC (rev 30630)
+++ grass/trunk/swig/python/vectoraccess.py 2008-03-19 10:07:48 UTC (rev 30631)
@@ -1,47 +0,0 @@
-#!/usr/bin/python
-
-# run within GRASS Spearfish session
-
-import os, sys
-import python_grass6 as g6lib
-
-if not os.environ.has_key("GISBASE"):
- print "You must be in GRASS GIS to run this program."
- sys.exit(1)
-
-if len(sys.argv)==2:
- input = sys.argv[1]
-else:
- input = raw_input("Vector Map Name? ")
-
-mapset = 'PERMANENT'
-
-# initialize
-g6lib.G_gisinit('')
-
-# define map structure
-map = g6lib.Map_info()
-
-# define open level (level 2: topology)
-g6lib.Vect_set_open_level (2)
-
-# open existing map
-g6lib.Vect_open_old(map, input, mapset)
-
-# query
-print 'Vect map: ', input
-print 'Vect is 3D: ', g6lib.Vect_is_3d (map)
-print 'Vect DB links: ', g6lib.Vect_get_num_dblinks(map)
-print 'Map Scale: 1:', g6lib.Vect_get_scale(map)
-# misleading:
-# print 'Number of lines:', g6lib.Vect_get_num_lines(map)
-print 'Number of points: ', g6lib.Vect_get_num_primitives(map,g6lib.GV_POINT)
-# confusing:
-#print 'Number of lines: ', g6lib.Vect_get_num_primitives(map,g6lib.GV_LINE)
-#print 'Number of areas:', g6lib.Vect_get_num_primitives(map,g6lib.GV_AREA)
-print 'Number of areas:', g6lib.Vect_get_num_areas(map)
-
-# close map
-g6lib.Vect_close(map)
-## end of the python script
-
More information about the grass-commit
mailing list