1

Can anybody assist in the simplest form of code to call on command line to "export topology" (which is level 2 information in GRASS) as separate spatial data, as explained below?

I have imported cad lines via dxf file containing only lines (a network of pipelines connected in a geographic pattern) into GRASS GIS via command line. This data I convert to polylines via GRASS v.build.polylines combining individual line segments into polylines in between the connection points. (All "joined" lines that do not intersect with other lines are "concatenated" into a single polyline, thus the network only consists of connected polylines)

The resultant vector map has three "layers" (in GRASS only first "layer", other two as "level") reported by QGis GRASS Plugin (seemingly only in QGis GUI?) The "names" assigned to the "level" or "layer" is given by the QGis GRASS Plugin as 1:"Line", 2:"line_topo" and 3:"point_topo" and more elaborately,

  1. Line -> polylines as expected <<<<<<<<<< termed "map" in GRASS
  2. line_topo -> the same polylines, but with node connection table <<<<<<<< @ level 2 in GRASS without "direct" access
  3. point_topo -> the beginning and end points (connection points) of all polylines, with table indicating the lines associated with the specific node <<<<<<<<<<<<< also @ level 2 in GRASS and also without "direct" access

("direct" access in this context is : a v.?? or similar command -> thus that can "access"/"extract"/"manipulate"/"export"/"or in any form whatsoever make it data that can be worked on outside of GRASS")

These "layers" are reported differently by GRASS (mapname = PipePolyLines):

v.info -t map=PipePolyLines
Cleaning up temporary files ...
Starting GRASS ...
Welcome to GRASS 6.4.3 (2013) 
nodes=23274  <<<<<< topology of polyline "connection nodes" (excl vertices)
points=0
lines=25748  <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< actual map information
boundaries=0
centroids=0
areas=0
islands=0
faces=0
kernels=0
primitives=25748
map3d=0
Closing monitors ...

To clear out the data definition, (as per GRASS definitions) @ Level 1 :the map has one layer of information being polylines.
@ Level 2 :The topology of these polylines, consisting of a "node table" (listing all the connecting nodes) as well as a table with the "connection detail" (line 1 = from Node1 to Node2, etc).

With the **GRASS Plugin** one can load level 2 topology as "QGis layers" being distinctly either the nodes (as points) or the connecting topology (as lines), with the NodeFrom and NodeTo line connectivity information.

How can one export the line_topo and the point_topo "QGis GRASS Plugin layers" (or level 2 topology in GRASS) to shapefile (or even attribute table) making use of external command line tools? (Given that the API function Vect_set_open_level seems to be employed by QGis GRASS Plugin)

It is easy to do it within the QGis gui -> simply import from "QGis GRASS Plugin layers" and then save from QGis gui. (I was not able to replicate this in the GRASS GUI though.)

So, how does QGis GRASS Plugin avail the topological information as separate accessible "layers", but the same functionality is not available in GRASS GUI (and for that matter GRASS)?

On a Linux system, I have made use of the bash command that exports the command string into an executable *.sh file (marked for execution) as per the GRASS tutorial ("GRASS Batch jobs" GRASS_and_Shell). This functionality allows for bashing also SAGA, where needed, from within the same bash file.

The proof of concept in making this more interactive seems viable and therefore I would much like to be able to interact more extensively with GRASS through the normal command line (outside of GRASS command line).


Realizing that there is a function Vect_set_open_level from http://grass.osgeo.org/programming6/vector_2Vlib_2open_8c.html, it would seem as if this functionality will not be available at command prompt?

The Grass Plugin for QGis calls this function in qgsgrassprovider.cpp.

I am not a programmer so this does not help a lot.

Just to show that GRASS 'v.out.ogr' is not able to access "topo_point" as a layer all three these commands

  1. v.out.ogr -e type=point input=PipePolyLines layer=1 dsn=PolyTopo.shp
  2. v.out.ogr -e type=point input=PipePolyLines layer=2 dsn=PolyTopo.shp
  3. v.out.ogr -e type=point input=PipePolyLines layer=0 dsn=PolyTopo.shp

produce the same response from GRASS

Cleaning up temporary files ...
Starting GRASS ...
Welcome to GRASS 6.4.3 (2013) 
WARNING: 25748 line(s) found, but not requested to be exported. Verify
         'type' parameter.
WARNING: No points found, but requested to be exported. Will skip this
         geometry type.
WARNING: Nothing to export
Closing monitors ...

Can anybody assist with the simplest form of code to call "topology export" from command line as stated above?

1 Answer 1

3

The GRASS command v.out.ogr, which you would use to export a vector to a shape, takes a layer= parameter. This way you can export separate layers from a GRASS vector. The values would be 0,1 etc.

But when you say "vector map has multiple layers" I assume you mean that the vector contains both points and lines. In this case use the type= parameter to get only points or lines.

5
  • Micha, thank you for commenting. Actually, the terminology used in the various modules can become confusing. I am editing my question in relation to the "vector map has multiple layers". GRASS uses two distinct terms "layer" and "level" - "layer" for the actual data and "level" for the topology. Thus, the polyline layer has its topology at level 2 (which is termed "layer" in QGis GRASS plugin). I want to access "level 2" on "layer 1" as bash printout shows.
    – Jaco V
    Commented Sep 26, 2014 at 7:12
  • You can find a graphical summary here: grasswiki.osgeo.org/wiki/…
    – markusN
    Commented Sep 29, 2014 at 19:46
  • @markusN Thank you for the pointer. However, not being a programmer, the graphical data presentation does not assist in me accessing the topology information as the programming is way over my head.Seems there is not a ready made function to call from command line in order to extract the topology from GRASS.
    – Jaco V
    Commented Oct 1, 2014 at 5:40
  • @jacov Not sure what you mean with "extract". To write it out into ASCII format, use grass.osgeo.org/grass70/manuals/v.out.ascii.html#standard-mode - otherwise v.out.ogr will export to Simple Features (SHAPE is non-topological!).
    – markusN
    Commented Oct 4, 2014 at 23:15
  • @markusN The question is put long in order to convey all communications, but may not be concise enough for a quick read. However, the short and sweet of it is, my goal, or what I want to achieve, on/at command line can "easily" be achieved from the GRASS Plugin in QGIS. The process in QGIS is however not suitable for bulk process. So that should eliminate conjecture. Try for yourself what I describe in the question and your uncertainties might then be cleared up.
    – Jaco V
    Commented Oct 6, 2014 at 2:30

Not the answer you're looking for? Browse other questions tagged or ask your own question.