[Qgis-developer] Retrieve value from another layer related to its localisation

Junior Delaz delazj at gmail.com
Thu Jan 15 02:19:04 PST 2015


Hi all,

I have two shapefiles : a line one (called "section") and a point one
(called "station") shapefiles.
The line shapefiles has fields like ID_section, ID_first, ID_last
The point file has an ID_station.
All these define a kind of network where a section begins on a station and
ends up at another station.
What I need to do is to fill :
- section ID_first field with the ID_station of the station that is the
closest to the beginning of the section
- and section ID_last field with the ID_station of the closest station to
the end of the line.

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.

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.
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...

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?

Thanks ...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20150115/80c7797d/attachment.html>


More information about the Qgis-developer mailing list