Saturday 24 November 2018

Removing small "salt & pepper" polygons from layer in QGIS?


I have a map made up of multiple polygons, with a few hundred thousand points very small polygons on within it.


I need the larger polygons, but not the points small polygons. How do I select and remove all the points small polygons, while preserving the larger polygons? (I obviously do not want to do this manually - there are a few too many points for that!)


I'm totally new to QGIS, and I've Googled extensivey with no luck. Probably because I'm unsure what the correct terminology to use in a Google search is!


The files I am using are a .dbf, .prj, .qpj, .shp and .shx. I'm simply dragging the .shp file on to QGIS, and the map appears as one layer. Basically a map of the UK divided into regions (which I want) and covered in points (which do not want).


map view table view


This is what it looks like up close. I did a dissolve to see if they'd go in to the surrounding layer, with no luck:



close-up view of polygons



Answer



It seems like you're working with Ordnance Survey Code-Point data, which is a dataset of the postal code areas in Great Britain and Northern Ireland.


The "points" you're referring to are small square polygons that represent so-called "vertical streets": stacks of more than one post code, which can't be represented using "conventional" polygons (see Andy Harfoot's comment for more details). You might want to think twice about removing these polygons if you need the affected postal codes for your analysis.



That said, here's how you can remove these polygons:




  1. Select all vertical street polygons by clicking "Select Features Using an Expression" and entering "POSTCODE" LIKE 'V%'. This will select all features that have a postal code starting with V, which are the vertical streets.






  2. Simply deleting the features won't help, since the polygons will leave holes behind, as you have already noticed. Instead, you can merge the vertical streets with a neighbouring large polygon using "Vector / Geoprocessing tools / Eliminate sliver polygons", saving the result to a new file.





  3. You may get the warning message that some features could not be dissolved, together with a list of feature ID's. If you also want to get rid of these features, select the vertical streets in the new layer using the expression from before, and then do one of the following:




    1. If you want an automatic solution, you can dissolve the vertical streets togehter with all neighbouring polygons. Save the selection to a new layer using "Layer / Save selection as vector file", and then use "Vector / Research Tools / Select by location" to select features in the merged layer that intersect with the offending vertical streets, creating a new selection. Then dissolve this selection using "Vector / Geoprocessing Tools / Dissolve", choosing --- Dissolve all --- in the "Dissolve field". Note that this approach can lead to the undesired dissolution of "proper" polygons if the offending vertical street is on the boundary of two other polygons, or if there are offending vertical streets within two neighbouring polygons.





    2. If you want to avoid dissolving other polygons, you can manually select the vertical streets and one adjacent polygon, taking care not to select two neighbouring polygons, and then dissolving them as above.






No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...