1

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?

Taras
  • 32,823
  • 4
  • 66
  • 137
  • 2
    You 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 May 31 '21 at 20:26
  • @MrXsquared ahh I understand. Dang, thank you! – gisthisgisthat May 31 '21 at 20:32
  • 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 May 31 '21 at 20:46
  • @Babel Sorry, I don't quite understand. Could you explain a little more? – gisthisgisthat May 31 '21 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: https://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 May 31 '21 at 21:54
  • I suppose @Babel would agree that this topic https://gis.stackexchange.com/q/305165/99589 may be a good example of using a Virtual Layer – Taras Jun 01 '21 at 05:01
  • 1
    Of course I do, @Taras – Babel Jun 01 '21 at 05:45

0 Answers0