2

When i try to create contour lines from raster (tiff file) in QGIS 2.6.0 Brighton i get the following message: screenshot of error message

I thought it could be irregular size of raster that causes error so i clipped it in regular size but it did not help. I also tried to convert raster but it did not help either. When i take some other raster i create contour lines with no problems.

2 Answers 2

2

I also run into this with QGIS 3. The upper and lower values of my raster were normal but after finding a few posts with a similar issue my colleague suggested looking into setting the NoData value of the input raster to a different value. (The raster NoData was set to -3.40282306074e+38 which appears to be the ESR default)

Setting the NoData value to -999 as well as 32767 (NrCAN DEM NoData default) the process succeeded in both cases.

1

I had this same issue. After taking a closer look at my raster data (using gdal_info from the OSGeo4w shell), I discovered that there were very low negative minimum and very high maximum values, which I was not seeing in the metadata or histogram sections of the raster's properties in the QGIS table of contents. So, using gdal_calc, I eliminated the extremely low and high values through a couple expressions. My DEM had a natural maximum of 890 feet. And, I wanted to preserve nodata values as zero. So, the two expressions (using the OSGeo4w shell) were...

  1. gdal_calc --outfile="out_file_name_1.tif" -A "input_dem.tif" --calc="A*(A<890)"
  2. gdal_calc --outfile="out_file_name_2.tif" -A "out_file_name_1.tif" --calc="A*(A>0)"

Then, using "out_file_name_2.tif" as input into gdal_contour, it worked as expected.

When gdal_contour fails because of memory allocation, chances are either 1) your file is too large (which was not the case for me), 2) your contour interval is too small, or 3) the input raster has a large erroneous spike or trough causing excessive contours to be generated.

Hope this helps!

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.