for a current project I want to connect nation-wide PV-modules (photovoltaic modules) to power grid nodes via zip codes and their respective power demands. For this reason, I downloaded QGIS as I was told it is the easiest way to achieve this result.

So far, I have been able to import grid nodes and lines into QGIS as point/line layer respectively. Also, I imported a map showing all the different zip codes as polygons. So far this worked wonderfully.

In a first step, now I want to import installed PV capacities, a dataset of which I don't have precise coordinates but rather their zip-codes.

Is it possible to import this *.csv dataset and have it distribute to the different zip codes?


1 Answer 1


You can use a Virtual Layer.

Drag and drop your csv file to the map and add the polygon layer.

Then join them together based on the zip code fields and fetch the polygon centroid geometry from the polygons. (I had to use TRIM function because of whitespaces which I couldnt get rid of).

You will have to adjust the table and column names below to match your data:

select ziptable.*, --select all fields from the csv
st_centroid(zip_polygons.geometry) as geometry --Join a point geometry from the polygons
from ziptable
join zip_polygons
on ziptable.zipcolumn = zip_polygons.zipcode --Join by these fields

Then you can right-click the virtual layer and export/save it.

enter image description here

  • 1
    That seems to have worked just fine, thank you! Although the sheer amount of them puts quite some stress on the program, I will have to work with that.
    – Titan
    Mar 19 at 15:42
  • Nice! Export the virtual layer to a geopackage or some other format and delete the virtual layer, they can be very slow
    – BERA
    Mar 19 at 15:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.