<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<p><font face="Courier">Hello!</font></p>
<p><font face="Courier">Here is yet another request for hand-ho</font><font
face="Courier">lding with GRASS GIS. This time it's a</font><font
face="Courier"> question on pygrass API, version 7.8.5. I want
to create a new vector map from a Python script. The steps I'm
fo</font><font face="Courier">l</font><font face="Courier">lowing
are:</font></p>
<p><font face="Courier">1. Create a VectorTopo object with.</font></p>
<font face="Courier">2. Define attribute co</font><font
face="Courier">lumns: co</font><font face="Courier"><font
face="Courier">ls = </font>[(co</font><font face="Courier">lumn
name, type), ...]</font>
<p><font face="Courier">3. Open the VectorTopo object in write mode:
write("w", tab_co</font><font face="Courier"><font
face="Courier">ls=</font>co</font><font face="Courier"><font
face="Courier">ls, ...)</font>.<br>
</font></p>
<p><font face="Courier">4. Add geometry objects, in my case it's
Area objects, one by one using write() interface.</font></p>
<p><font face="Courier">5. Commit changes and c</font><font
face="Courier">lose the VectorTopo.<br>
</font></p>
<p><font face="Courier">Step 4, however, is causing "AttributeError"
in a pygrass modu</font><font face="Courier">le. Stack trace:</font><br>
<font face="Courier"><font face="Courier"></font></font></p>
<p><font face="Courier">Traceback (most recent call last):<br>
File "stream_features.py", line 404, in <module><br>
generateWatersheds(ssegs, dwsmapname)<br>
File "stream_features.py", line 359, in generateWatersheds<br>
dwsvector.write(<br>
File
"/Applications/GRASS-7.8.app/Contents/Resources/etc/python/grass/pygrass/errors.py",
line 15, in wrapper<br>
return method(self, *args, **kargs)<br>
File
"/Applications/GRASS-7.8.app/Contents/Resources/etc/python/grass/pygrass/vector/__init__.py",
line 217, in write<br>
result = self._write_area(geo_obj)<br>
AttributeError: 'VectorTopo' object has no attribute
'_write_area'<br>
</font></p>
<p><font face="Courier">Can someone shed </font><font
face="Courier"><font face="Courier">light on where my
understanding is going wrong? Is this a bug in
vector/__init__.py? The code snippet for reference:</font></font></p>
<p><font face="Courier"><font face="Courier"><snip><br>
<br>
dwsvector = vector.VectorTopo("differentia</font></font><font
face="Courier"><font face="Courier"><font face="Courier">l_watersheds</font>")<br>
<br>
dwscols = [("cat", "INTEGER PRIMARY KEY"),<br>
("stream1", "INTEGER"),<br>
("stream2", "INTEGER")]<br>
<br>
dwsvector.open("w", tab_name=dwsmapname, tab_cols=dwscols,
overwrite=True)<br>
<br>
cat = 1<br>
<br>
# "boundary" is a vector.geometry.Boundary object,
obtained<br>
# from an existing vector map that is opened previous</font></font><font
face="Courier"><font face="Courier"><font face="Courier">ly</font>.<br>
areageom = vector.geometry.Area(v_id=boundary.id,
c_mapinfo=boundary.c_mapinfo)<br>
<br>
dwsvector.write(<br>
areageom,<br>
cat,<br>
attrs=(boundary.attrs["s1"], boundary.attrs["s2"]))<br>
<br>
# The AttributeError thrown when the write() method above
is invoked.<br>
<br>
</snip><br>
<br>
Hope the prob</font></font><font face="Courier">lem
description is c</font><font face="Courier"><font face="Courier">lear,
if it isn't, p</font></font><font face="Courier"><font
face="Courier"><font face="Courier">lease </font></font></font><font
face="Courier"><font face="Courier"><font face="Courier"><font
face="Courier">let me know.<br>
<br>
Asim<br>
</font></font></font></font></p>
</body>
</html>