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

Alessandro Frigeri alessandro.frigeri at gmail.com
Sun Sep 24 16:43:04 EDT 2006


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


2006/9/24, Markus Neteler <neteler at itc.it>:
> Hi,
>
> I have added the Vector API to the GRASS-SWIG-Python interface.
> Now w have to figure out how to use it :-)
>
>
> I am struggling there (don't know much about Python yet):
>
> #### snip #####
> import python_grass6 as g6lib
>
> input = 'soils'
> mapset = 'PERMANENT'
>
> g6lib.G_gisinit('')
> g6lib.Vect_set_open_level (2)
>
> ## how to set Map?
> g6lib.Vect_open_old_head (Map, input, mapset)
> print 'Vect is 3D:'
> print g6lib.Vect_is_3d (Map)
>
> g6lib.Vect_open_old(input, mapset)
> print 'Vect DB links'
> print g6lib.Vect_get_num_dblinks(Map)
>
>
> g6lib.Vect_close(Map)
>
> #### snap #####
>
>
> Markus
>
> _______________________________________________
> grass-dev mailing list
> grass-dev at grass.itc.it
> http://grass.itc.it/mailman/listinfo/grass-dev
>


-- 
Alessandro Frigeri, PhD
-------------- next part --------------
A non-text attachment was scrubbed...
Name: python_grass6.i.patch
Type: text/x-patch
Size: 448 bytes
Desc: not available
Url : http://lists.osgeo.org/pipermail/grass-dev/attachments/20060924/3a8348a3/python_grass6.i.bin


More information about the grass-dev mailing list