I'm relatively new to QGIS and have been using it for a project related to gerrymandering and electoral redistricting. My apologies if the question may seem a bit novice.

I have two layers that I've imported into QGIS: One with the boundaries of all zip codes in Virginia and one with all electoral precincts in Virginia. The precinct file also included a column for cluster which notes that electoral district a precinct is in. I used GDAL Dissolve polygons to dissolve the precincts up into the associated cluster/district as shown below:

Dissolved Map After importing the zip code layer, I used Joins to attach data to the zip code attribute table, matching based on the zip code identified (labelled ZCTA5CE00). The joined table looks like this:

enter image description here

One of the columns I attached to the open attribute table for the zipcode layer is idealpnum2.

I want to do a spatial join using "Join Attributes by Location" to map the zipcodes onto the cluster/district layer and get an average idealpnum2 for each cluster/district. The layers do not match perfectly and district/cluster boundaries cut through zip codes in several places. Is this possible?

When I've tried to do this using the dissolved cluster/district layer as the target vector layer and the zipcode layer as the join vector layer, it returned a joined layer with an attribute table that was null for everything. . In the pictures below, I had first went into the zip code layer and changed the CRS to EPSG:4326 so that it had the same CRS as the dissolved cluster/district layer.

enter image description here

enter image description here

I also tried to run it without changing the CRSs and instead "forcing" it through. Did not work there either.

Does anyone know what I should be doing differently here? Is it even possible?

  • Welcome to GIS:SE @ChristianConroy! When setting the CRS for a layer correctly, you will need to resave the layer by right-clicking the layer, selecting the Save As... option, select the relevant CRS and save it as a new shapefile. Then try running the join tool again :) – Joseph Jan 22 '18 at 10:38
  • Thanks for the suggestion! However, when I try to do so, I end up with the error message: Export to vector file failed. Error: creation of layer failed (OGR error:Failed to create file crsclipped.shp: Permission denied). Do you know why that might be happening? – Christian Conroy Jan 22 '18 at 13:40
  • Actually fixed that issue but still having null returned for everything when I use the newly saved layers with the CRSs adjusted to match. – Christian Conroy Jan 22 '18 at 19:17

Your Answer

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

Browse other questions tagged or ask your own question.