I am new to GRASS and Python and I have to convert a huge amount of *.xyz data into raster data using a batch process in GRASS. So far it works good, but when I put the created *.tif data into QGIS it looks like some kind of puzzle because of the different colors. Does anyone if there is a command for GRASS to get the DEM homogenous? I've already tried it with r.rescale.eq but that didn't solve the problem.

My code now looks like this

call r.in.xyz --overwrite -s -g input=%1 output=%2 > tmpRegion 
call SET /p myregion= < tmpRegion 
call DEL tmpRegion 
call g.region %myregion% res=1 
call r.in.xyz --overwrite input=%1 output=%2 separator="|" 
call r.out.gdal input=%2 type=Float32 output=%2.tif

and this is my resultenter image description here


This is a Qgis visualisation issue actually. Your tiles look this way because Qgis reads the max and min value for each file and creates a color ramp between those values. As your tiles changes, so does the terrain beneath.

You could use several ways to get a cleaner visualisation.

1. Qgis visualisation adjustment

Change 1 layer style (right click, properties, style), then edit min and max values to span your total altitude range (170-330 from your picture).

Then right click on that layer, styles, copy style. Next, for all the other layers, right click, styles, past style.

This might be cumbersome for a large number of layers.

2. Using VRT and catalog functions

You can create a .vrt (virtual layer) file to display all your tiles as one in the legend. This way, it is much easier to work with the data. The main advantage of .vrt is that it is a tiny file, which only links to your tiles.

To do so, use raster, miscellaneous, build virtual layer (catalog).

Add your tiles, then run it. You should now have only 1 layer, with no tiled output.

If needed, don't hesitate to build pyramids to improve display performance, but be aware that this might result in a huge file.

This might also be added in your code, though I couldn't provide you with the exact command line.

  • Thank you so far. Now when I use VRT and catalog functions i get a black background around the fields. Do you have a solution therefore? link – David Jun 19 '18 at 12:47
  • 1
    When creating the VRT there should be an option to set a NODATA value. – bugmenot123 Jun 19 '18 at 13:22
  • Either use the NoData option as @bugmenot123 said , or right click, properties, transparency, then add your NODATA value in the field. – Kantan Jun 19 '18 at 13:59
  • @David : Did it work for you? If so, please consider marking the question as accepted, by clicking on the green tick. It helps improving the website by telling future readers that this is the right way to solve the problem. Welcome to gis.Stackexchange! – Kantan Jun 20 '18 at 6:57

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.