2

I was wondering if it's possible to store 4D (lat, lon (wgs84), altitude and time) in PostGIS geography type.

I want to store flight paths, where every path consists of multiple points and every point has lat,lon,altitude and time as dimensions. According to the doc I can do this with geometries but I'm wondering what the proper way of doing this would be, since geography seems the right choice over geometry for flight paths that could cross the whole world.

0

It is possible to do it, or to do both:

CREATE TABLE points (
   gid SERIAL,
   time timestamp,
   z real,
   geog GEOGRAPHY(PointZM),
   geom geometry
);

    INSERT INTO points VALUES (
1,'2020-11-06T15:44',567.89,'POINT(0 1 567.89 121212121)','POINT(0 1 567.89 121212121)'
);

select gid,time, ST_AsText(geog), ST_AsText(geog) from points;


 gid |        time         |            st_astext            |            st_astext            
-----+---------------------+---------------------------------+---------------------------------
   1 | 2020-11-06 15:44:00 | POINT ZM (0 1 567.89 121212121) | POINT ZM (0 1 567.89 121212121)
(1 row)


     SELECT ST_Distance('POINT(-72.1235 42.3521)', geog)  FROM points;
   st_distance    
------------------
 8472725.92158588
(1 row)

  SELECT ST_Distance('POINT(-72.1235 42.3521)', geom)  FROM points;
    st_distance    
-------------------
 83.13720843677638
(1 row)

But depending on how you'd want to use or index the information you may want to store it differently.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.