Hello!

Here is yet another request for hand-holding with GRASS GIS.  This time it's aquestion on pygrass API, version 7.8.5.  I want to create a new vector map from a Python script.  The steps I'm following are:

1. Create a VectorTopo object with.

2. Define attribute columns: cols = [(column name, type), ...]

3. Open the VectorTopo object in write mode: write("w", tab_cols=cols, ...).

4. Add geometry objects, in my case it's Area objects, one by one using write() interface.

5. Commit changes and close the VectorTopo.

Step 4, however, is causing "AttributeError" in a pygrass module.  Stack trace:

Traceback (most recent call last):
  File "stream_features.py", line 404, in <module>
    generateWatersheds(ssegs, dwsmapname)
  File "stream_features.py", line 359, in generateWatersheds
    dwsvector.write(
  File "/Applications/GRASS-7.8.app/Contents/Resources/etc/python/grass/pygrass/errors.py", line 15, in wrapper
    return method(self, *args, **kargs)
  File "/Applications/GRASS-7.8.app/Contents/Resources/etc/python/grass/pygrass/vector/__init__.py", line 217, in write
    result = self._write_area(geo_obj)
AttributeError: 'VectorTopo' object has no attribute '_write_area'

Can someone shed light on where my understanding is going wrong?  Is this a bug in vector/__init__.py?  The code snippet for reference:

<snip>

    dwsvector = vector.VectorTopo("differential_watersheds")

    dwscols = [("cat", "INTEGER PRIMARY KEY"),
               ("stream1", "INTEGER"),
               ("stream2", "INTEGER")]

    dwsvector.open("w", tab_name=dwsmapname, tab_cols=dwscols, overwrite=True)

    cat = 1

    # "boundary" is a vector.geometry.Boundary object, obtained
    # from an existing vector map that is opened previously.
    areageom = vector.geometry.Area(v_id=boundary.id, c_mapinfo=boundary.c_mapinfo)

    dwsvector.write(
        areageom,
        cat,
        attrs=(boundary.attrs["s1"], boundary.attrs["s2"]))

    # The AttributeError thrown when the write() method above is invoked.

</snip>

Hope the problem description is clear, if it isn't, please let me know.

Asim
_______________________________________________
grass-user mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/grass-user

Reply via email to