0

I am trying to convert a table of MultipolygonZ geometries to a floating point raster where the pixel values of the output raster will be derived from the Z values of the MultipolygonZ geometries. The ultimate goal is to perform map algebra between the resultant floating point raster and a DEM (already loaded in PostGIS). I have already tried to perform the analysis directly between the MultipolygonZ geometries and the DEM without success - see PostGIS: intersection of a MultipolygonZ and a floating point raster.

Here is an example of one of the geometries that I am working with - it is essentially an inclined plane that represents water levels of a flood plain interpolated between two cross sections:

SELECT ST_GeomFromText('MULTIPOLYGON Z (((277378.7412 5048118.3481 22.46,278037.7398 5047686.44410001 22.46,277929.677100001 5047698.6316 22.46,277380.212900001 5048034.458 22.46,277105.837500883 5048202.1531993 22.46,277167.5633 5048248.2075 22.46,277173.661101116 5048252.75649908 22.46,277378.7412 5048118.3481 22.46)))')

Is this possible using the ST_AsRaster(), ST_ExtractToRaster() or any other functions/methods within PostGIS? I am able to create a raster using ST_AsRaster(), but I can't get the output raster to contain the interpolated Z values.

1

Short answer: No, it is not possible to get z values in your raster.

Long answer: Z-values are not always used for height and it is not that easy to interpolate height in vectorspace when it involves a surface (you would use kriging or some sort). Since you already have a way to interpolate from one cross section to the other, I would try to get isohypses from this process. In that way you would be able to store every isohypse polygon with its own height value, convert it to raster en then do an intersection with your DEM.

How to get the isohypses is for another stack question...

  • Thanks for the answer/explanation. That is what I was afraid of. I already have a working procedure outside of PostGIS where the MultiPolygonZ is converted to a TIN and then to a floating point raster. Map algebra is then performed between the output raster and the DEM to calculate the water heights of the flooded areas. I was hoping to be able to try this in PostGIS; however, it doesn't seem possible at the current time. – Brent Edwards Mar 17 '16 at 16:25
  • 1
    Why can't you just create another single band raster which represents the z value and do mapalgebra on that. – John Powell Mar 18 '16 at 15:11
  • @John Barça - This doesn't seem possible within the current version of PostGIS. I am able to create one using other tools/procedures, but my goal was to try to create one within PostGIS from my MultipolygonZ geometries. – Brent Edwards Mar 21 '16 at 12:59
1

This can be done directly with GDAL, such as with the gdal_rasterize ... -3d ... utility, or from C/C++/Python/etc. using the GDALRasterize API. Essentially, the raster would need to be created outside the database, but you can use the MultiPolygonZ data from PostGIS.

If you really need this feature in PostGIS, you could request and possibly contribute or sponsor the development. There are no technical reasons why this feature is not possible, since GDAL is already used to enable raster support for PostGIS.

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.