Skip to main content
17 votes

How to speed up raster to polygon conversion in R?

There is a "new" method from the stars package, which revolutionized the workflow for me (I was using the gdal_polygonizeR function previously). It has been faster than the John Baumgartner solution ...
Mikko's user avatar
  • 374
9 votes
Accepted

Convert a group of lines into a single polygone to style it

If you need to handle the polylines just for styling, you don't need to manipulate the geometry. E.g. you want to get rid of overlapping edges at a street intersection, you can to this by activating "...
Greg Z's user avatar
  • 827
9 votes
Accepted

Cannot select input layers for the "Polygonize" tool in QGIS

When you search for Polygonize in the Processing Toolbox, there appear several tools. 1) Polygonize tool converts line layer to polygon layer, turning an area inside three line segments into a ...
Kazuhito's user avatar
  • 31.2k
8 votes
Accepted

Polygonizing a raster yields lots of little squares?

The reason for this is that while you see yellow pixels, or pink pixels, QGIS sees thousands of discrete colours Zoom in really close to scanned map you'll see lots of noise - neighbouring pixels ...
Steven Kay's user avatar
  • 20.6k
8 votes

Converting raster to vector and creating polygons based on each pixel in QGIS

Yet another option would be SAGA Raster values to points tool (QGIS Processing Toolbox | SAGA | Vector <-> raster). Choose [1] cells as Type option. SAGA - Raster values to points note white ...
Kazuhito's user avatar
  • 31.2k
8 votes
Accepted

Divide a polygon into multiple small polygons using a MultiLineString

You may not need to use this MultiLineString variable for what you aim at. This works: from shapely.geometry import Polygon, LineString from shapely.ops import linemerge, unary_union, polygonize poly ...
julien's user avatar
  • 10.3k
7 votes

Converting polyline to polygon in QGIS

Just a hint if you can't find the Polygonize tool. In my QGIS 2.18.3 installation (Windows) I could not find the Polygonize tool at Vector geometry tools within the Toolbox. It took me some time to ...
Nicolo's user avatar
  • 340
7 votes
Accepted

Create polygons (representing boundaries) from lines

Starting with nc borders from the example(st_read) code, I'll first make a set of lines like in your data and then put them back together again. So we start with 100 North Carolina polygons in a ...
Spacedman's user avatar
  • 66.5k
7 votes
Accepted

How to apply GDAL polygonize?

I downloaded the dataset you linked to and tested with the following script- it works ok for me. In the following script, I left my own paths in for reference but you should of course change them to ...
Ben W's user avatar
  • 23.1k
7 votes
Accepted

How to extract the boundaries of Shapely MultiPoint?

For a grid-like multipoint, you can use buffer method to get the boundary of points as a polygon. For a multipoint geometry with 100 meters between each point as in the image, the following script ...
Kadir Şahbaz's user avatar
6 votes
Accepted

Convert multiple polylines to polygons in QGIS

Using QGIS processing: v.clean [snap] Polyline test The threshold is determined by attempts: final results To get the polygons: polygonize polygons
pigreco's user avatar
  • 4,520
6 votes
Accepted

sf lines to polygons with holes

The problem is that you have created a GEOMETRYCOLLECTION which can be an unstructured set of linear features, in other words there's no concept of holes and islands. What you want is a MULTIPOLYGON....
Spacedman's user avatar
  • 66.5k
6 votes
Accepted

Vectorize raster

I found a solution using USGS landcover dataset and gdal_sieve . The raw dataset looks like this: And using gdal_sieve led to that: Which is exactly what I wanted :) . Now I "just" have to choose ...
Tim Autin's user avatar
  • 604
6 votes
Accepted

Transforming line into polygon with Geometry Generator

Let's assume there is a polyline layer "line", see image below. Proceed with RMT > Symbology > Single Symbol > Line > Geometry Generator Use the following code make_polygon($...
Taras's user avatar
  • 34k
6 votes
Accepted

Merging cluster of points into polygons

This will work when each cluster has an attribute that defines it. If there is no such attribute, you can achieve it using the "DBSCAN clustering" geoalgorithm. Clusters point features ...
Taras's user avatar
  • 34k
6 votes
Accepted

How to polygonize raster with range of values?

What you want to do is the re-classify the raster before polygonizing. You can GRASS tool r.recode for that (available in QGIS). For a solution with raster calculator, see below. Using GRASS r.recode ...
Babel's user avatar
  • 74.9k
6 votes
Accepted

"UnicodeDecodeError: 'utf-8' codec can't decode byte 0x82 in position 85: invalid start byte" error when polygonizing WMS in QGIS

You cannot polygonize a WMS layer with QGIS. As you can see from the generated gdal_polygonize command, the name of the input raster is obscure. "crs=EPSG:3857&dpiMode=7&format=image/png&...
user30184's user avatar
  • 69k
5 votes

Converting polyline to polygon in QGIS

I had the same unwanted output and after doing some research it seems the cause can vary. My case was I had some polyline layers with very, very small gaps (in which some fragments were formed by two ...
Andre Silva's user avatar
  • 10.3k
5 votes

Converting polyline to polygon in QGIS

If the polylines overlap each other, Polygonize tool cannot handle it as follows: However Lines to polygons tool works as expected as follows:
RezaNikfal's user avatar
5 votes

Gdal Polygonize, empty attribute table

Found out that the reason the attribute table was empty was due to gdal.Polygonize( band, None, outLayer, -1, [], callback=None ) Updated it to gdal.Polygonize( band, None, outLayer, 0, [], ...
Maarten's user avatar
  • 81
5 votes
Accepted

Smoothing raster with binary cell values

Similar to what @WhiteboxDev suggested, another filter type that could be used is a sieve filter. Instead of looking at whether the 0s or 1s "win" for a given region, it looks at the number of ...
Mikkel Lydholm Rasmussen's user avatar
5 votes

Smoothing raster with binary cell values

In addition to the use of a majority filter, there is another alternative approach that I will list below. This approach is more involved than simply filtering the raster and should only be used when ...
WhiteboxDev's user avatar
  • 11.1k
5 votes

Extracting polygons from scanned GeoRef images based on colours in QGIS

You can get pretty close with: "Raster calculator". The turquoise areas have a red band value of about 100-120 (in my downloaded copy of your raster) the other colors a lot less or more, I ...
Bera's user avatar
  • 77.8k
5 votes

QGIS - How do I select features in a particular location precisely, the location is a raster

Open the Raster calculator tool and use this expression to create a mask, "layer@band" != no-data. Replace layer with the name of your raster, band with the number of your band and no-data ...
Mayo's user avatar
  • 4,050
5 votes
Accepted

Polygonize error

I could re-produce the error with QGIS 3.35, installed with OSGeo4W. The command log shows that with the default setting QGIS tries to save the polygonozed result into an Interlis 2 file. This format ...
user30184's user avatar
  • 69k
4 votes

Convert a group of lines into a single polygone to style it

If the symbol levels don't work for you (not sure when it was implemented), you can simply duplicate the layer, style the first with 1mm red, and the second with 2mm black: The order in the legend ...
AndreJ's user avatar
  • 77.1k
4 votes
Accepted

QGIS 2.18 Polygonize (raster to vector)

As you have deduced already the QGIS polygonize utility is a GUI for GDAL_Polygonize which briefly explains the use of a mask: -mask filename: Use the first band of the specified file as a validity ...
Michael Stimson's user avatar
4 votes
Accepted

Batch Polygonize rasters into shp file using gdal_polygonize.py but no result?

As said by Michael Stimson from the comments, here's the answer for my own question: import subprocess, glob script = "/usr/bin/gdal_polygonize.py" for raster in glob.glob("/data/brent/GAUP/Jul21_17-...
brentiemapper's user avatar
4 votes

Converting raster to vector and creating polygons based on each pixel in QGIS

Alternatively you can do it directly with OpenJUMP Plus. Open your raster as a Sextante raster layer and use this tool As a result you'll get a polygon layer that contains the pixel values as ...
user30184's user avatar
  • 69k
4 votes

Converting raster to vector and creating polygons based on each pixel in QGIS

Since QGIS 3.4 there is an algorithm called "Raster pixels to polygons". You can find it in the Processing Toolbox -> Vector creation -> Raster pixels to polygons For more details ...
Francisco Puga's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible