I have a large number of .asc DSM files which I'd like like to lower the vertical resolution for by two decimal places, preferably using a batch operation. I'm hoping this will reduce storage capacity needed and help speed up geoprocessing. Is there any way I can do this either in QGIS or windows command prompt?

To clarify: As an example, I'd like to go from a vertical reading of 1.161 to 1.2 (random raster cell example).

  • 1
    I didn't see your edit soon enough so i answered a bit differently. My method converts your data from float to integer, which is a good way to make data smaller and easier to manage. I'm not sure going from 1.161 to 1.2 will really change much. If really you want to do that, use a round() function, maybe, but i doubt it will change anything. – gisnside Aug 28 '17 at 20:00
  • Seems a bit similar to this one : gis.stackexchange.com/questions/146543/… – gisnside Aug 28 '17 at 20:08
  • 2
    ASCII is the 2nd worst image format that I've used (Gridded XYZ is the worst) for gobbling up disc space.. May I suggest you convert to a binary format, like ERDAS Img or GeoTIFF (can include lossless compression); Is there a reason for maintaining your images as ASCII raster? Do you have any python skills? What GDAL version does your QGIS use? gis.stackexchange.com/questions/86296/… – Michael Stimson Aug 28 '17 at 20:56
  • 1
    Depending on your GDAL version you can export AAIGRID (Esri ASCII) with the switch DECIMAL_PRECISION=1 to round the ASCII files as a batch operation; I would use python to seek out the files in a folder structure (os.walk()) which would save having to find them all. Another way to do the same is to use a command window and execute the command DIR *.ASC /B /S > C:\SOME\PATH\List.txt to get a list of all the ASCII files (full path) and write it to a list txt file.. One of those two options might save you some time when you get into it. – Michael Stimson Aug 28 '17 at 21:21
  • 1
    @user77875 " Would like to keep the 1 decimal place if possible" : is there a reason to stay in a float format ? Please note you don't loose data following my answer : you can still revert to your original float data at the end of your calculations by dividing the final results by a 10 factor * the number of decimal you rounded to. Exemple :if you go from 1.161 to 1161 in integer, it keeps the 3 decimals but reduce the data cost If you use a Erdas img, with the right settings, you can reduce even more the cost ;) – gisnside Aug 29 '17 at 5:28

The basic trick in this method is to use a Raster Calculator to multiply your raster by 100 then turn it from float to integer by specifying Int16 or Int32 in the output format. It should considerably decrease the size of your data.

You can use the GDAL calculator + batch process

batch gdal calculator

Or via the interface (button upper right)

raster calculator

Batch calculate

  • For keeping more decimals, just multiply by the number of decimals you need *10 (*10 for 1.2 > 12, *100 for 1.23 > 123, *1000 for 1.234 > 1234 for example) – gisnside Aug 28 '17 at 20:02
  • To go back to your original data, just divide by the number you used to multiply. – gisnside Aug 29 '17 at 5:29

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.