In postgis, what is the difference between Z-Dimension and M-Dimension

Viewed 160

Just as the title, what is the difference between Z-Dimension and M-Dimension in postgis?

It is said that Z-Dimension generally stores elevation information while M-Dimension stores some other information.

However, is there any substantial difference between Z-Dimension and M-Dimension? For example, is there any difference in spect of the functions offered by postgis?

1 Answers

There is a difference in that PostGIS treats the Z coordinate different in three-dimensional functions.

Consider this example:

SELECT st_3ddistance(
          'SRID=4326;POINT ZM(0 0 0 100)'::geometry,
          'SRID=4326;POINT ZM(0 0 0 0)'::geometry
       );

 st_3ddistance 
═══════════════
             0
(1 row)

SELECT st_3ddistance(
          'SRID=4326;POINT ZM(0 0 100 0)'::geometry,
          'SRID=4326;POINT ZM(0 0 0 0)'::geometry
       );

 st_3ddistance 
═══════════════
           100
(1 row)

The M dimension can be any measure associated with each point, for example the intensity of the radioactive radiation in that location. Obviously, that does not factor in distance measurements. It is used in other functions like ST_InterpolatePoint, which interpolates the M dimension at a given point:

SELECT st_interpolatepoint(
          'SRID=4326;LINESTRING ZM(0 0 0 100,50 50 10 0)'::geometry,
          'SRID=4326;POINT(20 20)'::geometry
       );

 st_interpolatepoint 
═════════════════════
                  60
(1 row)

Here the Z coordinate is ignored, since it is a function for 2-dimensional geometry.

Related