Point coordinates to polygon – part I

Articles about field studies sometimes (but not always unfortunately) contain coordinates delimiting the boundaries of the field study. What if you want to view those boundaries in e.g., Google Earth? In other words, how to create a polygon layer based on point coordinates? Let’s explore some ways to do this in QGIS. Note that all plug-ins mentioned below are either part of the QGIS core, or can be downloaded with the plug-in manager.

First step is to convert those coordinates to a point file. The easiest way, I think, is to simply enter the coordinates in a spreadsheet, especially if the coordinates come in DM (degrees and minutes) or in DMS (degrees, minutes and seconds). For the examples below, I am assuming you have already entered the coordinates in a spreadsheet, and converted to decimal degrees.

Step 1. Coordinates to a vector point layer

The next step is to convert your spreadsheet to a point file. In QGIS you have two easy options, the Add delimited text layer plug-in or the XY tool plug-in.

Add delimited text layer

Save your spreadsheet as a comma delimited text file (csv) Then, use the ‘Add delimited text layer’ plug-in (see Figure 1) to create a point layer. Note that if you want to keep the point layer, you need to save it.

Figure 1. Add delimited text layer' plug-in

Figure 1. Add delimited text layer’ plug-in

XY tool

With the XY tool, you can import the spreadsheet directly. The tool supports both Excel and Libre/OpenOffice spreadsheets. If installed, you can find the plugin under the Vector menu. As you can see, the plugin includes various options for import and export of attribute tables.

Figure 2. XY tool

Figure 2. XY tool

Step 2. Point to polygon file

Depending on the desired output, there are various options to convert a point file to a polygon file.

Delaunay triangulation

The Delaunay triangulation polygons can be created with the function of the same name under menu Vector | Geometry Tools. Note that the order of the points is not important as all points are connected to each other. The result shows all borders possible by connecting the given points.

Figure 3.  Delaunay triangulation polygon

Figure 3. Delaunay triangulation polygon

Convex hull

The Convex hull can be created with the function Convex hull(s) under the menu Vector | Geoprocessing tools | convex hull). It is the smallest convex set containing all points. You can see it as a rubber band wrapped around the “outside” points. This makes this function suitable if you have only two points (of the diagonally opposing corners of a rectangle).

Figure 4. Convex hull polygon

Figure 4. Convex hull polygon

Points2One plugin

To capture irregular areas, you need (1) ordered points, and (2) a way to connect these points to a boundary. The first part, you will have to take care of – the tool assumes that the points are ordered. The second part can be done by the Points2One plug-in.

Figure 5. Opening the Points2One addon

Figure 5. Opening the Points2One addon

Figure 6. A polygon created with the Points2One plugin, which was used to convert the 5 boundary points to a polygon

Figure 6. A polygon created with the Points2One plugin, which was used to convert the 5 boundary points to a polygon

The figure below shows what happens if your points are not in the right order.

Figure 7. A polygon created with the Points2One addon, based on 6 boundary points. It shows what may happen when the boundary points are not ordered.

Figure 7. A polygon created with the Points2One addon, based on 6 boundary points. It shows what may happen when the boundary points are not ordered.

SAGA

Another way to do this is using SAGA GIS. SAGA is available from within QGIS via the Sextante toolbox. Unlike the methods above, you need an intermediate step, in which you convert the points to a line. This line is in turn converted to a polygon.

You can convert the points to a line vector layer with the Convert points to line function. As you can see in the screenshot below, you’ll need to add an extra column to your table to populate the field Separate by…. This will tell SAGA which points form a line together. This allows you to create multiple lines. However, in our case, we want all points to be connected by one line only. So you need to add a column and fill all rows with the same value (e.g., 1).

Figure 8. The Convert points to line function menu in the Saga module of the Sextante toolbox

Figure 8. The Convert points to line function in the Saga module of the Sextante toolbox

Figure 9. Convert lines to Polygon function in the SAGA module of the Sextante toolbox.

Figure 9. Convert lines to Polygon function in the SAGA module of the Sextante toolbox.

Step 3. Save the layer

And the last step is the easiest… save the layer in whatever format you like. You want to check out the location of the study area in Google Earth? Save the polygon as a kml file and you should be good to go.

See here a post how to do this in GRASS GIS.

About these ads

8 thoughts on “Point coordinates to polygon – part I

  1. Nick

    How would you do this if you wanted to create a hundred polygons at once? I have a spreadsheet with 100 polygons (each has x,y coordinates for all 4 corners) and I need them as 1 shape file with 100 separate polygons within it.

    Thanks for all the tutorials so far though, they’ve been a huge help for me with GIS!

    Reply
      1. Nick

        I actually ended up using the plug in points 2 polygon (i believe) and as long as each set of points had a unique ID you could bring them in together. Thanks for the reply though

    1. pvanb Post author

      I don’t have Google Earth Pro, but I would open the kml file in QGIS, follow the steps outlined to get a polygon layer, and save the result back as kml.

      Reply
  2. Jeff

    Thanks! I was looking for a quick way to convert points representing boundaries of a polygon – convex hull was exactly what I was looking for.

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s