[postgis-users] Getting data from table with interval

Luca Bertoncello lucabert at lucabert.de
Thu Jan 6 12:41:34 PST 2022


Hi list!

I have a table in my PostGIS database, with the ground elevation of Europe.
The table is so:

gis=# \d elevation
                        Tabelle »public.elevation«
  Spalte   |       Typ        | Sortierfolge | NULL erlaubt? | Vorgabewert
-----------+------------------+--------------+---------------+-------------
 latlng    | geography        |              |               |
 lat       | double precision |              |               |
 lng       | double precision |              |               |
 elevation | real             |              |               |

lat and lng are just used for an export to a SQLite-DB for use in an
App. The same data are in "latlng" as geography...
The table has currently a precision of 3x3 Km, but I can import data
with a better precision, too, of course.

So my question...
I'd like to use these data to create a vertical profile similar to the
one I can get from Google-Maps.
Currently, with a simple query, I can get the elevation of a given point.
Of course, I don't have _all_ point in the table, so I have to search
the nearest point, but this is OK...

What I need is a function that receive two coordinates as parameters.
These coordinates define a line from A to B.
I'd like to retrieve all elevations in this line, with a given interval,
so that I can retrieve for example the elevation every kilometer or so.

And I don't have any idea how to do that...

Can someone suggest me a way?

Thanks a lot
Luca Bertoncello
(lucabert at lucabert.de)


More information about the postgis-users mailing list