I have two shapefiles:
- one with various points of Hospitals across Los Angeles
- another of the LA census tracts.
I want to merge the two layers together to create one layer with all of that data together. I want to be able to click on individual tracts on the map and see that tract's info, as well as be able to click on the points inside that are contained within the tract (as well as be able to click on those points).
I am using QGIS. I'm not sure what the right move is.
How can I do this?
asked May 31, 2021 at 20:12
-
2You can not merge points and polygons that way in one layer. You can only join them by 1:n where 1 is a polygon with n points aggregated (array, concatenated string, sum, mean, ... of the point attributes) or by joining 1:1 where each point gets the values of the polygon it is covered by. Which of these two options do you prefer?MrXsquared– MrXsquared2021年05月31日 20:26:55 +00:00Commented May 31, 2021 at 20:26
-
You don't even have to join - a spatial query would do the job. You could create a virtual field (attribute) based on such a query or a virtual layer.Babel– Babel2021年05月31日 20:46:25 +00:00Commented May 31, 2021 at 20:46
-
@Babel Sorry, I don't quite understand. Could you explain a little more?gisthisgisthat– gisthisgisthat2021年05月31日 21:42:20 +00:00Commented May 31, 2021 at 21:42
-
Well, you could use QGIS expressions to create a virtual field that calculates dynamically a spatial relationship between two layers like every point should get the attribute information from the polygon it is inside. See here for an example, where the point-layer gets an information from the line layer the points lay on: gis.stackexchange.com/a/398092/88814 - If the field is a virtual one (create it with field calculator), the content will update when you make changes. Virtual layers offer a similar way, but with SQL-like queries.Babel– Babel2021年05月31日 21:54:19 +00:00Commented May 31, 2021 at 21:54
-
1Of course I do, @TarasBabel– Babel2021年06月01日 05:45:24 +00:00Commented Jun 1, 2021 at 5:45