0

I'm trying to merge a point dataset with a raster dataset using Column X / Row Y.

I have written a tool which generates a raster and, from that raster, I have created grid points with St_PixelsAsCentroids(). These pixel centroids then undergo their own analysis (see image below) which I then want to merge back onto the raster. I know I can do this using geomval and ST_SetValues() but was wondering if there was a quicker way to relate back to the original raster's Column X / Row Y?

Analysed raster pixel centroids reading to be returned to the mother raster!

1

Still not clear what you are trying to do. ST_SetValues does have a variant that takes a matrix of values (where the matrix positions correspond to x/y column). So if you know the X/Y you can just fill it in with the matrix of values instead of using geomval. http://postgis.net/docs/manual-2.1/RT_ST_SetValues.html

There are other ways of burning pixel values into an existing raster. You can use a combination of ST_Union(ST_AsRaster) and convert all your existing geometries to rasters and union them in with the original. If you have more of a sparse matrix that might be much speedier than using ST_SetValues. I haven't done any benchmarks to see which performs better.

  • "So if you know the X/Y you can just fill it in with the matrix of values instead of using geomval." I have read the documentation and couldn't figure this one out. Could you post the code? – Phil Donovan Nov 14 '14 at 0:23

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.