Or you could use v.distance from GRASS (either through Processing or the 
QGIS-GRASS plugin):
http://grass.osgeo.org/grass64/manuals/v.distance.html

With the “output”-option it produces lines.

Cheers
Stefan

From: qgis-user-boun...@lists.osgeo.org 
[mailto:qgis-user-boun...@lists.osgeo.org] On Behalf Of Alexandre Neto
Sent: 10. mars 2015 10:32
To: Raymond Nijssen
Cc: QGIS User
Subject: Re: [Qgis-user] Fwd: Visualize Distance matrix

If your data is in a Spatialite or a Postgis database, it's quite easy to 
achieve what you seek.

All you need to do is create a SQL query similar to this one in DB Manager:

SELECT
    a.gid as dep_id,
    b.gid as dest_id,
    ST_Distance(a.geom, b.geom) as distance,
    ST_MakeLine(a.geom, b.geom) as geom
FROM
    my_table as a, my_table as b
WHERE
    a.gid > b.gid

Note: This is the postgis version, not sure if the same function applies to 
spatialite

Add it to the map canvas by using dep_id as unique value column and geom as 
geometry column.

Hope it helps.

Alexandre Neto

On Tue, Mar 10, 2015 at 8:08 AM, Raymond Nijssen 
<r.nijs...@terglobo.nl<mailto:r.nijs...@terglobo.nl>> wrote:
Hi Joris,

I dont know about that plugin, but i would write a little script for that like 
this:

# get active (point) layer as input
inputlayer = iface.activeLayer()
# create new memory layer for output
outputlayer = QgsVectorLayer("Linestring", "distance_lines", "memory")
outputprovider = outputlayer.dataProvider()
# loop all points
iter = inputlayer.getFeatures()
for feature in iter:
    p1 = feature.geometry().asPoint()
    iter2 = layer.getFeatures()
    for feature2 in iter2:
        p2 = feature2.geometry().asPoint()
        if not p1 == p2:
            # create new line
            l = QgsGeometry.fromPolyline([p1,p2])
            feat = QgsFeature()
            feat.setGeometry(l)
            outputprovider.addFeatures([feat])
outputlayer.commitChanges()
outputlayer.updateExtents()
# add to map
QgsMapLayerRegistry.instance().addMapLayer(outputlayer)

Good luck,

Raymond



On 09-03-15 18:18, Joris Hintjens wrote:
Thanks Raymond, but what I need is the distance from every point in a layer to 
every other point. That is what “distance matrix” gives me.
Then, I want to plot every distance line (as a seperate layer?) on the map.

Joris
Begin doorgestuurd bericht:

Datum: 9 maart 2015 15:53:56 CET
Van: Raymond Nijssen <r.nijs...@terglobo.nl<mailto:r.nijs...@terglobo.nl>>
Aan: qgis-user@lists.osgeo.org<mailto:qgis-user@lists.osgeo.org>
Onderwerp: Antw.: [Qgis-user] Visualize Distance matrix

Hi Joris,

Not sure if I understand your question, but if you want to do a distance 
calculation for all points in a point layer to a certain location you can use 
the field calculator in the attribute table window.

The expression should be:

distance($geometry ,geomFromWKT( 'POINT(0 0)' ))

to calculate all distances to coordinate 0,0.

Hope this helps you.

Raymond



On 09-03-15 15:13, Joris Hintjens wrote:
I feel stupid: I am stuck with what seems a basic operation..
I have a points layer, of which I want to visualize the distance matrix.
I can create the martini CSV.
I cannot create a distance hub layer with the MMQGIS plugin with From and To 
point from within  the same layer.

Any help on how I ca get this result on my map?

PoinA——————>PointB
                xxx Meter

and this for the entire matrix


thanks
Joris
_______________________________________________
Qgis-user mailing list
Qgis-user@lists.osgeo.org<mailto:Qgis-user@lists.osgeo.org>
http://lists.osgeo.org/mailman/listinfo/qgis-user

--
Terglobo
Ampèrestraat 110
5223 CT 's-Hertogenbosch
06-25314983
_______________________________________________
Qgis-user mailing list
Qgis-user@lists.osgeo.org<mailto:Qgis-user@lists.osgeo.org>
http://lists.osgeo.org/mailman/listinfo/qgis-user




_______________________________________________
Qgis-user mailing list
Qgis-user@lists.osgeo.org<mailto:Qgis-user@lists.osgeo.org>
http://lists.osgeo.org/mailman/listinfo/qgis-user

--
Terglobo
Ampèrestraat 110
5223 CT 's-Hertogenbosch
06-25314983

_______________________________________________
Qgis-user mailing list
Qgis-user@lists.osgeo.org<mailto:Qgis-user@lists.osgeo.org>
http://lists.osgeo.org/mailman/listinfo/qgis-user

_______________________________________________
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user

Reply via email to