I have multiple 2D points(lng=X lat=Y altitude=Z==NULL timestamp=M) mixed with multiple 3D points (lng=X lat=Y altitude=Z timestamp=M). I am going to apply ST_MAKELINE (Postgis) to those points. Then I realized that function auto fill 0 to Z axis of all 2D points, but I expected NULLs. So is there any function to avoid this?

Probably my description was incorrect. I am trying to compress multiple mixed dimension points with ST_SIMPLIFY. before I call ST_SIMPLIFY I need to make all points into a LINE via ST_MAKELINE. Then ST_MAKELINE auto convert 2D points into 3D point which is not expected. NULL should be NULL rather than 0.

Pseudo query: ST_SIMPLIFY(ST_MAKELINE([set of points]))

Update: What I have done so far (awaiting better solution)

I made a copy of mixed points as raw_points and then convert all mixed points into 2D (basically drop Z) then call ST_MAKELINE with all 2D points. Then call ST_SIMPLIFY to get a set of compressed points as compressed_points

Finally recover altitude information by following

Pseudo code:

select raw_point 
from compressed_point 
 LEFT JOIN raw_points on ST_M(compressed_point) = ST_M(raw_points);

Your Answer

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

Browse other questions tagged or ask your own question.