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:
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();
Answer
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:
No comments:
Post a Comment