cancel
Showing results for 
Search instead for 
Did you mean: 

HANA Spatial Predicate - ST_Covers

BenedictV
Active Contributor
0 Kudos

I am trying to use the ST_Covers predicate in HANA to check if a particular point is covered by a shape. The point has the lat/long information for the city of San Francisco and the shape is the State of California from the "SAP_SPATIAL"."SHAPE_LEVEL_5" table. Here's the point information,

<?xmlversion="1.0" standalone="no"?><!DOCTYPE svg PUBLIC"-//W3C//DTD SVG 1.1//EN""http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="37.774930 -122.419416 .0002 .0002"><rect width="0.1%" height="0.1%" fill="lightgrey" stroke="none" x="38.71669" y="121.36442"/></svg>
SELECT A."CITY" FROM "<schema>"."GEOPOINTS" AS AINNERJOIN"SAP_SPATIAL"."SHAPE_LEVEL_5" AS CAONCA."SHAPE_4326".ST_Covers(A."POINT_4326") = 1WHERECA."AREA_ID" = '21009408';

But I do not get any output. Isn't this how the ST_Covers predicate works?

Accepted Solutions (1)

Accepted Solutions (1)

lbreddemann
Active Contributor

Hi Benedict

your SQL looks alright, but the data point you are using appears to have x/y swapped : x="38.71669" y="121.36442"

When I look at some demo data from San Francisco, then the x coordinate is around 121/122 and the y coordinate around 37/38:

select id, name, loc_4326, loc_4326.ST_asText()
from "HSGS"."AWARDEE"
where awardee_city ='San Francisco';

ID  NAME                                  LOC_4326                                  LOC_4326.ST_ASTEXT()        
452 Cairn Biosciences                     0101000000656EBE11DD985EC04BCB48BDA7E24240POINT (-122.388493 37.770744)
463 Mission Bio, Inc.                     01010000007E7214200A995EC0508D976E12E14240POINT (-122.391243 37.758375)
464 STEMKids LLC                          010400000000000000                        POINT EMPTY                  
465 Nano Hydrophobics, Inc.               010100000072DC291DAC9B5EC006B8205B96E54240POINT (-122.43238 37.793651) 
1795Exploratorium                         01010000007098689082995EC0F44F70B1A2E64240POINT (-122.398594 37.80184) 
1869WestEd                                01010000002733DE567A995EC0ACAB02B518E44240POINT (-122.398092 37.782004)
74  San Francisco State University        01010000007F4DD6A8879E5EC055A4C2D842DC4240POINT (-122.47703 37.72079)  
603 Industrial Microbes, Inc.             010100000072C3EFA65B9B5EC092E68F696DDE4240POINT (-122.427469 37.737714)
421 Zenflow, Inc.                         010100000066C1C41F459B5EC0410FB56D18DF4240POINT (-122.426094 37.742933)
778 University of California-San Francisco0101000000D0285DFA979A5EC02C11A8FE41E24240POINT (-122.415526 37.767639)
804 Kelley Nicole                         01010000004434BA83D89A5EC013D55B035BE34240POINT (-122.419465 37.776215)
808 Exploratorium                         01010000005DF92CCF83995EC0CA1AF5108DE64240POINT (-122.39867 37.80118)  
814 Tides Center                          010400000000000000                        POINT EMPTY                  
823 University of San Francisco           010400000000000000                        POINT EMPTY                  
851 ProLynx LLC                           0101000000AE9FFEB3E69C5EC097900F7A36E14240POINT (-122.451581 37.759475)

- Lars

BenedictV
Active Contributor
0 Kudos

Spot on Lars.

I looked at the spatial reference table and the co-ordinates for SRID-4326 is 'long/lat/z/m'. long/lat, 😞 who would have thought?

Answers (0)