Using PostGIS, what is the best method to interpolate the z value for points (the orange dot in the image below) located between each contour layer (blue lines and red lines in the image below)? So for the blue contours it's going to be ~ 917 and for the red contours it'll be ~ 819.
The blue contours are a 2D Multipolygon and the red contours are a 2D Multilinestring (so for both, the contour value is an attribute field. If necessary I could update the geometries to have a z value).
Thanks!
Best Answer
COMMENT, 1 day later: I now see that my solution assumes that the contours are stored as polygons. In fact, the question is about multipolygon data. For my solution to work, you will first have to extract the individual component polygons with their level, and assign them a unique integer-valued id called "id".
Two further assumptions, that are not checked, are:
Good luck! Roelof
(END OF COMMENT)
For the polygon case, I suggest creating a function using plpgsql. Here is my try:
I made the assumption that your geometry field is called the_geom. You may have to substitute this value with the actual name in your table.
To apply the function:
For the contour lines, it's harder. If possible, do an intermediate step to convert the contour lines to polygons.