Elsevier

Computers & Geosciences

Volume 35, Issue 9, September 2009, Pages 1843-1853
Computers & Geosciences

A new hierarchical triangle-based point-in-polygon data structure

https://doi.org/10.1016/j.cageo.2008.09.013Get rights and content

Abstract

The point-in-polygon or containment test is fundamental in computational geometry and is applied intensively in geographical information systems. When this test is repeated several times with the same polygon a data structure is necessary in order to reduce the linear time needed to obtain an inclusion result. In the literature different approaches, like grids or quadtrees, have been proposed for reducing the complexity of these algorithms. We propose a new data structure based on hierarchical subdivisions by means of tri-cones, which reduces the time necessary for this inclusion test. This data structure, named tri-tree, decomposes the whole space by means of tri-cones and classifies the edges of the polygon. For the inclusion test only the edges classified in one tri-cone are considered. The tri-tree has a set of properties which makes it specially suited to this aim, with a similar complexity to other data structures, but well suited to polygons which represent regions. We include a theoretical and practical study in which the new data structure is compared with classical ones, showing a significant improvement.

Introduction

The containment test is widely used in areas like computational geometry, computer graphics and geographical information systems (GIS). In some situations we must consider the inclusion not only of a point in a polygon, but also of many points and polygons, and a common task is to assign points to polygons. The point-in-polygon operation is popular in GIS analysis and makes sense from both the discrete object and the field perspective (Longley et al., 2001).

The point-in-polygon test could be used in a very large set of applications, such as the superposition of polygons, the classification of entities or queries about properties of regions. Imagine an area in which it is necessary to determine spatial coincidence between hydrologic unit codes and regions. A point-in-polygon routine is needed for assigning regions to hydrologic units. These hydrologic units are useful for the prediction of zones of erosion and deposition in a catchment, and can be expanded when torrential rains occur. This special situation is considered in the “Andalucía” region of Spain.

The inclusion test consists of obtaining a boolean result regarding the containment of a point in the interior or on the boundary of a polygon represented by a set of ordered vertices.

The definition of polygon changes for different applications, and special algorithms have been developed for different types of polygons (like convex or non-convex) and for different definitions of polygons (like simple or non-simple). We consider a polygon as an ordered set of vertices (in counter-clockwise order) which form edges making a closed loop without edge intersection (simple polygon). We allow convex or non-convex polygons, manifold or non-manifold, and polygons with or without holes (Fig. 1). We employ this type of polygons which represent spatial areas in a GIS perspective.

When an inclusion test is needed repetitively for the same polygon and there is enough memory in the system for extra information, some data structures are introduced as pre-processing in order to reduce the time complexity of the algorithms. In these cases, some features of the polygon are classified or arranged and the inclusion time is reduced by means of a determined search in these structures.

In this paper we present a new data structure specially suited to the point-in-polygon test. This triangle-based structure subdivides recursively the space occupied by the polygon into tri-cones1 and classifies the edges of the polygon in pre-processing time. Two bounding triangles delimit the area occupied by the classified edges. In query time the points are classified in this data structure, and a point-in-polygon test is performed only with the edges classified in the corresponding tri-cone (Fig. 2). For the containment test several algorithms could be used, but the ray-crossing method (Haines, 1994) and the triangle-based algorithm (Feito et al., 1995) are well suited.

The new data structure is suitable for polygons which represent regions because it fits properly to the contour, which means a quick inclusion test. The expected complexity is O(logn) for query, being n the number of vertices of the polygon, with O(n) space and O(nlogn) construction time. This new data structure is constructed in less time than other data structures like quadtrees, obtaining an improvement in the inclusion test and being suitable for some inclusion methods like the ray-crossings or the triangle-based ones.

In the next section we will revise data structures traditionally used for the point-in-polygon test, as well as their relevant properties. A review of point-in-polygon methods is also shown. Then we will propose a new data structure and its fundamental features. We will follow with the point-in-polygon algorithms adapted to the use of this data structure. Finally we will carry out a time study in which we measure the times obtained for diverse inclusion methods and data structures.

Section snippets

Background

The main data structures used for the point-in-polygon test are grids, quadtrees, k–d trees, bsp-trees, layer of edges, slices or trapezoids (Huang and Shih, 1997, Samet, 2006). Some of these data structures are suitable for some containment methods (i.e. the ray-crossing method could be used with grids, quadtrees, k–d trees, layer of edges or trapezoids). Let us examine some of these data structures. First we review the principal point-in-polygon methods.

Point-in-polygon methods have been

The new data structure

The previous strategies attempt to reduce the number of edges to examine in the point-in-polygon test. These strategies benefit from reduced query time complexity due to additional storage cost and pre-processing time. We propose a new data structure specially suited to the inclusion test for GIS applications.

In the new data structure we will try to use a spatial subdivision similar to the wedge method (Preparata and Shamos, 1985), but applied to non-convex polygons.

The proposed method

Algorithms adaptation to the new structure

We have mentioned four different algorithms for the point-in-polygon test with non-convex polygons: the ray-crossings, the triangle-based, the winding-number and the pixel-based method. The last method is suitable for raster representations. The ray-crossings and winding-number concepts are very closely related in a mathematical perspective (Hormann and Agathos, 2001), the winding-number being slower than the ray-crossings method. Therefore we will study the adaptation of the ray-crossings and

Experimental results and discussion

Now let us analyse the storage, construction and inclusion time for the new data structure.

For a tri-cone we must store information about the bounding triangle as well as the inner bounding triangle, and a list of edges classified in the tri-cone (pointers to the vertices). All bounding triangles have a common point as origin, the reason why for each triangle it is necessary to store only two vertices. The number of edges classified in a tri-cone depends on the geometry of the polygon.

The

Conclusions

We have obtained a new data structure specially suited for the point-in-polygon problem using the crossings-count and the triangle-based methods. This data structure fits better to the geometry of a polygon, obtaining better construction and query times than other data structures like grids and quadtrees. The method proposed is suitable for complex polygons with a large quantity of edges with or without holes, being translation, rotation and scale invariant.

This method could be combined with

Acknowledgements

This work has been partially supported by the Spanish Ministry of Education and Science and the European Union (via ERDF funds) through the research Project TIN2007-67474-C03-03, by the Consejería de Innovación, Ciencia y Empresa of the Junta de Andalucía through the research Projects P06-TIC-01403 and P07-TIC-02773, and by the University of Jaén through the research Project UJA-08-16-02.

References (16)

There are more references available in the full text version of this article.

Cited by (17)

  • A robust, fast, and accurate algorithm for point in spherical polygon classification with applications in geoscience and remote sensing

    2022, Computers and Geosciences
    Citation Excerpt :

    We utilize a method of recursive spatial subdivision that is particularly well suited to the sphere. It shares many similarities with the wedge method for convex planar polygons (Preparata and Shamos, 1985) and the tri-tree algorithm (Jiménez et al., 2009) used for arbitrary simple planar polygons. The algorithm works by classifying polygon edges into “spherical-lunes”.

  • Parallel scanline algorithm for rapid rasterization of vector geographic data

    2013, Computers and Geosciences
    Citation Excerpt :

    Later rasterization algorithms were mostly derived from or improvements of these methods. Some researchers focused on the fast implementation of rasterization, such as the winding number algorithm (Hormann and Agathos, 2001), the hierarchical triangle-based method (Jiménez et al., 2009), and the point-in-polygon method based on the quasi-closest point (Yang et al., 2010). Other researchers considered the lossy conversion process and focused on improving the accuracy of the rasterization, such as the optimization algorithm based on errors in minimized areas (Wang et al., 2006) and the conversion of equal areas (Zhou et al., 2007).

  • A point-in-polygon method based on a quasi-closest point

    2010, Computers and Geosciences
    Citation Excerpt :

    For example, every time a mouse is clicked inside a map on a screen, an instance of the point-in-polygon problem occurs (O'Rourke, 2000). Another example in geosciences is to identify if a water well is in a certain watershed, and even to assign regions to hydrologic units for the prediction of erosion and deposition zones (Jiménez et al., 2009). The point-in-polygon test can be also used to determine the number of soil boreholes located in a particular cadastral parcel (Ellis, 2001).

  • Fine Linear Equation Algorithm for Geo-Fence

    2023, Lecture Notes in Electrical Engineering
  • Efficient Point-in-Polygon Tests by Grids Without the Trouble of Tuning the Grid Resolutions

    2022, IEEE Transactions on Visualization and Computer Graphics
View all citing articles on Scopus
View full text