I have three adjacent polygons that together make up a larger shape. I need an algorithm that will dissolve the internal borders leaving only the outside border. An example would be a group of adjacent counties. I want to merge together all the county polygons and dissolve the internal borders so I'm left with just the outline of the state.
[GIS] Looking for dissolve algorithm for Javascript
algorithmdissolvejavascriptpolygon
Related Solutions
You can speed up the manual clean up process a bit by creating a virtual field on your final layer and populating it with the area of each feature ($area in field calculator). Then sort the attribute table by this field. You will probable find lots of records at the top with zero or close to zero areas, and these can be deleted quickly from within the attribute table. Do a visual scan to determine at around what area the'real features' begin, and delete all the smaller ones.
It's a multi-step process, so you should create a custom model or script. In order to avoid slivers of polygons that belong to neighboring polygon points, you'll need to iterate through your states layer. Working with state polygons and a set of random points, I'll go through the process so that you can understand what's going on inside our model.
Inside the Model
- Extract by location
- Extract features from:
points_layer
- Where the features:
intersect
- By comparing to the features from:
polygons_layer
- Extract features from:
- Voronoi polygons
- Input layer:
'Extracted (location)' from algorithm 'Extract by location'
- Buffer region:
500
(It seems excessive, but we want to ensure that your Voronoi polygons completely cover the state they're in. Since we'll clip this layer in the next step, it's irrelevant how big we make this.) - Parent algorithms:
Extract by location
- Input layer:
- Clip
- Input layer:
'Voronoi polygons' from algorithm 'Voronoi polygons'
- Overlay layer:
polygons_layer
- Clipped:
output
- Parent algorithms:
Extract by location
andVoronoi polygons
- Input layer:
As you can see, we have our state-constrained Voronoi polygons in which points from neighboring states do not affect their arrangement.
Here's an image of the model:
The image doesn't convey this, but note that the polygon layer input of the model is a Vector Features
object, not a Vector Layer
.
Running the Model
When you go to run your model it is vital that you click on the icon to iterate through the features of your States layer.
Once you've run the model, you can simply run Merge vector layers on the outputs to get a single-layer output, if that is important to you. Unfortunately, I'm not aware of an easy way to merge multiple model outputs within the model itself (please, someone correct me if there is something).
If you're comfortable with Python, you can easily modify the exported script of this model to handle that additional step. As you did not mention code-based solutions in your question, however, I will leave that out.
Best Answer
This is a pure Javascript api that performs Dissolve, also commonly called Union, and other spatial operations. It is based on Java Topology Suite. jsts