I have two layers: 'linear' – road network and 'point' – points in each linear features intersections.
Point layer have in attribute table name for each point features: A,B,C,D,E,F, etc.
How add in point layer names of nearest points of road network?
For example:
for point A in attribute table should be attributes B,E;
for point B in attribute table should be attributes A,C;
for point C in attribute table should be attributes B,D;
for point D in attribute table should be attributes C,H,N,I;
In QGIS using Distance Matrix possible similar task, but there is "nearest distance", not road network.
I think it's done in PostgreSQL/PostGIS, but don't find solution.
Thanks!
Best Answer
Read point data for closest road in PostGIS:
cp alias should have one closest road for every point, WHERE ST_Dwithin(geom,geom) < 1 should make search faster
Little closer answer is (in PostGIS)
That returns roads rows several times if there are more than one intersection on road
Solution A
Return only one row per road (i'm not 100% how crosstab works)
Or use LEFT join on road id. There is several ways to do it
Should create new table which has road geoms, gid and name from point table. There should not be any dublicate r.gid + p.name rows. In QGIS you can define label field from database (assuming that you have PostGIS source) from Layers properties.
You may need to use first answer if your data does not intersect.
Closest point on road in PostGIS is
Above should return point geometry on road which is closest to point on point table which is closest to road.