[gdal-dev] About gdal RasterizeLayer

jratike80 jukka.rahkonen at maanmittauslaitos.fi
Tue May 4 12:41:06 PDT 2021


I tried if someone who don't know Python could do about the same with
gdal_rasterize https://gdal.org/programs/gdal_rasterize.html and I had some

gdal_rasterize -dialect sqlite -sql "select st_buffer(geometry,0.01) from
states" -burn 100 -of GTIFF -ot byte -tr 0.1 0.1 -add states.shp

I used byte type and burn value 100 for making quick visible result. The
default type is Float64 and it has room for much more overlapping geometries
than two.

-Jukka Rahkonen-

Frank Warmerdam wrote
> Miguel,
> I can't seem to find this in the docs, but I think what you want is
> "MERGE_ALG" set to ADD instead of the default REPLACE.
> https://github.com/OSGeo/gdal/blob/master/gdal/alg/gdalrasterize.cpp#L1165
> This doesn't address the buffering (I guess you might still want to buffer
> the whole set), but it should take care of the additive step.
> I actually implemented this as part of a programming test for my current
> job - to build heatmaps of satellite coverage.
> Best regards,
> Frank
> On Tue, May 4, 2021 at 1:30 PM Miguel A. Manso <

> m.manso@

> > wrote:
>> Dear all
>> I have a multiline layer type (tracking) and I want to make a heat map
>> (densities) on a buffer of them, so that in those places where several
>> buffers overlap the density is added as many times as lines overlap.
>> Now I'm doing it with a python script that reads from a shp the lines,
>> generates a buffer and rasterize the polygon filling it with a given
>> value with gda.RasterizeLayer(). I read the image as an array and with
>> numpy I add it to another array (accumulating). When I finish I convert
>> it to an image and save it in a geotiff.
>> This procedure is relatively slow. Especially if you have to do it for
>> many lines.
>> My question is along the lines of whether the RasterizeLayer function
>> itself could do this process in a more efficient way, making the burning
>> of the objects not an OR operation but an arithmetic sum...
>> Any suggestions would be welcome.
>> Regards
>> Miguel A. Manso
>> _______________________________________________
>> gdal-dev mailing list

> gdal-dev at .osgeo

>> https://lists.osgeo.org/mailman/listinfo/gdal-dev
> -- 
> ---------------------------------------+--------------------------------------
> I set the clouds in motion - turn up   | Frank Warmerdam,

> warmerdam@

> light and sound - activate the windows | +1 650-701-7823
> and watch the world go round - Rush    | Geospatial Software Developer
> _______________________________________________
> gdal-dev mailing list

> gdal-dev at .osgeo

> https://lists.osgeo.org/mailman/listinfo/gdal-dev

Sent from: http://osgeo-org.1560.x6.nabble.com/GDAL-Dev-f3742093.html

More information about the gdal-dev mailing list