-1

I try to create a raster layer from a line shape on canvas.

This raster layer band values should be equal and different from other cells. For instance the cells which consists line should be 0 other sides should be 1 - of course other side values should be equal, as well.

There is a tool which helps me about it?

enter image description here

closed as off-topic by PolyGeo Feb 21 '18 at 7:45

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions seeking help to debug/write/improve code must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Providing a clear problem statement and evidence of a code attempt will help others to help you. See: How to create a Minimal, Complete, and Verifiable example." – PolyGeo
If this question can be reworded to fit the rules in the help center, please edit the question.

1

Have a look to processing and gdal.

Using QGIS 2.18

https://docs.qgis.org/2.18/fr/docs/user_manual/processing/console.html

There is for your purpose one algorithm that fits well : gdal rasterize. You can use it as follow:

import processing

processing.runalg("gdalogr:rasterize","path/to/your/vector/layer.shp","area",1,100,100,"869423.623626,934698.45436,6310430.7313,6345492.27874",False,5,"",4,75,6,1,False,0,"",None)

for the many option see processing.alghelp("gdalogr:rasterize") in your console.

Using QGIS 3.0

Same principle with processing.run... You may want to have a look here : Using processing.runalg in QGIS 3

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