26

I'm currently using building data from the Ordnance Survey Vectormap District and I've noticed that a lot of building polygons are split in 2 because of the way the OS split up the shapefile.

This is what I'm seeing in QGIS – I've highlighted some of the buildings split at the tile boundary:

enter image description here

I can't manually merge the buildings as there are way too many of them that have been split at the boundaries (this is just a zoomed in example). I'm looking for an automated way to solve this.

Unfortunately, each side of the split buildings has a different id so I can't easily dissolve them.

How would you suggest I can automatically merge the building tiles?

Edit

I'm now using PostGIS to merge the polygons split at the tile boundaries. Here is the SQL statement that does this for me – it's many, many times faster than doing it with QGIS:

DROP TABLE merged;
CREATE TABLE merged AS
SELECT
  -- Merge polygons that are within 0.01 metres of each other
  (ST_Dump(ST_Union(ST_Buffer(the_geom, 0.01)))).geom AS the_geom
FROM unmerged;

-- Update the geometry_columns table
SELECT Populate_Geometry_Columns();
1
  • 7
    You should probably post your solution as an answer and accept that instead of mine. Sticking with the question-answer scheme makes it much easier for others with the same issue to find the solution.
    – Jake
    Feb 8, 2013 at 15:05

1 Answer 1

19

If you simply want to dissolve the edges and are happy with having one large multipolygon feature of all buildings, you can simply use the fTools "Dissolve" tool ("Vector/Geoprocessing/Dissolve").

If you want to keep the attributes (in the case of OS Vector that would only be the ID, which seems to be rather arbitrary), you can split the dissolved vector layer and then assign the attributes of the original undissolved layer using "Join attributes by location":

This is a subset of two OS buildings shapefiles that were merged into a single shapefile using "Vector/Data management/Merge shapefiles into one". The colours are assigned randomly to show the individual features:

This is the result of the "Dissolve" tool: All features have been dissolved into a single feature with the ID of the first object, the break in the three central buildings is gone:

After splitting the feature using "Vector/Geometry/Multipart to singleparts", the buildings are individual features again, but they all have the same ID:

Running "Vector/Data Management tools/Join attributes by location" with the split layer as the target and the original merged layer as the Join vector layer, the buildings are reassigned their individual IDs:

7
  • I think the problem might be that this is OS VMD OpenData (correct me if I'm wrong). In which case the features don't have attributes that can be used for dissolving. So you might as well try using the ordinary fTools dissolve. Good luck with this, in some OpenData vectors I've got polygons split by lines that coincide with grid lines that just won't dissolve.
    – nhopton
    Feb 7, 2013 at 18:48
  • @nhopton: But the ordinary fTools dissolve will lump all features into a single feature (if there's no IDs that can be used to identify which features belong together, as is the case here), which is most likely not what Rob wants. If you use v.dissolve after assigning all features some identical dummy attribute, only those that share a boundary will be merged together.
    – Jake
    Feb 7, 2013 at 19:02
  • A single feature probably wouldn't be a problem for Rob, if all he was after was the shapes. But yes, try both methods of dissolving. Nick.
    – nhopton
    Feb 7, 2013 at 19:25
  • Are you sure that all of the polygons that ought to have been dissolved have in fact been dissolved? Here most of them dissolve, but not all of them.
    – nhopton
    Feb 7, 2013 at 20:32
  • Thanks for the help! It turns out @nhopton was right and that the VectorMap District splits are actually a little off and so aren't dissolving correctly. I'm now experimenting with using PostGIS to speed this process up. Feb 8, 2013 at 12:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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