I have a height model of a quite big area saved in Esri ASCII grid files and a road network of this same area in a shapefile. I'd like to convert every height model value outside the road network to -999.999 (NODATA_value in my .asc-files), as I won't be needing them. This would reduce amount of data massively as I will later use only real values and forget those NODATA_values.

Is there any reasonable way to do this, for example in QGIS or ArcMap? Would it even be possible to have a few meters wide buffer around the roads, just to be sure that there will be every needed height value in the end?

  • Are you sure you want to make such a sparse matrix grid? Would it work for you if you simply overlayed roads with DTM (digital terrain model) to add elevation data to the road network layer?
    – U2ros
    Sep 4, 2012 at 12:35
  • 1
    As @sgrieve points out in an answer, this isn't going to do you much good, because in an ASCII file those NoData values have to be represented as some numerical value. The way to achieve huge space savings is to extract the heights for the road cells only, convert the result to integer format, and save it in native ESRI grid format (which uses run length encoding). You can expect around 99% compression depending on the cell size (smaller cells will result in more compression).
    – whuber
    Sep 4, 2012 at 12:37
  • I should have mentioned more clearly that this shapefile + ASCII grid is only temporary. Changing real heights to NoData will make .asc-files even larger than those were, but this helps because a script reads those grids and it skips all NoData values.
    – Jussi V
    Sep 5, 2012 at 7:33
  • This is not the best way to do this, but with advice from @sgrieve, I can get things working. It would be better to put that height data to shapefile, but right now I don't have time for modifications it would need (algo, gui, dataloader) in the app using this data.
    – Jussi V
    Sep 5, 2012 at 7:40

1 Answer 1


You can perform an extract by mask in Arcmap to extract the raster cells which fall within a masking polygon, in your case the road network.

If you want to buffer the road network first, you can run a simple buffer using the buffer Arcmap tool and then use the buffered road network as the mask to extract data with.

As a side note, if you are trying to reduce the size of these ASCII rasters, avoid spurious precision in your nodata values. If you change your nodata value from -999.999 to -9999, you will save a not insignificant amount of space in large rasters.

Your Answer

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

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