Hello,
Is it possible in pygrass to append a new point to a map of points (same for other features) ? Or do I have to get all the features of a map, and the new feature, and then write all features to a new map ?
Moritz
Hello,
Is it possible in pygrass to append a new point to a map of points (same for other features) ? Or do I have to get all the features of a map, and the new feature, and then write all features to a new map ?
Moritz
Soory for the delay,
On Fri, Jan 30, 2015 at 3:52 PM, Moritz Lennert
<mlennert@club.worldonline.be> wrote:
Is it possible in pygrass to append a new point to a map of points (same for
other features) ? Or do I have to get all the features of a map, and the new
feature, and then write all features to a new map ?
Yes, here an example, write a new map:
{{{
from grass.pygrass.vector.geometry import Point
from grass.pygrass.vector import VectorTopo
with VectorTopo('mypoits', mode='w') as my:
... my.write(Point(0, 10))
... my.write(Point(5, 15))
...
}}}
read an existing map:
{{{
with VectorTopo('mypoits', mode='r') as my:
... for p in my:
... print(p)
...
POINT(0.000000 10.000000)
POINT(5.000000 15.000000)
}}}
Add some new point to an existing map:
{{{
with VectorTopo('mypoits', mode='rw') as my:
... my.write(Point(10, 10))
... my.write(Point(15, 15))
...
}}}
and read again the modified map:
{{{
with VectorTopo('mypoits', mode='r') as my:
... for p in my:
... print(p)
...
POINT(0.000000 10.000000)
POINT(5.000000 15.000000)
POINT(10.000000 10.000000)
POINT(15.000000 15.000000)
}}}
All the best
Pietro
Hi,
2015-01-31 11:16 GMT+01:00 Pietro <peter.zamb@gmail.com>:
Yes, here an example, write a new map:
btw, are these examples collected somewhere (on the wiki)? Thanks! Martin
--
Martin Landa
http://geo.fsv.cvut.cz/gwiki/Landa
http://gismentors.eu/mentors/landa
Hi Martin,
On Sat, Jan 31, 2015 at 12:10 PM, Martin Landa <landa.martin@gmail.com> wrote:
Hi,
2015-01-31 11:16 GMT+01:00 Pietro <peter.zamb@gmail.com>:
Yes, here an example, write a new map:
btw, are these examples collected somewhere (on the wiki)? Thanks! Martin
I collected some training material here:
http://grasswiki.osgeo.org/wiki/Python/pygrass
and here there is a tutorial for the vector part:
http://nbviewer.ipython.org/github/zarch/workshop-pygrass/blob/master/02_Vector.ipynb
But yes the documentation for the pygrass library is not enough I hope
to be able to fill this gap in the next months.
Pietro
Hi Pietro,
2015-01-31 14:42 GMT+01:00 Pietro <peter.zamb@gmail.com>:
I collected some training material here:
thanks for that. Martin
--
Martin Landa
http://geo.fsv.cvut.cz/gwiki/Landa
http://gismentors.eu/mentors/landa