Dear devs,
After searching the pygrass documentation for examples on how to write areas to a vector map and trying different things without success, I am currently struggling with adding the category to the area.
Anyone, who can give me a hint on how add categories to a pygrass geometry, esp. area?
The following Python code shows how I write the area (maybe it is supposed to be done differently?). Result is an area written, but without category and thus not usable at that point:
import grass.script as grass
from grass.pygrass.vector import VectorTopo
from grass.pygrass.vector.geometry import Boundary
from grass.pygrass.vector.geometry import Centroid
from grass.pygrass.vector.geometry import Point
Create area
area = Point(x=100, y=100).buffer(50)
vect_name = ‘test1’
Create vector map
vect = VectorTopo(vect_name)
vect.open(mode=‘w’)
vect.write(Boundary(points=area[0].to_list()))
, c_cats=int(cat), set_cats=True
cent = Centroid(x=area[1].x, y=area[1].y)
vect.write(cent)
vect.close(build=True)
Check if cat is present
grass.read_command(‘v.category’, input= vect_name, option=‘report’)
Thanks for any hints in advance!
Cheers
Stefan
P.S.: Adding a category to the centroid does not help…
P.S.: BTW. pygrass documentation says area.buffer(50) is supposed to return an Area() object [1]. However, it returns a tuple with a line (boundary) and a point (centroid), like Area().buffer(50) is supposed to [2].