1

I joined a polygon layer to a point layer using a common field and then exported as a new layer. Just in case I first saved the geometry of the polygon layer (shape and area) in the table of attributes of the polygon layer. For some reason the resulting layer is not displayed at all in QGIS, not even at the wrong place. So I just want to tell QGIS to look for the polygon geometry in the common table of attributes so that the layer is displayed as polygons, not points.

Philippe Morgan
  • 633
  • 4
  • 11
  • 1
    what tool did you use to do the inital join? I don't believe QGIS will recognize a second geometry column in a layer. Its possible that you would need to create a second layer with a join that is the opposite of the first. – Hugh_Kelley Sep 16 '20 at 18:27
  • I used the regular join tool in the properties of the layer I wanted to join the other layer with. – Philippe Morgan Sep 16 '20 at 18:33
  • But I joined the polygon layer TO the point layer (for some specific reason I could not just do the opposite) but with its geometry attributes thinking that later on it would allow me to change this layer to a polygon one. – Philippe Morgan Sep 16 '20 at 18:35
  • I just opened up the properties> Joins menu and hit the + button. I don't see a way to include the geometry of the Join Layer. What do you think the field name of the polygon geometry is in the attribute table? Is the geometry stored as text like: Polygon(1.234, 5.678, ...)? – Hugh_Kelley Sep 16 '20 at 18:39
  • 1
    No I just used Vector/Geometry Tools/Add Geometry Attributes, then it added a layer called "shape" and another one called "area". I thought I could somehow use this to recreate the polygon shapefile afterwards, but obviously I was mistaken. I probably need to export as a .csv with wkt which seems to include geometry in the table. – Philippe Morgan Sep 16 '20 at 18:43
  • 1
    yeah that sounds like how I would do it. Alternatively, if you left joined a unique id from the polygon layer(right) onto the point layer(left), you can now join the data back to the polygons on that unique id and remove any polygon rows that didn't get data in the second join. . – Hugh_Kelley Sep 16 '20 at 18:51
  • My big issue is that I am trying to do a many to one join (join addresses, sometimes several addresses with the same parcel, with parcels, I have the same parcel identifier on both sides). Apart from doing a virtual layer (which made QGIS freeze in my case) I am not sure how to do that. If I merge addresses with polygons directly excess addresses will be deleted. I am thinking of doing the opposite, joining parcels with their polygon geometry to the address point layer (one to many, it seems to work) and then using the saved geometry to convert the layer to polygons. – Philippe Morgan Sep 16 '20 at 18:55
  • By the way I realized adding geometry attributes just add perimeter and area to the table, no wonder I could not do it. WKT is definitely the way to go. – Philippe Morgan Sep 16 '20 at 18:59
  • Have you tried creating spatial index? – ar-siddiqui Sep 16 '20 at 20:05
  • yes i had spatial indexes created for all layers – Philippe Morgan Sep 17 '20 at 15:27

2 Answers2

0

so I guess the answer is that an additional geometry column cannot be added to a layer in QGIS, geometry attributes are "Attributes" that describe the geometry, not the geom data itself.

Hugh_Kelley
  • 747
  • 1
  • 6
  • 19
  • No I think you can export to CSV and add a WKT here and then if you join with the WKT column included it should allow you to have a polygon layer. Well I am trying now, will let everyone know!

    https://gis.stackexchange.com/questions/23376/how-to-export-polygons-to-csv-with-coordinates

    – Philippe Morgan Sep 16 '20 at 19:19
0

To do this, before (or after but the file will be heavier) the join, export the join layer as csv file (save as CSV file) and select geometry as WKT. This way when you join the polygon layer to the point layer the polygon information is kept and you can then export as a CSV and reimport using WKT for coordinates (not sure if you can do this without first reexporting and then reimporting a CSV). This way, the layer can be displayed as a polygon layer even if it was joined to a point layer initially.

Save as CSV Layer and choose as WKT for geometry

Philippe Morgan
  • 633
  • 4
  • 11