I'm working in QGIS with two shapefiles: point and line. Points mark nodes of the lines, and each of them have their own attributes. Lines are related to an attribute table too. The goal is, once the lines are exploded between nodes, to join ONE point attributes to each new line section. How can I join point attributes to each line section? (better not using any plugins, so I still cannot download them)
2 Answers
Try "join attributes by location".
Problem is, that the lines by definition have two nodes.
Without using any plugins... then only tool I can think of is a Virtual Layer.
Given:
- You have one
segments
layer (exploded line, and saved as a new line shapefile) - You also have one
points
layer. And the data you want to extract is stored in theyour_data
field ofpoints
layer.
(1) Go to menu Layer | Add Layer | Add/Edit Virtual Layer
.
(2) Click on [Import]
and select your segments
and points
layers.
(3) In the Query window, give an expression:
SELECT segments.*, points.your_data
FROM segments, points
WHERE st_intersects(st_buffer(st_startpoint(segments.geometry), 10), points.geometry)=1
Additional note -
- In the above example there is a
st_buffer(..., 10)
which is a tolerance radius(10m)
between your points and nodes of linestring. - If the points are located at the exactly same as nodes,
st_intersects(st_startpoint(segments.geometry), points.geometry)=1
would work just fine. - (and you may want to use
st_endpoint
rather thanst_startpoint
).
-
See the answer "Map1" at this link gis.stackexchange.com/questions/101459/… I think he'll point you in the right direction. Commented Jul 2, 2018 at 13:27
-
@Cyril um... I disagree to recommend PostGIS. Sergi's working environment does not allow downloading plugins, possibility of setting up PostGIS would be even less.– KazuhitoCommented Jul 2, 2018 at 13:48
-
What prevents the user to join the QGIS, PostgreSQL/PostGIS and solved using these tools and analytical tasks? Commented Jul 2, 2018 at 13:53
-
@Cyril If you think PostGIS is the right way to achieve solution, you can post it as your answer. We can support asker in various approaches. Only thing prevents the user to use any tool is their IT environment, not us.– KazuhitoCommented Jul 2, 2018 at 14:02
-
Thanks for your help, but now I am using ArcGIS to solve this problem. Which tool may I use now?– SergiCommented Jul 25, 2018 at 7:40