Group Points into Polygons

Analysis Guides

Group Points into Polygons

This guide describes how to apply the Group points into polygons analysis to group point, line or polygon data into polygons, based on the extents of similar points or lines.

For example, from a sample of soil classification point data of a region, polygon extents of similar soil type can be mapped. Another relevant example is mapping different species habitats that can be analyzed by movement, or location trends, over time.

Grouping Points

This analysis method can be used in a variety of contexts, such as analyzing sales territories for optimization, understanding catchment areas, and defining location patterns with mobile tracking data.

For this guide, let's explore species movement data from Movebank to understand how habitat-ranges of different birds compare. This example groups GPS tracking data for two species of birds into polygons.

Movebank is a rich online database of animal tracking data hosted by the Max Planck Institute for Ornithology.
  1. Import the template .carto file packaged from "Download resources" of this guide and create the map. Builder opens with point data as the first and only map layer, named Habitats.

    Click on "Download resources" from this guide to download the zip file to your local machine. Extract the zip file to view the .carto file(s) used for this guide.

    Point data of Habitats

  2. From the LAYERS pane in Builder, click the Habitats map layer.

  3. Click the ANALYSIS tab to add an analysis to the layer.

  4. Apply the Group points into polygons analysis.

    • The SOURCE layer is the layer on which to perform the analysis.
    • Select Convex Hull as the METHOD.
    • Select the GROUP BY checkbox to enable the category column drop-down list, and select individual-taxon-canonical-name as the column. This is the column from the dataset that specifics the species name associated with location points.
    • For the Value aggregation option, keep the default COUNT operation selected.
    • Click APPLY.

The location points of each species are grouped into their potential habitat polygons.

Convex Hull applied

Grouped Results

As as result of the analysis, two polygons appear on your Map View, each representing the group of species category. To enhance the visualization, style the polygons with the category column, by styling by value.

  1. From the LAYERS pane in Builder, click the Habitats map layer.

  2. Click the STYLE tab to apply custom styling to the layer.

  3. Click the COLOR to open the color picker. The SOLID tab is selected by default.

  4. Click the BY VALUE tab.

  5. Select Category as the column from your map layer. Builder assigns a default qualitative CARTOColor scheme, which helps you visualize the difference between the two groups of data.

Style by value with the category column

Enhanced Cartography

The Movebank dataset also has a column which records the time at each location point for the species. To trace the spots where the birds flew between 2011 to 2014, create a new layer from the original data and drag it above the Habitats layer.

You can drag and drop analysis results to create a new layer. You can also drag and drop the original source (point data from the Habitats layer) as a new layer from the LAYERS pane.
  1. Click on the original Habitat source of data movements_of_long_legged_buzzards_and_short_toed_eagles from Layer A. This is separate from the analysis results (A1, Convex Hull).

    Select original source from map layer

  2. Click and drag the data above the Habitats layer. You will notice that a new layer is created based on the original source of data.

    New layer created from original data source

  3. Rename the new layer to Movements.

    Rename map layer name from context menu

  4. Select the Movements layer and apply styling by using the STYLE tab of the map layer:

    • Select ANIMATED as the Aggregation option and keep Points as the TYPE.
    • Click on the COLOR to style BY VALUE, selecting individual-taxon-canonical-name as the column.
    • Select timestamp as the COLUMN option.
    • Further style the map by modifying the color and opacity of the layer. Change the SIZE value to 4, and change the STROKE size to O.

Animated options applied to Movements layers

This analysis is a first step of identifying behaviors for these bird species. For example, data patterns may reveal if they like suitable climatic conditions, if they can co-exist with other animals, what food they gravitate towards, if they are an endangered threat, and many more potential investigations.

Download the final .carto file from the "Download resources" of this guide, and explore the additional cartography, and CartoCSS, that was applied to the map.

External Resources

If you are interested in using the underlying functions in the SQL view of Builder, view the PostGIS documentation.