[Gdal-dev] Masking rasters with gdal_rasterize

Frank Warmerdam warmerdam at pobox.com
Tue Jan 23 12:05:00 EST 2007

Jose Luis Gomez Dans wrote:
> Hi! I use gdal_rasterize a lot. There is one thing which would be great,
> which tothe best of my knowledge, isn't yet possible without iddling with
> things. This is to simply mask areas in a raster which are outside polygons.
> Is there a way of doing this with gdal_resize (other than rasterize the
> vector and implement the masking elsewhere)?


It's great to hear it is getting good use!  And yes, a the option you request
would be very very useful for masking - a very common use.  In the past I've
had to add an extra "world ring" around polygons to get this effect.

If you file a feature request for this feature in bugzilla I'll try and
implement it.

> Also, is there a file limit for gdal_rasterize? I have a pretty large
> polygon file (>900k polygons) which fails with an out of memory error (this
> is with gdal 1.3.2, I am yet to try the newer version).

The algorithm is setup such that all all the features from one input layer
are read into memory and then the raster is processed in chunks.  So it
should handle very large rasters reasonably well, but it won't scale up to
truely huge vector layers.

However, 900k of vector data is not alot.  Ah, perhaps you mean > 900000
polygons ... that is quite a few!  It might help if the algorithm discarded
polygons outside the area of the raster.

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 OSGeo, http://osgeo.org

More information about the Gdal-dev mailing list