2

I need to make a raster from a polyline shapefile. However, when I use gdal_rasterize (either directly or through QGIS), all my lines are drawn one pixel wide, while I need them to be drawn with the stroke weight of 3. I've examined the documentation at http://www.gdal.org/gdal_rasterize.html, but couldn't find a parameter to do so.

I have in mind some workarounds, but is there a simpler way to do so? My workarounds are: - render a raster 9 times smaller and blow it up - write a script that reads the raster and outputs a 3x3 block into another raster whenever it reads a non-zero pixel

2
  • You could potentially use a buffered geometry to get your results, although that is not a certain solution.
    – user10353
    Commented May 18, 2014 at 23:21
  • I recommend to make a feature request for gdal_rasterize. It feels reasonable that it could be made to utilize at least partly the style definitions configured with OGR_STYLES gdal.org/ogr/ogr_feature_style.html.
    – user30184
    Commented May 19, 2014 at 5:47

2 Answers 2

2

Hope this one helps.

Use GDAL rasterize to conver polyline to raster, then it is possible to run r.neighbors with a 3 (by 3) sized neighbourhood. see also in this post.

This is my result on some lines drew on WGS84. This is only a snapshot but the method works for all featurs and/or raster cells. Original polyline colored yellow, in black are the polyline to raster result. Then layered underneeth in red is the last raster with a 3 pixel "buffer".

example

It quite similar to the workaround you have suggested, but enable you to drop scripting and use GRASS tool instead. I find it to be most intuitive way to handle such a problem.

1

Line features do not have a width in GIS. It is the styling that makes them thicker (as you need it).

You can make a buffer around your line elements to get polygons with a defined width.

But note that this is in map units, while the width of the line is in pixels.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.