<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman",serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="NO-BOK" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">Or you could use v.distance from GRASS (either through Processing or the QGIS-GRASS plugin):<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US"><a href="http://grass.osgeo.org/grass64/manuals/v.distance.html">http://grass.osgeo.org/grass64/manuals/v.distance.html</a><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">With the “output”-option it produces lines.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">Cheers<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">Stefan<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><b><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif"> qgis-user-bounces@lists.osgeo.org [mailto:qgis-user-bounces@lists.osgeo.org]
<b>On Behalf Of </b>Alexandre Neto<br>
<b>Sent:</b> 10. mars 2015 10:32<br>
<b>To:</b> Raymond Nijssen<br>
<b>Cc:</b> QGIS User<br>
<b>Subject:</b> Re: [Qgis-user] Fwd: Visualize Distance matrix<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">If your data is in a Spatialite or a Postgis database, it's quite easy to achieve what you seek.<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">All you need to do is create a SQL query similar to this one in DB Manager:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">SELECT</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New""> a.gid as dep_id,</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New""> b.gid as dest_id, </span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New""> ST_Distance(a.geom, b.geom) as distance,</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New";background:white"> </span><span style="font-family:"Courier New";color:#2E2E2E;background:#F8F8F9">ST_MakeLine(a.geom, b.geom) as geom</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New";color:#2E2E2E;background:#F8F8F9">FROM</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New";color:#2E2E2E;background:#F8F8F9"> my_table as a, my_table as b</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New";color:#2E2E2E;background:#F8F8F9">WHERE</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New";color:#2E2E2E;background:#F8F8F9"> a.gid > b.gid</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New";color:#2E2E2E;background:#F8F8F9">Note: This is the postgis version, not sure if the same function applies to spatialite</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New";color:#2E2E2E;background:#F8F8F9">Add it to the map canvas by using dep_id as unique value column and geom as geometry column.</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New";color:#2E2E2E;background:#F8F8F9">Hope it helps.</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New";color:#2E2E2E;background:#F8F8F9">Alexandre Neto</span><o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">On Tue, Mar 10, 2015 at 8:08 AM, Raymond Nijssen <<a href="mailto:r.nijssen@terglobo.nl" target="_blank">r.nijssen@terglobo.nl</a>> wrote:<o:p></o:p></p>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<p class="MsoNormal">Hi Joris,<br>
<br>
I dont know about that plugin, but i would write a little script for that like this:<br>
<br>
# get active (point) layer as input<br>
inputlayer = iface.activeLayer()<br>
# create new memory layer for output<br>
outputlayer = QgsVectorLayer("Linestring", "distance_lines", "memory")<br>
outputprovider = outputlayer.dataProvider()<br>
# loop all points<br>
iter = inputlayer.getFeatures()<br>
for feature in iter:<br>
p1 = feature.geometry().asPoint()<br>
iter2 = layer.getFeatures()<br>
for feature2 in iter2:<br>
p2 = feature2.geometry().asPoint()<br>
if not p1 == p2:<br>
# create new line<br>
l = QgsGeometry.fromPolyline([p1,p2])<br>
feat = QgsFeature()<br>
feat.setGeometry(l)<br>
outputprovider.addFeatures([feat])<br>
outputlayer.commitChanges()<br>
outputlayer.updateExtents()<br>
# add to map<br>
QgsMapLayerRegistry.instance().addMapLayer(outputlayer)<br>
<br>
Good luck,<br>
<br>
Raymond<o:p></o:p></p>
<div>
<div>
<p class="MsoNormal"><br>
<br>
<br>
On 09-03-15 18:18, Joris Hintjens wrote:<o:p></o:p></p>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<p class="MsoNormal" style="margin-bottom:12.0pt">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.<br>
Then, I want to plot every distance line (as a seperate layer?) on the map.<br>
<br>
Joris<o:p></o:p></p>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<p class="MsoNormal">Begin doorgestuurd bericht:<br>
<br>
Datum: 9 maart 2015 15:53:56 CET<br>
Van: Raymond Nijssen <<a href="mailto:r.nijssen@terglobo.nl" target="_blank">r.nijssen@terglobo.nl</a>><br>
Aan: <a href="mailto:qgis-user@lists.osgeo.org" target="_blank">qgis-user@lists.osgeo.org</a><br>
Onderwerp: Antw.: [Qgis-user] Visualize Distance matrix<br>
<br>
Hi Joris,<br>
<br>
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.<br>
<br>
The expression should be:<br>
<br>
distance($geometry ,geomFromWKT( 'POINT(0 0)' ))<br>
<br>
to calculate all distances to coordinate 0,0.<br>
<br>
Hope this helps you.<br>
<br>
Raymond<br>
<br>
<br>
<br>
On 09-03-15 15:13, Joris Hintjens wrote:<o:p></o:p></p>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<p class="MsoNormal" style="margin-bottom:12.0pt">I feel stupid: I am stuck with what seems a basic operation..<br>
I have a points layer, of which I want to visualize the distance matrix.<br>
I can create the martini CSV.<br>
I cannot create a distance hub layer with the MMQGIS plugin with From and To point from within the same layer.<br>
<br>
Any help on how I ca get this result on my map?<br>
<br>
PoinA——————>PointB<br>
xxx Meter<br>
<br>
and this for the entire matrix<br>
<br>
<br>
thanks<br>
Joris<br>
_______________________________________________<br>
Qgis-user mailing list<br>
<a href="mailto:Qgis-user@lists.osgeo.org" target="_blank">Qgis-user@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/qgis-user" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-user</a><o:p></o:p></p>
</blockquote>
<p class="MsoNormal"><br>
--<br>
Terglobo<br>
Ampèrestraat 110<br>
5223 CT 's-Hertogenbosch<br>
06-25314983<br>
_______________________________________________<br>
Qgis-user mailing list<br>
<a href="mailto:Qgis-user@lists.osgeo.org" target="_blank">Qgis-user@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/qgis-user" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-user</a><o:p></o:p></p>
</blockquote>
<p class="MsoNormal" style="margin-bottom:12.0pt"><br>
<br>
<br>
<br>
_______________________________________________<br>
Qgis-user mailing list<br>
<a href="mailto:Qgis-user@lists.osgeo.org" target="_blank">Qgis-user@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/qgis-user" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-user</a><o:p></o:p></p>
</blockquote>
<p class="MsoNormal"><br>
-- <br>
Terglobo<br>
Ampèrestraat 110<br>
5223 CT 's-Hertogenbosch<br>
06-25314983<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><br>
_______________________________________________<br>
Qgis-user mailing list<br>
<a href="mailto:Qgis-user@lists.osgeo.org">Qgis-user@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/qgis-user" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-user</a><o:p></o:p></p>
</blockquote>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</body>
</html>