Quantcast
Viewing all articles
Browse latest Browse all 10473

Re: Hana SPS07 and spatial data

I have an existing table with LATITUDE and LONGITUDE columns and want to use them to create a new ST_POINT column. From there, I hope to take advantage of the new geospatial functions.


This sounded like a simple extension to Gerrit's example above but it turns out there's a little more to it.


As Gerrit says, to use latitudes and longitudes, you must specify the SRID of 4326 when you create the column:

 

alter table GHCND_STATIONS add( LOCATION st_point(4326) );

 

However, in my case, it was also necessary to specify the SRID during the update:

 

update GHCND_STATIONS

set LOCATION = new st_point( 'POINT(' || LONGITUDE || ' ' || LATITUDE ||')',4326)

 

Garrit's INSERT statements worked without the SRID but when I tried this in an UPDATE statement, the resulting ST_Point has an SRID of -1 and attempts to use them in distance calculations return NULL.

 

Performance was disappointing.  The table in question contains 91,000 weather stations. The query below returns stations within 50 km of a specified lat/long and takes almost 11 seconds to run (on an AWS HANA):

 

SELECT ID, name, longitude, latitude, location.ST_AsEWKT() As EWKT,

location.st_distance(ST_GeomFromEWKT('SRID=4326;POINT(-94.1167 29.7000)'))/1000 as Dist_KM

FROM GHCND_STATIONS

where location.st_distance(ST_GeomFromEWKT('SRID=4326;POINT(-94.1167 29.7000)'))/1000 < 50

 

Almost all the time went into WHERE clause.


Viewing all articles
Browse latest Browse all 10473

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>