[Gdal-dev] how gdal_rasterize works

Frank Warmerdam warmerdam at pobox.com
Fri Jun 16 16:04:43 EDT 2006


Luke Roth wrote:
> I've been trying to use the polygon rasterization functions in 
> alg/gdalrasterize.cpp for a while now, but I just can't get it to do 
> what I want.  I've been using apps/gdal_rasterize.exe to rasterize an 
> entire vector layer, but what I'd really like to do is to rasterize 
> individual polygons from my C code without having to run 
> gdal_rasterize.exe for each individual feature.  I've tried using the 
> apps/gdal_rasterize.cpp code as a template, but I'm not getting 
> anywhere.  Can anyone who has used this code give me a simple 
> walkthrough or nudge me in the right direction?  I can give more details 
> if it would help.

Luke,

You should be able to follow the gdal_rasterize.c code as a template
for this.  If you are running into problems, you might need to be specific
about what is going wrong.

Are you calling GDALRasterizeGeometries() once for each feature?  Keep in
mind that the downside of doing this is that a complete pass through the
raster (read/write) must be made for each features.  Well, actually come
to think of it, the code might be smart enough to focus on the area of
the geometry, but still it is likely to result in quite a bit of extra
read/write work on the raster.

As Chris Barker suggests, GDAL's rasterization capability is not
sophisticated from a render styling point of view.  Other tools may
be more appropriate if you want to do anything more sophisitcated
that rasterize the polygons in a single solid color.

For more interactive help, you might want to drop into #gdal on
irc.freenode.net.  I should be around for a while.

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | President OSGF, http://osgeo.org




More information about the Gdal-dev mailing list