Skip to Content
Author's profile photo Tom Flanagan

[SAP HANA Academy] SAP HANA SPS11 – HANA Spatial: Spatial Functionality in SQLScript

Part of the SAP HANA Academy’s What’s New with SAP HANA SPS11 series, Jamie Wiseman provides a tutorial video on using spatial functionality in HANA SQLScript. Specifically Jamie will detail how to use spatial data type ST_GEOMETRY and spatial methods to access and manipulate spatial data in HANA SQLScript. Note this feature is only applicable to SAP HANA SPS11 and it will not work for any prior iterations of SAP HANA.

Watch Jamie’s quick tutorial below.

Screen Shot 2015-12-09 at 3.08.41 PM.png

In SAP HANA SPS11 SQLScript now supports spatial data type ST_GEOMETRY and SQL spatial methods to access and manipulate spatial data. To demonstrate this Jamie is using a user defined function that uses spatial dimensions in a procedure. Then Jamie will call that procedure which contains a couple of ST_GEOMETRY inputs.

You must be logged into your SAP HANA system with a user who has the rights to create new functions and procedures. Please visit this GitHub page to access, for free, the script used in this tutorial.

Screen Shot 2015-12-09 at 5.43.59 PM.png

Lines 1-9 of the script create a user defined function that has a pair of ST_GEOMETRY input parameters. Line 8 of the function uses the ST distance method to calculate the distance between the two inputs. The distance calculated is subjected to whatever SRID (spatial reference ID) is used.

Screen Shot 2015-12-09 at 5.58.35 PM.png

Lines 11-27 create a procedure that not only references the user defined function, but also incorporates a pair of geometry type inputs. Also, two other spatial methods are used to create an additional display value. This display value consists of two different well-know text methods that will show spatial values in an easier to read text format. Currently at the time of this tutorial’s creation only geometry spatial type values are allowed in SQLScript in SAP HANA SPS11.

If you were to uncomment line 13, which contains a point spatial type, then an error would be returned.

Screen Shot 2015-12-09 at 5.59.39 PM.png

Lines 29-35 deal with the procedure call. The syntax for the two parameter inputs creates geometry spatial types. In Jamie’s example both are points. The SRIDs of the two geometries are specified in the same input.

Screen Shot 2015-12-09 at 6.00.52 PM.png

If you run all of the syntax at once you will get the results from the procedure’s nested distance call and will also display the results from the two additional spatial methods.

Screen Shot 2015-12-09 at 5.52.34 PM.png

For more tutorials videos on What’s New with SAP HANA SPS11 please check out this playlist.

SAP HANA Academy – Over 1,300 free tutorials videos on SAP HANA, SAP Analytics and the SAP HANA Cloud Platform.

Follow us on Twitter @saphanaacademy and connect with us on LinkedIn to keep apprised of our latest free tutorials.

Assigned Tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.