SAP Home Learn Build Integrate Model Operate Extend with AI ConnectTutorial navigator Knowledge Graph API Devtoberfest Developer Advocates App Space

Manage my Account SAP Devs YouTube ↗ Learnings ↗ Community ↗ Provide Feedback ↗
Logout
โคข Open full site

Transformation methods

Transformation methods transform a geometry into some other geometry

Overview

🎓 beginner 15 min. SAP HANABeginnerSqlSAP HANA CloudExpress EditionSAP HANA SpatialSAP HANA Multi Model Processing
Markus Fath M Markus Fath February 7, 2023
Created by February 13, 2018
Contributors

Prerequisites

Prerequisites

Steps

Step 1 Boundary
โ€”

The ST_Boundary method returns the boundary of a geometry. Boundary depends on a geometry type and its characteristics.

A point has no boundary and returns the empty geometry. An empty geometry returns null.

SQL
SELECT
"SHAPEID",
"SHAPE".ST_asWKT() AS "WKT",
"SHAPE".ST_Boundary().ST_asWKT() AS "BOUNDARY_WKT"
FROM "TUTORIAL_GEO"."SPATIALSHAPES"
WHERE "SHAPE".ST_GeometryType() = 'ST_Point'
ORDER BY 1 ASC;

Points boundaries
Points boundaries

The boundary for line strings is a collection of their end points.

SQL
SELECT
"SHAPEID",
"SHAPE".ST_asWKT() AS "WKT",
"SHAPE".ST_Boundary().ST_asWKT() AS "BOUNDARY_WKT"
FROM "TUTORIAL_GEO"."SPATIALSHAPES"
WHERE "SHAPE".ST_GeometryType() = 'ST_LineString'
ORDER BY 1 ASC;

Lines boundaries
Lines boundaries

The boundary for multi line strings is a collection of all their end points of individual line strings in the collection.

SQL
SELECT
ST_UnionAggr("SHAPE").ST_asWKT() AS "WKT",
ST_UnionAggr("SHAPE").ST_Boundary().ST_asWKT() AS "BOUNDARY_WKT"
FROM "TUTORIAL_GEO"."SPATIALSHAPES"
WHERE "SHAPE".ST_GeometryType() = 'ST_LineString';

Multi lines boundaries
Multi lines boundaries

A ring — a special case of a string where the start point is the same as the end point and there are no self-intersections — has no boundary.

SQL
SELECT
NEW ST_LineString('LINESTRING (6 7,10 3,10 10,6 7)').ST_Boundary().ST_asWKT() AS "BOUNDARY_WKT"
FROM DUMMY;

Ring boundary
Ring boundary

The boundary for a polygon is its outer ring and any inner rings.

SQL
SELECT
"SHAPEID",
"SHAPE".ST_asWKT() AS "WKT",
"SHAPE".ST_Boundary().ST_asWKT() AS "BOUNDARY_WKT"
FROM "TUTORIAL_GEO"."SPATIALSHAPES"
WHERE "SHAPE".ST_GeometryType() = 'ST_Polygon'
ORDER BY 1 ASC;

Polygon boundary
Polygon boundary

Below is an example for a polygon with the inner ring to illustrate the output containing both the outer and inner rings as a MULTILINESTRING.

SQL
SELECT
NEW ST_Polygon('Polygon ((-5 -5, 5 -5, 0 5, -5 -5), (-2 -2, -2 0, 2 0, 2 -2, -2 -2))').ST_Boundary().ST_asWKT()
FROM DUMMY;

Polygon with inner ring boundary
Polygon with inner ring boundary

Obviously the length of a boundary is equal to the perimeter of a polygon.

SQL
SELECT
"SHAPEID",
"SHAPE".ST_asWKT() AS "WKT",
"SHAPE".ST_Boundary().ST_Length() AS "BOUND_LENGTH",
"SHAPE".ST_Perimeter() AS "PERIMETER"
FROM "TUTORIAL_GEO"."SPATIALSHAPES"
WHERE "SHAPE".ST_GeometryType() = 'ST_Polygon'
ORDER BY 1 ASC;
Step 2 Envelope
+
Step 3 Convex hull
+
Step 4 Buffer
+
Step 5 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 5
1. Boundary 2. Envelope 3. Convex hull 4. Buffer 5. Optional

Learn more →