0

I have used next command:

gdal_rasterize -burn 1 -tr 30 30 fire_2010.shp fireRaster2010.tif

to convert shapefile to raster. But I am getting no data in the raster. The same command works for another shapefile. The only difference I see is the polygons in this shapefile are small.

enter image description here

So, from the image it can be checked that fireRaster2010 has 0 0 [no values]. The fire2010 is a shapefile, and that is visible as blue colored patches.

here is the shapefile enter image description here

here is the raster file- no data. The values 0 0 in the Layer Panel signifies that there is no data in the file. All the values are zero. enter image description here

  • It could be an extent issue (please, see my answer). – xunilk Mar 28 '17 at 11:47
1

For rasterizing in fire studies is convenient that you first get polygon for layer extent that contain all years.

In my case, I considered three years (1990-1992) for Portugal case. That polygon at next image:

enter image description here

it has this extent:

xMin,yMin 82175,9600 : xMax,yMax 356140.00,572100.00

equivalent to:

-te 82175 9600 356140.00 572100.00

as parameter syntax of gdal_rasterize command.

Assuming the same raster resolution (-tr 30 30), my three gdal_rasterize commands are:

gdal_rasterize -burn 1 -te 82175 9600 356140.00 572100.00 -tr 30 30 fire_1990.shp fireRaster1990.tif
gdal_rasterize -burn 1 -te 82175 9600 356140.00 572100.00 -tr 30 30 fire_1991.shp fireRaster1991.tif
gdal_rasterize -burn 1 -te 82175 9600 356140.00 572100.00 -tr 30 30 fire_1992.shp fireRaster1992.tif

After running each one at the bash console, I loaded all resulting raster at Map View of QGIS. In the case of 1990 year, it can be observed (pseudocolor with two classes, Spectral ramp):

enter image description here

If I hide fire_1990 shapefile, I got a similar behavior as in your case: small areas look as not rasterized but they were.

enter image description here

Zoom an arbitrary zone where this behavior occurs, it permit to corroborate that they really exist.

enter image description here

I think that in your case could be an extent issue.

  • Thanks a lot xunilk for your reply. But I guess, there is difference what you rasterized. The values you got after rasterizing are either 0 or 1. There is data. What I am getting is a blank file. All values are 0. I have put the separate images of my shapefile and raster file. Thanks again – Sumedha Khatter Mar 29 '17 at 3:28
1

It's very likely an extent issue.

The values 0 0 in the Layer Panel signifies that there is no data in the file.

No, it does not. It only shows the values being used for coloring. You are using qgis, which, by default (at least for me), chooses default values for the style based on the 2% to 98% range of your data. I believe it does this to deal with outliers that could really skew the colors. But in this case, because your data is predominately 0 with only a few 1's, this range ends up being set as 0 0 for coloring purposes because the 1's are essentially being treated as outliers.

To check this you either need to manually set your color range to 0 1 in the properties for the layer, or you can use the identify tool (blue circle with an 'i' in it and a mouse cursor icon) to click individual pixels and see their values

  • Yes. You are exactly right. By using gdalinfo -hist <filename>, the file shows the histogram of all its values. So, my file had data, but it was showing 0 0 in QGIS. I sorted this out by changing the max value in QGIS. – Sumedha Khatter Apr 17 '17 at 19:20
  • Tip: You can change the behaviour settings to "Minimum/Maximum" in the settings > options > rendering > raster > limits if you find this gets annoying :-) – Steven Kay Apr 17 '17 at 20:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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