Skip to Content

SAP HANA Geospatial - how to calculate polygon area

Hi !

In oracle i have polygon ,he area 8,6 ha.

its coordinates

(37.67864227294922 50.4218626237537,37.67864227294922 50.42404998528019,37.68362045288086 50.42404998528019,37.68362045288086 50.4218626237537, 37.67864227294922 50.4218626237537)

in HANA i create this polygon like this

insert into MY_TABLE(id,spolygon)

select 7777777,NEW ST_Polygon('Polygon ((37.67864227294922 50.4218626237537,37.67864227294922 50.42404998528019,37.68362045288086 50.42404998528019,37.68362045288086 50.4218626237537,37.67864227294922 50.4218626237537))') from dummy;

When i calculating area

select p.spolygon.st_area() from MY_TABLE p where;

I get 0,000010890908015426248. -- what kind of unit, where it comes from (how to configure it), how do i calculate the area in hectares?

if i do like this p.spolygon.st_area() * 1000000 i get 10.8 not 8,6 ha

What shall I do to get my 8.6 hectare ?

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    Posted on Aug 22, 2016 at 02:19 PM

    Hello Viktor,

    cause you did not define a Spatial Reference Identifier (SRID), the default SRID 0 is used which is a flat, 2D plane system. So ST_AREA just returns the result value as double value with an "undefined type" I would say for your input polygon with long/lat values. Of course as it can be seen in the system view ST_SPATIAL_REFERENCE_SYSTEMS the default linear unit is "meter", but that is not true in your case, cause you do not pass meter values.

    The best fitting SRID would be 4326 (WGS84) (a list of the supported SRID and a description for it can be found here: Spatial Reference Systems (SRS) and Spatial Reference Identifiers (SRID) - SAP HANA Spatial Reference), but that SRID does not support the ST_Area method (4326 is a round-earth type) as described here: List of All Supported Methods - SAP HANA Spatial Reference.

    So the only long/lat SRID supporting ST_Area is 100004326 (WGS84 planar), but it is not a round-earth type and therefore has differences in area/distance calculations. As it can be read in the link added above, it is therefore also not recommended to use it for such calculations. But just for demo purposes following example calculates the square meters for your coordinates. As it can be seen, SRID 100000436 is defined and as unit for ST_Area "meter" is defined (cause the default for the choosen SRID is planar degree):

    select NEW ST_Polygon('Polygon ((
    37.67864227294922 50.4218626237537,
    37.67864227294922 50.42404998528019,
    37.68362045288086 50.42404998528019,
    37.68362045288086 50.4218626237537,
    37.67864227294922 50.4218626237537))',1000004326).ST_Area('meter') from dummy;

    The result does also not match your expected result (converted to hectar), but it should give you some hints and insights that different SRIDs exist and why your calculation with default SRID 0 returns the result as it is.



    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.