<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">Hi, <br>
I knew about those functions a few weeks ago, and I was really
happy about that, because it is a lack in the basic function.<br>
For I, those new functions should really be in the core project in
the next release ...<br>
Thanks to all the programmers.<br>
Jean<br>
<br>
Le 15/01/2015 11:59, Enrico Ferreguti a écrit :<br>
</div>
<blockquote
cite="mid:CAJy=XteGLd0T2NhW2C+yswL0H9Hh8f9x-D=y7Ti5LxoeUWseaA@mail.gmail.com"
type="cite">
<div dir="ltr">
<div>
<div>
<div>You can use refFunctions (<a moz-do-not-send="true"
href="http://plugins.qgis.org/plugins/refFunctions/">http://plugins.qgis.org/plugins/refFunctions/</a>)
plugin that extends Field Calculator with a new Reference
group.<br>
</div>
Within this group you will find a geomnearest and a
geomdistance function that can help you.<br>
</div>
<br>
</div>
<div>copy and paste from helper screen:<br>
<br>
<span style="font-family:"luxi serif,georgia,times new
roman,times,serif";font-size:large;font-weight:600;color:rgb(114,159,207);background-color:rgb(246,246,246)">geomnearest
function</span>
<p style="margin:0px;text-indent:0px"><span
style="font-family:"arial,sans-serif";color:rgb(0,0,0)"><br>
Retrieve target field value from the nearest target
feature in target layer </span></p>
<p style="margin:12px
0px;text-indent:0px;background-color:rgb(246,246,246)"><span
style="font-family:"luxi serif,georgia,times new
roman,times,serif";font-size:medium;font-weight:600;color:rgb(114,159,207);background-color:rgb(246,246,246)">Syntax</span><span
style="font-family:"arial,sans-serif";color:rgb(0,0,0)"> </span></p>
<p style="margin:12px 0px;text-indent:0px"><span
style="font-family:"arial,sans-serif";color:rgb(0,0,0)">geomnearest(</span><span
style="font-family:"arial,sans-serif";font-style:italic;color:rgb(0,0,0)">targetLayer,targetField</span><span
style="font-family:"arial,sans-serif";color:rgb(0,0,0)">) </span></p>
<p style="margin:12px
0px;text-indent:0px;background-color:rgb(246,246,246)"><span
style="font-family:"luxi serif,georgia,times new
roman,times,serif";font-size:medium;font-weight:600;color:rgb(114,159,207);background-color:rgb(246,246,246)">Arguments</span><span
style="font-family:"arial,sans-serif";color:rgb(0,0,0)"> </span></p>
<p style="margin:12px 0px;text-indent:0px"><span
style="font-family:"arial,sans-serif";font-style:italic;color:rgb(0,0,0)">targetLayer</span><span
style="font-family:"arial,sans-serif";color:rgb(0,0,0)"> → the
name of a currently loaded layer, for example 'myLayer'.<br>
</span><span
style="font-family:"arial,sans-serif";font-style:italic;color:rgb(0,0,0)">targetField</span><span
style="font-family:"arial,sans-serif";color:rgb(0,0,0)"> → a
field in target layer we want as result when source
feature is within target feature, for example 'myField'. <br>
If targetField is equal to '$geometry' The WKT geometry of
targetFeature willbe retrieved. If otherwise is equal to
'$distance' the calculated distance between source and
target features will be returned<br>
</span><span
style="font-family:"arial,sans-serif";font-style:italic;color:rgb(0,0,0)">Number
of feature tested is limited to 100000 to avoid time
wasting loops</span><span
style="font-family:"arial,sans-serif";color:rgb(0,0,0)">
</span></p>
<p style="margin:12px
0px;text-indent:0px;background-color:rgb(246,246,246)"><span
style="font-family:"luxi serif,georgia,times new
roman,times,serif";font-size:medium;font-weight:600;color:rgb(114,159,207);background-color:rgb(246,246,246)">Example</span><span
style="font-family:"arial,sans-serif";color:rgb(0,0,0)"> </span></p>
<p style="margin:12px 0px;text-indent:0px"><span
style="font-family:"arial,sans-serif";color:rgb(0,0,0)">geomnearest('targetLayer','TargetField')
<br>
geomnearest('targetLayer','$geometry') <br>
geomnearest('targetLayer','$distance') </span></p>
<br>
</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">2015-01-15 11:19 GMT+01:00 Junior Delaz
<span dir="ltr"><<a moz-do-not-send="true"
href="mailto:delazj@gmail.com" target="_blank">delazj@gmail.com</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">
<div>
<div>
<div>
<div>
<div>Hi all,<br>
<br>
</div>
I have two shapefiles : a line one (called
"section") and a point one (called "station")
shapefiles.<br>
</div>
The line shapefiles has fields like ID_section,
ID_first, ID_last<br>
</div>
The point file has an ID_station.<br>
</div>
<div>All these define a kind of network where a section
begins on a station and ends up at another station.<br>
</div>
<div>What I need to do is to fill :<br>
- section ID_first field with the ID_station of the
station that is the closest to the beginning of the
section<br>
- and section ID_last field with the ID_station of the
closest station to the end of the line.<br>
</div>
<div><br>
I can obtain this result while combining many analysis
tools and plugins (QChainage, Spatial_Join...). I know
how I can do it. There might be a way with processing
tools and if somebody has an idea, I'll be glad to
know it however.<br>
<br>
</div>
<div>But what I'm really wondering is if it isn't
directly possible to fill these fields in the Field
calculator using all the nice functions we have.
Indeed, QGIS 2.6 and RefFunctions plugin give
relational fonctions to retrieve values on a specific
layer according to its fields, features values or
localisation.<br>
</div>
<div>I tried many combinations with db_query,
geomnearest, geomRedef, xat/yat, buffer, geometry,
within , attribute (not all at the same time :) )....
I'm pretty sure it's possible but I can't find. And I
don't want to lose all my hair...<br>
</div>
<div><br>
</div>
<div>Does anybody know how I can retrieve in a line
shapefile's field the value of the point feature that
is the closest to the first vertex of this line,
within the field calculator?<br>
</div>
<br>
</div>
Thanks ...<br>
</div>
</blockquote>
</div>
<br>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
Qgis-user mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Qgis-user@lists.osgeo.org">Qgis-user@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="http://lists.osgeo.org/mailman/listinfo/qgis-user">http://lists.osgeo.org/mailman/listinfo/qgis-user</a></pre>
</blockquote>
<br>
</body>
</html>