6

I'm trying to take advantage of the many functions available in Postgis for dealing with latitude and longitude coordinate systems. However, I would like to add some altitude information to my database and I can't find the proper answer for which datatype should be used for properly holding Latitude, Longitude and Altitude in Postgis?

I have found that Geometry type is capable of X, Y and Z, but the Geography type only holds Latitude and Longitude. Is there and differences between both?

2

2 Answers 2

5

I don't see why geography can't hold Z. Did you try it?

As per the docs:

CREATE TABLE testgeog(gid serial PRIMARY KEY, the_geog geography(POINTZ,4326) );

0

For geometries, like PointZ which can store Z values, you can try the WKB or WKT formats for example.
WKB is particularly well suited for database.
Transformations are easily performed as it is an OGC standard.

https://en.wikipedia.org/wiki/Well-known_text
http://docs.opengeospatial.org/is/12-063r5/12-063r5.html

1
  • I would highly recommend using the postgis geometry/geography types instead of using WKB or WKT. The performance will be much better and the use of postgis functions will be a lot easier (and faster).
    – tilt
    Jun 8, 2017 at 12:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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