Poly2grid

Geometric functions poly2grid

syntax

  • poly2grid(polygon_data_item, gridunit)

definition

The poly2grid function results in a Grid Data item with a relation to the Domain unit of the polygon_data_item.

The resulting data item has:

description

The poly2grid function is based on a similar function in GDAL.

The Point_in_polygon function can also relate the cells of a grid to polygons, but poly2grid is much faster.

applies to

  • data item polygon_data_item with a wpoint, spoint, upoint, ipoint, fpoint or dpoint Value type
  • Unit gridunit with a wpoint, spoint, upoint, ipoint, fpoint or dpoint value type

conditions

  1. The composition type type of the polygon_data_item needs to be polygon.
  2. The Domain unit of the polygon_data_item must be of value type uint32.

complexity

The complexity of the poly2grid function for one polygon is O(n* log(n) + x), with:

  • n: number of points of the polygon.
  • x: number of pixels to be drawn.

This implies the number of points per polygon is an important factor in the calculation speed of the function.

Simplifying polygons can help to improve the calculation speed. See Geometric functions for simplify functions in the GeoDMS.

since version

6.025

example

attribute<source/district> DistrictGrid (gridunit/gridcel_10m) := 
   poly2grid(Source/District/border, gridunit/gridcel_10m);

see also