Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors
podcast
Filter by Categories
ArcGIS Pro
GDAL
GeoJson
Map
Python
QGIS
Uncategorized

Polygon to points in QGIS

4 ways of Converting a polygon to points in QGIS

Converting a polygon to points in QGIS – t his can be useful for various analyses, such as sampling within polygons or simplifying complex geometries. There are several methods to achieve this, depending on your specific needs, such as creating points at polygon centroids, vertices, or at regular intervals within the polygon. Below, I’ll guide you through a couple of common methods using QGIS.

Working with QGIS? You should be listening to our podcast!

Method 1: Extracting Centroids

This method creates a point at the centroid of each polygon.

  1. Open QGIS and load your polygon layer.
  2. Go to the menu: Vector > Geometry Tools > Centroids.
  3. In the Centroids dialog, select your polygon layer as the Input layer.
  4. Choose where to save the output layer or just add it to the map as a temporary layer.
  5. Click Run, and then Close the dialog once the process completes.

You now have a point layer where each point represents the centroid of a polygon.

Method 2: Extracting Vertices

If you need points at every vertex of the polygons:

  1. Open QGIS and load your polygon layer.
  2. Go to the menu: Vector > Geometry Tools > Extract vertices.
  3. Select your polygon layer as the Input layer.
  4. Choose the output file location or add it as a temporary layer.
  5. Click Run, and then Close once done.

This method will create a point layer with points at every vertex of your polygons.

Method 3: Regular Points Inside Polygons

To create points at regular intervals inside polygons:

  1. Open QGIS and load your polygon layer.
  2. Go to the menu: Vector > Research Tools > Regular points.
  3. In the Regular points dialog, set your polygon layer as the Extent by clicking on the button with three dots and selecting Use layer/canvas extent.
  4. Specify the Point spacing and Number of points. You can also adjust the grid offset if needed.
  5. Choose the output file location or add it as a temporary layer.
  6. Click Run, and then Close once finished.

This will generate a point layer with points distributed at regular intervals within your polygons. Note that this method may create points outside the polygons if the entire extent of the polygon layer is used. To avoid this, you can use the Clip tool (under Vector > Geoprocessing Tools) to clip the points layer with your original polygon layer, ensuring that only points within the polygons are retained.

Additional Tips

  • The Geometry by expression tool (under Vector > Geometry Tools) can also be used for more complex point generation tasks, allowing you to use expressions to define exactly where points should be placed.
  • For specific analyses, consider what type of point representation best suits your needs: centroids for representing the “center” of polygons, vertices for detailed boundary representations, or regular points for sampling or distribution analyses within polygons.

Remember to save your work and the newly created point layers to avoid losing data.

Method 4 : Convert Polygon to Points Using “Convert Geometry Type”

  1. Open QGIS and ensure your polygon layer is loaded into your project.
  2. Navigate to the Processing Toolbox. You can open it by going to the menu: View > Panels > Processing Toolbox. Alternatively, you can press Ctrl+Alt+T on your keyboard.
  3. In the Processing Toolbox, search for Convert Geometry Type. You can find it under Vector geometry.
  4. Double-click on Convert Geometry Type to open the tool’s dialog.
  5. In the tool dialog, set the following options:
  • Input layer: Choose your polygon layer from the dropdown menu.
  • Geometry type: Select Nodes. This option will convert your polygons to points. Depending on your QGIS version, you might need to select the specific point geometry type (e.g., Point (single) for single points or another option if you’re aiming for multi-points or a specific CRS).
  1. Choose where to save the output layer or add it as a temporary layer by leaving the Save to file option unchecked.
  2. Click Run to start the conversion process. Once the process completes, you will see the new point layer added to your project.

Important Considerations

  • What Points Represent: The “Convert Geometry Type” tool will generally create points based on the input geometry’s vertices. For polygons, this means you’ll get points at every corner or bend in the polygon boundary. This is different from extracting centroids or creating points at regular intervals inside polygons.
  • Attribute Data: One of the benefits of using the “Convert Geometry Type” tool is that the resulting point layer retains the attribute data from the original polygon layer, making it easy to maintain data continuity.

The “Convert Geometry Type” tool offers a straightforward way to transform your data between different geometrical representations in QGIS, making it a valuable tool for various GIS tasks and analyses.

Here are some frequently asked questions:

What’s the difference between converting polygons to centroids and converting them to vertices?

Converting polygons to centroids and converting them to vertices are two different processes in GIS, each serving distinct purposes and resulting in different types of point data. Here’s a breakdown of the differences between these two methods:

Converting Polygons to Centroids

  • Process: This method involves calculating the geometric center (centroid) of a polygon and creating a point at that location. The centroid is the average position of all the points that make up the polygon, effectively serving as the “center of mass” of the polygon.
  • Result: Each polygon is represented by a single point, regardless of the polygon’s size, shape, or complexity. This means that a complex, irregularly shaped polygon and a simple square polygon will each be represented by one point located at their respective centers.
  • Use Cases: Centroid points are useful for simplifying spatial data and for analyses where a single point representation is sufficient to represent the location of a polygon. Examples include mapping the center locations of administrative areas, land parcels, or other features where a central point is needed for labeling, analysis, or visualization.
  • Attribute Data: The attribute data of the original polygon is typically preserved in the centroid point, meaning that each centroid point retains the attributes of the polygon it represents.

Converting Polygons to Vertices

  • Process: This method involves creating a point at every vertex (corner) of the polygon. Vertices are the points where two sides of a polygon meet, and every polygon is defined by a series of these vertices.
  • Result: A polygon is represented by multiple points, with the number of points corresponding to the number of vertices the polygon has. This means that more complex polygons with many sides will result in more points compared to simpler polygons.
  • Use Cases: Vertex points are useful for analyses that require detailed boundary information or for operations that involve the manipulation or examination of polygon edges. Examples include creating a detailed point map of a geographic feature’s outline or conducting spatial analyses that require interaction with the specific points defining a polygon’s boundary.
  • Attribute Data: Each vertex point inherits the attributes of its parent polygon. Since a single polygon can produce multiple vertex points, this means that the attribute data will be duplicated across multiple points, each corresponding to a vertex of the original polygon.

Key Differences

  • Representation: Centroids provide a simplified, single-point representation of a polygon, useful for general location purposes. Vertices offer a detailed, multi-point representation that captures the boundary and shape of the polygon.
  • Number of Points Generated: Converting to centroids results in one point per polygon, while converting to vertices produces a point for each vertex of the polygon, leading to a potentially large number of points for complex shapes.
  • Use Case: The choice between centroids and vertices depends on the intended analysis or visualization. Centroids are chosen for simplicity and a central representation, while vertices are selected for detailed boundary analysis and shape representation.

Understanding these differences is crucial when deciding how to convert polygon data to points in GIS, ensuring that the chosen method aligns with the objectives of your analysis or visualization project.

Can I automate the conversion process for multiple polygon layers to multiple point layers?

Yes, you can automate the conversion process for multiple layers or large datasets in QGIS, which is particularly useful for batch processing or when working with extensive spatial data. QGIS provides several ways to automate tasks, including the use of the Graphical Modeler, Batch Processing, and scripting with the Python console (PyQGIS). Here’s how you can leverage these features for automating the conversion of polygons to points or other repetitive tasks:

1. Graphical Modeler

The Graphical Modeler allows you to create custom workflows by combining multiple processing tools. You can access it via Processing > Graphical Modeler. Within the modeler, you can define inputs and a series of operations (like converting polygons to centroids, vertices, or random points) that apply to those inputs. Once your model is built, you can run it on multiple layers or datasets by selecting them as inputs, effectively automating the process.

  • Advantage: User-friendly interface for creating complex workflows without writing code.
  • Use Case: Automating the conversion of multiple polygon layers to their centroids or vertices while preserving attribute data.

2. Batch Processing

Many tools in QGIS, including those for converting geometry types, support batch processing directly. This feature allows you to apply the same operation to many layers at once.

  • To access batch processing, either right-click on the tool in the Processing Toolbox and select “Execute as Batch Process,” or open the tool and click on the “Run as Batch Process” button (if available).
  • In the batch processing window, you can add multiple rows for each layer you wish to process and specify individual parameters and output settings for each.
  • Advantage: Straightforward for running the same tool on many layers without creating a model.
  • Use Case: Converting several polygon layers to point layers (e.g., centroids or vertices) in one operation.

3. Scripting with PyQGIS

For more advanced automation and flexibility, you can use the Python console in QGIS or create standalone scripts using PyQGIS, QGIS’s Python library. This method allows you to automate virtually any task in QGIS, including complex data processing and analysis workflows.

  • Access the Python console in QGIS via Plugins > Python Console.
  • You can write scripts to loop through layers in your project, apply conversion processes, and even integrate conditions or additional processing steps.
  • Advantage: Maximum flexibility and control over the automation process.
  • Use Case: Automating complex workflows, such as converting polygons to points with specific attributes or conditions, processing the data further, and then exporting the results.

Example PyQGIS Script

Here’s a simple example script that you could adapt for converting polygon layers to centroids (assuming you have a basic understanding of Python and PyQGIS):

from qgis.core import QgsProject, QgsProcessingFeatureSourceDefinition, QgsProcessingParameterFeatureSink
import processing

# List all polygon layers in the project
polygon_layers = [layer for layer in QgsProject.instance().mapLayers().values() if layer.geometryType() == QgsWkbTypes.PolygonGeometry]

# Loop through polygon layers and convert each to centroids
for layer in polygon_layers:
    parameters = {
        'INPUT': layer,
        'ALL_PARTS': True,
        'OUTPUT': 'memory:'  # Use 'memory:' for temporary layer or provide a file path to save
    }
    result = processing.run("native:centroids", parameters)
    # Add result to the map (optional)
    QgsProject.instance().addMapLayer(result['OUTPUT'])

This script gets all polygon layers in the current QGIS project, converts each to a layer of centroids, and adds the result to the project.

About the Author
I'm Daniel O'Donohue, the voice and creator behind The MapScaping Podcast ( A podcast for the geospatial community ). With a professional background as a geospatial specialist, I've spent years harnessing the power of spatial to unravel the complexities of our world, one layer at a time.