How does the rasterize tool decide which value to represent when a cell covers an area which inclueds different values? I need it in this case for polygons but would like to know for lines and points as well. What are the rules that it follows.


Looking at the source here and here, it seems GDAL just starts from the top of the list and works its way down, so it'll be in whatever order the shapes are stored in, overwriting any data that was stored in a given pixel. I'm not even sure it does anything with attribute indexes.


The rasterizer by default just uses the centre of the pixel for polygons, or Bresenham's algorithm for lines (presumably points are just nearest neighbour). There appears to be an option to fill any touched pixel that can, I think, be supplied on the command line. There's a comment to this effect in the code:

462  * <dt>"ALL_TOUCHED":</dt> <dd>May be set to TRUE to set all pixels touched
463  * by the line or polygons, not just those whose center is within the polygon
464  * or that are selected by brezenhams line algorithm.  Defaults to FALSE.</dd>

So there is no blending at all, and it doesn't try to do anything clever.

|improve this answer|||||
  • Thanks for the reply. Should prove useful later on. What I would like to know is how the rasterize function selects the representative value from the shape. Does it use the centrepoint value or the highest percentage coverage and how does it deal with a 50/50 situation etc? The source is still a bit tricky for me to understand sorry. – Andre Wise Apr 11 '12 at 20:37

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.