Skip to Content

Intro to SAP HANA Geospatial: Spatial Reference Systems

Previous

Intro to SAP HANA Geospatial: Spatial Reference Systems

By Vitaliy Rudnytskiy

In the context of spatial databases, the defined space in which geometries are described is called a spatial reference system (SRS).

You will learn

You will learn what Spatial Reference Systems and Spatial Units of Measure are, how they are defined and used in SAP HANA.

Details


Step 1: Calculating the distance on the flat surface

What is the distance between two points: (0, 0) and (1, 0)?

select new st_point('POINT (0 0)').st_distance(new st_point('POINT (1 0)')) as distance from dummy;
Distance in SRS=0

The result is 1.

But what if you want to measure a distance between two geographic point where coordinates are latitude and longitude? Then you need to specify what Spatial Reference System (SRS) is used for geometries in spatial queries.
A spatial reference system defines, at minimum:
- units of measure of the underlying coordinate system (degrees, meters, and so on),
- maximum and minimum coordinates (also referred to as the bounds),
- whether the data is planar or spheroid data,
- projection information for transforming the data to other reference systems.

When not SRS is specified in the query, then the default SRS with id (SRID) equal 0 is assumed by SAP HANA. Spatial reference system details can be viewed in the ST_SPATIAL_REFERENCE_SYSTEMS system view.

Check some of the characteristics of SRS with SRID equal 0

select srs_name, round_earth, axis_order, min_x, max_x, linear_unit_of_measure
from ST_SPATIAL_REFERENCE_SYSTEMS where srs_id=0;

SRS 0 details

As you can see it is the DEFAULT reference system, with all x, y, z and m coordinates. It is based on the flat surface. It has meter defined as a linear unit of measure, and so conversion to other units is possible in some spatial methods. The list of pre-installed units is available in the system view ST_UNITS_OF_MEASURE. One of them is yard, used in the following example.

select new st_point('POINT (0 0)').st_distance(new st_point('POINT (1 0)'), 'yard') as distance from dummy;
Convert to yard

More units of measures can be manually created or loaded into the SAP HANA using separate Geospatial Metadata Installer. Geospatial Metadata Installer is available for registered customers and partners.

Step 2: Calculating the distance on the round Earth

The Spatial Reference System that implements geodetic coordinate system of the Global Positioning System (GPS), or WGS 84, has SRID 4326.

select srs_name, round_earth, axis_order, min_x, max_x, min_y, max_y, linear_unit_of_measure, angular_unit_of_measure
from ST_SPATIAL_REFERENCE_SYSTEMS where srs_id=4326;
SRS 4326

This SRS has degree defined as the angular unit of measure and boundaries are between -180 to 180 degrees longitude and -90 to 90 degrees latitude.

To calculate a distance of one degree of longitude at the equator in kilometers run this query.

select new st_point('POINT (0 0)', 4326).st_distance(new st_point('POINT (1 0)', 4326), 'kilometer') as distance from dummy;
one degree on the equator

A distance of one degree of longitude at the 45 degrees latitude should be shorter.

select new st_point('POINT (0 45)', 4326).st_distance(new st_point('POINT (1 45)', 4326), 'kilometer') as distance from dummy;
one degree on the 45deg latitude

SRS with id 4326 is the one of many standardized reference systems. Other may have different assumptions regarding the Earth shape, or may define boundaries to cover only selected countries.

More spatial reference systems can be manually created or loaded into the SAP HANA using separate Geospatial Metadata Installer. Geospatial Metadata Installer is available for registered customers and partners.

Optional

Next Steps

Updated 12/12/2017

Time to Complete

15 Min

Beginner

Next Steps

Next
Back to top