SAP

Manage my Account SAP Devs YouTube ↗ Learnings ↗ Community ↗ Provide Feedback ↗
Logout
⤢ Open full site

Understand Polygons in SAP HANA Spatial

A polygon is a spatial data type that defines a region of space

Overview

Markus Fath M Markus Fath February 7, 2023
Created on December 7, 2016
Contributors

More from Markus Fath

See all 13 tutorials by Markus Fath →

Prerequisites

Prerequisites

Steps

Step 1 Instantiate a surface

Rings, from the previous tutorials, are still strings; i.e. they have length, but no surface. To construct the surface you use polygons. A polygon defines a region of space. A polygon is constructed from one exterior bounding ring that defines the outside of the region and zero or more interior rings, which define holes in the region.

Open the SQL Editor of your choice (web or desktop based) connected to your SAP HANA database instance.

Type and execute the following SQL statement.

SQL
SELECT NEW ST_Polygon('Polygon ((0 0, 4 0, 0 3, 0 0), (0.5 0.5, 0.5 1.5, 1.5 1.5, 1.5 0.5, 0.5 0.5))').ST_asSVG() AS "SVG"
FROM "DUMMY";

This query instantiates a surface in the 2-dimensional Euclidean space and returns its dimensions. In the example above it is a polygon defined by an external ring with the shape of a triangle connecting points (0, 0); i.e., X=0 and Y=0, with points (4, 0) and (4, 3) and an internal ring with the shape of a square. The constructor is using Well-known text (WKT). As explained in the previous tutorial, WKT is a text markup language for representing vector geometry objects defined by the Open Geospatial Consortium (OGC).

Below is an SVG modified to fill a geometry with a color using fill="yellow" to better illustrate the meaning of the external and internal rings of polygons.

Polygon with 2 rings
Polygon with 2 rings

Step 2 Get a dimension
+
Step 3 Get an area
+
Step 4 Get a boundary
+
Step 5 Get boundaries of a multi-segment line
+
Step 6 Check if one geometry is within another
+
Step 7 Check if a point is within a given disk
+
Step 8 Optional
+

Resources

Discussion

Share feedback on this tutorial or join the conversation in SAP Community.

Submit detailed feedback Discuss in Community
Steps
Step 1 of 8
1. Instantiate a surface 2. Get a dimension 3. Get an area 4. Get a boundary 5. Get boundaries of a multi-segment line 6. Check if one geometry is within another 7. Check if a point is within a given disk 8. Optional
Next