[GRASS-dev] GRASS-Python Interface: Vector API added

Markus Neteler neteler at itc.it
Mon Sep 25 04:10:21 EDT 2006


Thanks, Alessandro.

I have submitted the patches and added 
rasteraccess.py and
vectoraccess.py
as examples in CVS. The latter, slightly extended, now reports:

python vectoraccess.py
Vect is 3D:  0
Vect DB links:  1
Map Scale:  1: 24000
Number of lines: 2876


Markus


On Sun, Sep 24, 2006 at 10:43:04PM +0200, Alessandro Frigeri wrote:
> Hello,
> 
> To get the Map_info structure we have to wrap also dig_structs.h (so
> we must add dig_struct.i to the interfaces dir by adding a line in the
> Makefile there).
> 
> I also added some lines to the python-swig interface file to provide
> access to int/float/double arrays.  Find attached  the patch to
> python_grass.i and below the updates to the script proposed by Markus
> that now works with the new Map_info object.
> 
> #!/usr/bin/python
> import python_grass6 as g6lib
> 
> input = 'soils'
> mapset = 'PERMANENT'
> 
> g6lib.G_gisinit('')
> g6lib.Vect_set_open_level (2)
> 
> map = g6lib.Map_info()
> 
> g6lib.Vect_open_old_head (map, input, mapset)
> print 'Vect is 3D: ', g6lib.Vect_is_3d (map)
> 
> g6lib.Vect_open_old(map, input, mapset)
> print 'Vect DB links: ', g6lib.Vect_get_num_dblinks(map)
> 
> g6lib.Vect_close(map)
> ## end of the python script
> 
> Regards,
> 
> Alessandro
> 
> -- 
> Alessandro Frigeri, PhD




More information about the grass-dev mailing list