Belaid MOA wrote:
I wrote a GDAL C++ code that solves the following simple problem:
take two images, a source image with spatial resolution 25mx25m (high resolution) and a destination image with spatial resolution 10000mx10000m (low resolution) and scale the source image so that the values of the pixels in the source image that are mapped to the same pixel P in the destination image sum up to the value of P.

you really want the sum, rather than an average?

Anyway, it seems you could use gdal_warp for this, with maybe a multiplication at the end to get a sum rather than an average.

> As a side
note, the two images have different projections.

That's more than a side note -- this is trivial if there were no projection change. Could you do them in separate steps? Change the projection of the high-res image, then do your down sampling. That might make it pretty easy to do with the gdal utilities.

Briefly, the arithmetic that computes the overlap is:

given your large difference in resolution, you may be able to keep it simpler -- only use those pixels in the source wholly contained in the destination pixel -- I doubt you'd see a difference.

As you can see, the ratio 1/2*(SrcXRes/DstXRes) is so small that I do not get smooth image

That's a big change in resolution if your source data is not that smooth, you're not going to get a smooth result.

Am I doing something wrong in my arithmetic?

not that I could quickly see, but give yourself some really simple test cases to make sure.

You also might want to test without the re-projection, as that will be easier to see if you've done it right.

Should I apply an average filter to smoothen the image?

That is entirely dependent on your application.

-Chris



--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

chris.bar...@noaa.gov
_______________________________________________
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to