1

I have been trying to use the v.net.distance from GRASS in the QGIS toolbox. I have a road layer with two sets of points I want to calculate the shortest distance between. I have checked the validity of my data and have also run v.build.check to confirm that my topology is correct. I can run GDAL tools and qgis tools that achieve a similar goal, just not this particular GRASS tool (it allows for calculating shortest distance between two different datasets, as opposed to Shortest Path which is from or to a single point.) When I run the tool I get back:

ERROR: Unable to open vector map <outputff06757401c4451cafe5dc2e9072a5cb>

Maybe there is a glitch with this tool functioning in QGIS? Maybe there is a workaround? I am going to try it directly in GRASS.

Processing algorithm…
        Algorithm 'v.net.distance' starting…
        Input parameters:
        { '-g' : False, '-l' : False, 'GRASS_MIN_AREA_PARAMETER' : 0.0001, 'GRASS_OUTPUT_TYPE_PARAMETER' : 0, 'GRASS_REGION_PARAMETER' : None, 'GRASS_SNAP_TOLERANCE_PARAMETER' : -1, 'GRASS_VECTOR_DSCO' : '', 'GRASS_VECTOR_LCO' : '', 'arc_backward_column' : None, 'arc_column' : None, 'arc_type' : [0,1], 'flayer' : 'C:/OSGEO4~1/bin/Points.shp', 'from_cats' : '', 'from_where' : '', 'input' : 'C:/Users/hrlan/OneDrive/GIS Data/Tri-Cities/TRIAL/clippedroads.gpkg', 'node_column' : None, 'output' : 'C:/Users/hrlan/AppData/Local/Temp/processing_6eba1c62bb314895b2461e5307c0bcf3/3fe80ebcd9fc46d3a5514a940ca6f30a/output.gpkg', 'threshold' : 50, 'tlayer' : 'C:/OSGEO4~1/bin/Lith.shp', 'to_cats' : '', 'to_type' : [0], 'to_where' : '' }

        g.proj -c proj4="+proj=lcc +lat_1=47.33333333333334 +lat_2=45.83333333333334 +lat_0=45.33333333333334 +lon_0=-120.5 +x_0=500000.0001016001 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=us-ft +no_defs"
        v.in.ogr min_area=0.0001 snap=-1.0 input="C:\Users\hrlan\OneDrive\GIS Data\Tri-Cities\TRIAL\clippedroads.gpkg" output="vector_5c3275b17603e19" --overwrite -o
        v.in.ogr min_area=0.0001 snap=-1.0 input="C:\OSGEO4~1\bin\Points.shp" output="vector_5c3275b17642320" --overwrite -o
        v.in.ogr min_area=0.0001 snap=-1.0 input="C:\OSGEO4~1\bin\Lith.shp" output="vector_5c3275b17642321" --overwrite -o
        g.region n=324088.0 s=46.18814656209498 e=1985810.0 w=-119.21186806411583
        v.net input=vector_5c3275b17603e19 points=vector_5c3275b17642320 output=bufnet5c3275b17680c22 operation=connect threshold=50.0 arc_layer=1 node_layer=2
        v.net input=bufnet5c3275b17680c22 points=vector_5c3275b17642321 output=net5c3275b17680c23 operation=connect threshold=50.0 arc_layer=1 node_layer=3
        v.db.connect -o map=net5c3275b17680c23 table=vector_5c3275b17642320 layer=2
        v.db.connect -o map=net5c3275b17680c23 table=vector_5c3275b17642321 layer=3
        v.net.distance input=net5c3275b17680c23 arc_type="line,boundary" to_type="point" from_layer="2" to_layer="3" output=outputff06757401c4451cafe5dc2e9072a5cb --overwrite
        v.out.ogr type="line" input="outputff06757401c4451cafe5dc2e9072a5cb" output="C:/Users/hrlan/AppData/Local/Temp/processing_6eba1c62bb314895b2461e5307c0bcf3/3fe80ebcd9fc46d3a5514a940ca6f30a/output.gpkg" format="GPKG" layer=1 --overwrite
        Cleaning up temporary files...
        Starting GRASS GIS...
        WARNING: Concurrent mapset locking is not supported on Windows
        Executing <C:\Users\hrlan\AppData\Local\Temp\processing_6eba1c62bb314895b2461e5307c0bcf3\grassdata\grass_batch_job.cmd> ...
        C:\OSGEO4~1\bin>chcp 1252 1>NUL
        C:\OSGEO4~1\bin>g.proj -c proj4="+proj=lcc +lat_1=47.33333333333334 +lat_2=45.83333333333334 +lat_0=45.33333333333334 +lon_0=-120.5 +x_0=500000.0001016001 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=us-ft +no_defs"
        Default region was updated to the new projection, but if you have multiple mapsets `g.region -d` should be run in each to update the region from the default
        Projection information updated
        C:\OSGEO4~1\bin>v.in.ogr min_area=0.0001 snap=-1.0 input="C:\Users\hrlan\OneDrive\GIS Data\Tri-Cities\TRIAL\clippedroads.gpkg" output="vector_5c3275b17603e19" --overwrite -o
        Over-riding projection check
        Check if OGR layer <Road> contains polygons...
        0..2..4..6..8..10..12..14..16..18..20..22..24..26..28..30..32..34..36..38..40..42..44..46..48..50..52..54..56..58..60..62..64..66..68..70..72..74..76..78..80..82..84..86..88..90..92..94..96..98..100
        Creating attribute table for layer <Road>...
        Importing 1632 features (OGR layer <Road>)...
        0..2..4..6..8..10..12..14..16..18..20..22..24..26..28..30..32..34..36..38..40..42..44..46..48..50..52..54..56..58..60..62..64..66..68..70..72..74..76..78..80..82..84..86..88..90..92..94..96..98..100
        -----------------------------------------------------
        Building topology for vector map <vector_5c3275b17603e19@PERMANENT>...
        Registering primitives...
        1632 primitives registered
        7883 vertices registered
        Building areas...
        0..2..4..6..8..10..12..14..16..18..20..22..24..26..28..30..32..34..36..38..40..42..44..46..48..50..52..54..56..58..60..62..64..66..68..70..72..74..76..78..80..82..84..86..88..90..92..94..96..98..100
        0 areas built
        0 isles built
        Attaching islands...
        Attaching centroids...
        1..3..5..7..9..11..13..15..17..19..21..23..25..27..29..31..33..35..37..39..41..43..45..47..49..51..53..55..57..59..61..63..65..67..69..71..73..75..77..79..81..83..85..87..89..91..93..95..97..99..100
        Number of nodes: 1315
        Number of primitives: 1632
        Number of points: 0
        Number of lines: 1632
        Number of boundaries: 0
        Number of centroids: 0
        Number of areas: 0
        Number of isles: 0
        C:\OSGEO4~1\bin>v.in.ogr min_area=0.0001 snap=-1.0 input="C:\OSGEO4~1\bin\Points.shp" output="vector_5c3275b17642320" --overwrite -o
        Over-riding projection check
        Check if OGR layer <Points> contains polygons...
        0..50..100
        Creating attribute table for layer <Points>...
        Importing 2 features (OGR layer <Points>)...
        0..50..100
        -----------------------------------------------------
        Building topology for vector map <vector_5c3275b17642320@PERMANENT>...
        Registering primitives...
        2 primitives registered
        2 vertices registered
        Building areas...
        0..50..100
        0 areas built
        0 isles built
        Attaching islands...
        Attaching centroids...
        50..100
        Number of nodes: 0
        Number of primitives: 2
        Number of points: 2
        Number of lines: 0
        Number of boundaries: 0
        Number of centroids: 0
        Number of areas: 0
        Number of isles: 0
        C:\OSGEO4~1\bin>v.in.ogr min_area=0.0001 snap=-1.0 input="C:\OSGEO4~1\bin\Lith.shp" output="vector_5c3275b17642321" --overwrite -o
        Over-riding projection check
        Check if OGR layer <Lith> contains polygons...
        0..50..100
        Creating attribute table for layer <Lith>...
        Importing 2 features (OGR layer <Lith>)...
        0..50..100
        -----------------------------------------------------
        Registering primitives...
        0 primitives registered
        0 vertices registered
        Number of nodes: 0
        Number of primitives: 0
        Number of points: 0
        Number of lines: 0
        Number of boundaries: 0
        Number of centroids: 0
        Number of areas: -
        Number of isles: -
        Copying features...
        Building topology for vector map <vector_5c3275b17642321@PERMANENT>...
        Registering primitives...
        0 primitives registered
        0 vertices registered
        Building areas...
        100
        0 areas built
        0 isles built
        Attaching islands...
        Attaching centroids...
        Number of nodes: 0
        Number of primitives: 0
        Number of points: 0
        Number of lines: 0
        Number of boundaries: 0
        Number of centroids: 0
        Number of areas: 0
        Number of isles: 0
        C:\OSGEO4~1\bin>g.region n=324088.0 s=46.18814656209498 e=1985810.0 w=-119.21186806411583
        C:\OSGEO4~1\bin>v.net input=vector_5c3275b17603e19 points=vector_5c3275b17642320 output=bufnet5c3275b17680c22 operation=connect threshold=50.0 arc_layer=1 node_layer=2
        Copying features...
        2..5..8..11..14..17..20..23..26..29..32..35..38..41..44..47..50..53..56..59..62..65..68..71..74..77..80..83..86..89..92..95..98..100
        Building topology for vector map <bufnet5c3275b17680c22@PERMANENT>...
        Registering primitives...
        1632 primitives registered
        7883 vertices registered
        Number of nodes: 1315
        Number of primitives: 1632
        Number of points: 0
        Number of lines: 1632
        Number of boundaries: 0
        Number of centroids: 0
        Number of areas: -
        Number of isles: -
        Copying attributes...
        Building topology for vector map <bufnet5c3275b17680c22@PERMANENT>...
        Registering primitives...
        1632 primitives registered
        7883 vertices registered
        Building areas...
        0..2..4..6..8..10..12..14..16..18..20..22..24..26..28..30..32..34..36..38..40..42..44..46..48..50..52..54..56..58..60..62..64..66..68..70..72..74..76..78..80..82..84..86..88..90..92..94..96..98..100
        0 areas built
        0 isles built
        Attaching islands...
        Attaching centroids...
        1..3..5..7..9..11..13..15..17..19..21..23..25..27..29..31..33..35..37..39..41..43..45..47..49..51..53..55..57..59..61..63..65..67..69..71..73..75..77..79..81..83..85..87..89..91..93..95..97..99..100
        Number of nodes: 1315
        Number of primitives: 1632
        Number of points: 0
        Number of lines: 1632
        Number of boundaries: 0
        Number of centroids: 0
        Number of areas: 0
        Number of isles: 0
        v.net complete. 0 lines (network arcs) written to output.
        C:\OSGEO4~1\bin>v.net input=bufnet5c3275b17680c22 points=vector_5c3275b17642321 output=net5c3275b17680c23 operation=connect threshold=50.0 arc_layer=1 node_layer=3
        Copying features...
        2..5..8..11..14..17..20..23..26..29..32..35..38..41..44..47..50..53..56..59..62..65..68..71..74..77..80..83..86..89..92..95..98..100
        Building topology for vector map <net5c3275b17680c23@PERMANENT>...
        Registering primitives...
        1632 primitives registered
        7883 vertices registered
        Number of nodes: 1315
        Number of primitives: 1632
        Number of points: 0
        Number of lines: 1632
        Number of boundaries: 0
        Number of centroids: 0
        Number of areas: -
        Number of isles: -
        Copying attributes...
        Building topology for vector map <net5c3275b17680c23@PERMANENT>...
        Registering primitives...
        1632 primitives registered
        7883 vertices registered
        Building areas...
        0..2..4..6..8..10..12..14..16..18..20..22..24..26..28..30..32..34..36..38..40..42..44..46..48..50..52..54..56..58..60..62..64..66..68..70..72..74..76..78..80..82..84..86..88..90..92..94..96..98..100
        0 areas built
        0 isles built
        Attaching islands...
        Attaching centroids...
        1..3..5..7..9..11..13..15..17..19..21..23..25..27..29..31..33..35..37..39..41..43..45..47..49..51..53..55..57..59..61..63..65..67..69..71..73..75..77..79..81..83..85..87..89..91..93..95..97..99..100
        Number of nodes: 1315
        Number of primitives: 1632
        Number of points: 0
        Number of lines: 1632
        Number of boundaries: 0
        Number of centroids: 0
        Number of areas: 0
        Number of isles: 0
        v.net complete. 0 lines (network arcs) written to output.
        C:\OSGEO4~1\bin>v.db.connect -o map=net5c3275b17680c23 table=vector_5c3275b17642320 layer=2
        The table <vector_5c3275b17642320> is now part of vector map <net5c3275b17680c23> and may be deleted or overwritten by GRASS modules
        Select privileges were granted on the table
        C:\OSGEO4~1\bin>v.db.connect -o map=net5c3275b17680c23 table=vector_5c3275b17642321 layer=3
        The table <vector_5c3275b17642321> is now part of vector map <net5c3275b17680c23> and may be deleted or overwritten by GRASS modules
        Select privileges were granted on the table
        C:\OSGEO4~1\bin>v.net.distance input=net5c3275b17680c23 arc_type="line,boundary" to_type="point" from_layer="2" to_layer="3" output=outputff06757401c4451cafe5dc2e9072a5cb --overwrite
        ERROR: No 'from' features selected. Please check options 'from_layer', 'from_where', 'from_cats'.
        C:\OSGEO4~1\bin>v.out.ogr type="line" input="outputff06757401c4451cafe5dc2e9072a5cb" output="C:/Users/hrlan/AppData/Local/Temp/processing_6eba1c62bb314895b2461e5307c0bcf3/3fe80ebcd9fc46d3a5514a940ca6f30a/output.gpkg" format="GPKG" layer=1 --overwrite
        WARNING: Unable to open vector map <outputff06757401c4451cafe5dc2e9072a5cb@PERMANENT> on level 2. Try to rebuild vector topology with v.build.
        ERROR: Unable to open vector map <outputff06757401c4451cafe5dc2e9072a5cb>
        C:\OSGEO4~1\bin>exit
        Execution of <C:\Users\hrlan\AppData\Local\Temp\processing_6eba1c62bb314895b2461e5307c0bcf3\grassdata\grass_batch_job.cmd> finished.
        Cleaning up temporary files...
        Press any key to continue . . .
        Execution completed in 10.80 seconds
        Results:
        {'output': <QgsProcessingOutputLayerDefinition {'sink':C:/Users/hrlan/AppData/Local/Temp/processing_6eba1c62bb314895b2461e5307c0bcf3/3fe80ebcd9fc46d3a5514a940ca6f30a/output.gpkg, 'createOptions': {'fileEncoding': 'System'}}>}

        Loading resulting layers
        The following layers were not correctly generated.<ul><li>C:/Users/hrlan/AppData/Local/Temp/processing_6eba1c62bb314895b2461e5307c0bcf3/3fe80ebcd9fc46d3a5514a940ca6f30a/output.gpkg</li></ul>You can check the 'Log Messages Panel' in QGIS main window to find more information about the execution of the algorithm

.
3

The algorithm is failing to find arcs that connect the points with the network, both to the points of entry to the network and to the output (between both "from" and "to" point layers and the "network" layer).

You can see it in these parts of the log:

Processing algorithm…
    Algorithm 'v.net.distance' starting…
    ...
    ...
    C:\OSGEO4~1\bin>v.net input=vector_5c3275b17603e19 points=vector_5c3275b17642320 output=bufnet5c3275b17680c22 operation=connect threshold=50.0 arc_layer=1 node_layer=2
    Copying features...
    ...
    v.net complete. 0 lines (network arcs) written to output.
    C:\OSGEO4~1\bin>v.net input=bufnet5c3275b17680c22 points=vector_5c3275b17642321 output=net5c3275b17680c23 operation=connect threshold=50.0 arc_layer=1 node_layer=3
    Copying features...
    ...
    v.net complete. 0 lines (network arcs) written to output.
    ...
    ...
.  

From there it fails to find the arcs and can not calculate the shortest distance between them, but under those circumstances it is already an expected behavior.

The first thing I suggest you verify is that the points are closer to the network than the assigned threshold (50.0 in your case). The assigned threshold is the distance with respect to the network to which points are searched, in map units (obviously, its three layers must have assigned the same CRS).

Or rather adjust the threshold to the maximum distance you want a point to be searched around each line of the network, making sure that at least one point of each layer is at a distance less than the specified threshold.

If having done that verification the algorithm fails again, comment that we will look for the origin of the error. In addition, I suggest that you edit the body of the question by clarifying which version of QGIS you are using, and as much as possible attach sets of data that can be verified to reproduce the error.

  • I am assuming that the network is a set of lines that are broken at each intersection. In other words, a new line starts at each "corner" or "cross street". If this were not the case, and the lines were only one along the entire route, keep in mind that the network "has no corners", that is, only points that are close to the same route can be analyzed. Use the v.clean tool, with the break method, to split the routes at each intersection if necessary. – Gabriel De Luca Jan 7 at 3:07
  • Thank you for the punctual and thorough response Gabriel. I tried changing the threshold to absurdly high and low values to hopefully allow GRASS to detect points near other points, but I still received the same error. I then tried using the v.clean tool using the break function, but received the Warning: no attributes found error again. I tried running this cleaned file in v.net.distance, yet still received the same error. Is it possible that I have set the parameters in both v.et.distance and v.clean incorrectly? – hendo Jan 8 at 18:45
  • I tried running the topology checker plugin, and got back a bunch of "dangles" where small side streets are in my dataset. I am not sure if v.net.distance is picking up on that as well? – hendo Jan 8 at 19:15
  • @hendo, simplify the problem. Try with a new layer with a few lines. Try drawing arcs between points and networks with v.net. Don't run the v.net.distance algorithm in QGIS until you can be sure that the points and the network can be connected. If it doesn't work, please share sample data. – Gabriel De Luca Jan 8 at 20:32
  • I created a very simple vector shapefile, consisting of four different lines that all intersect at different points. I ran v.net, using the vector trial road data I created as the input arc layer. The task to be performed I set to "nodes," and ran the program. I got back these warnings, and nothing as an output. "WARNING: 7 features without category were skipped. Features without category are written only when -c flag is given. WARNING: Output layer is empty, no features written" I tried different settings, and my only hunch is that I need to enter a node dataset? But it should do that forme – hendo Jan 10 at 19:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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