I'm using OS Codepoint With Polygons data set which provides shapefiles of each Postcode area within the UK. Within each postcode area are boundaries of individual postcodes.

I'm trying to merge these layers together to make another shapefile of our business boundaries that are made up from groups of postcodes.

From reading on here, it seems that I need to add a field to the Dbf file to name the business area that I want to 'dissolve' to and fill that field with the business area attributes.

Am I barking up the right tree here?


If I have understood your question correctly, you have a shapefile of your company's business areas information and you want to attribute your CodePoint polygons and the Postcode sub-areas with the attribute for your business areas. If so, you want to do a spatial join. This is like a normal database table join but instead of joining tables by some common id field, you join the tables based on the intersection/overlap of geometry.

In QGIS you can do a spatial join by: Vector->Data Management Tools->Join Attributes By Location.

That's the theory and will work nicely in ArcGIS. HOWEVER DO NOT DO THIS IN QGIS!

It will give us unreliable results (note to self - must log this bug!) because the criteria QGIS uses for joing the data is a simple intersection with no account of actual overlap. Technically polygons intersect if their boundaries merely touch. In QGIS, your only options for summarizing the attributes are either

  • Take attributes of first located feature
  • Take summary of intersecting features (mean, min, max, sum, median)

The second option is fine if you have numeric data. You have business district ids, so a mathematical summary makes no sense and that leaves you with the first option and here's the problem: Your postcode areas can easily (and frequently will probably) be contained by one business district but touch another one. If the one it touches is considered 'first' by QGIS then you will get the wrong attribute joined. (If a QGIS developer wants to reproduce this error create two shapefiles. One is a grid of several polygons each 100km square (say) and the second one is a grid covering the exact same area but the polygons are 20km square this time. Then join attributes by location from the big grid to the little grid and note the attribution of polygons along the edges - it will not be from the big polygon covering the little one, but from the neightbour in most cases).

Fortunately, attributes are transferred if you just do a normal intersect or union operation. So (until the QGIS bug is fixed) intersect your Business Districts withe your Postcodes: Vector->Geoprocessing Tools->Intersect No need to create an extra field first.

Given your comments below do this instead: 1) Merge all your shapefiles by Vector->Data management tools->Merge shapefiles to one (no need to load them first if they are all in one folder)

2) If you CSV has a simple format of (say) two columns where one is your postcode and the other is the business area code, then once you have merged the shapefiles you can do a simple table join (instead of a spatial join). Load the CSV file Layer->Add Vector Layer (NOT as delimited text). Then open the properties of your merged postcodes, click on the 'Joins' tab. Click the green + and specify your relationship between the CSV and the postcodes (i.e. your postcode field in each case)

  • Hi MappaGnosis. Thanks for such a comprehensive response - you're clearly very knowlegable. I'm slightly guilty that i didn't better articulate my question though. To clarify, I have the codepoint shapefiles that are split into 120 individual shapefiles, one for each postcode area. each shapefile contains every postcode within that postcode area as a feature. I want to combine these features into from postcode level to much broader business area levels. I have a csv file that lists what postcodes each business area is made up from. – GISNewbie Mar 8 '13 at 10:10
  • So i think what i need to do, is start a qgis project and load all 120 shapefiles into it and and somehow merge them together because for example my welsh business region will span CF (Cardiff) and SA (Swansea) postcodes. i hope i'm giving a better picture of what i need to do... – GISNewbie Mar 8 '13 at 10:16
  • I've edited my answer to reflect your comments – MappaGnosis Mar 8 '13 at 10:55
  • Hi MappaGnosis - Could i please bring this up again and ask more of your help please. I've just done the lookup table and the joins as you've prescribed in the response above. But when i try and use the intersect function to split the newly combined shapefile, it will only allow me to select the same layer as the input vector layer and the intersect layer. Am i missing something??? – GISNewbie Apr 30 '13 at 14:47
  • It could be the join - try making it permanent by saving the joined file with a new file name. However, I've misunderstood something obviously because I thought you were merging data not splitting it. – MappaGnosis Apr 30 '13 at 19:15

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.