2

I want to change the shape extent of some shape files, I would like to know how to do it in QGIS, since I rasterized some shapes and when I used the calculator to add them, the resulting raster had deleted zones with null data... What i'm trying to do is to add the boolean rasters of the distribution of species into one, to obtain a single one that shows the # of species in a region....

The first image shows the resulting raster (after I use raster calc to add every raster), the second one is the raster I made of the original shape file I used to clip all of my shapes for the region. When I inspect the resulting raster, I get null values (the blue colored section, so the image seems incomplete...

2

If I understand you correctly: your REAL ISSUE is a difference between extents of RASTERS that you use in Raster calculator. And this difference cause loss of data beyond the extent of the smallest input raster. Of course you may fight it by assigning the same extent for all the shapes (and you will have to use scripting for this). But you should consider another approach: assign uniform extent for rasters. There is a 'How To' on this subject here, the key steps are:

  1. Firstly we need to create an empty georeferenced image with needed extent. Go to Raster | Miscellaneous | Build Virtual Raster. Here choose rasters A and B to become a virtual raster (VR) and do not define noData values. Add VR to the TOC.

  2. Now we will create a templates for expanded A and B. In Raster calculator (Raster | Raster calculator) insert expression: VR@1 * 0, highlight VR raster (by clicking on it) in Raster bands and click on Current layer extent button. Execute expression and save its result - it will be a template for raster A. Copy it to create template for raster B.

  3. Now lets change extent for A. In Raster calculator enter expression: A@1 this will simply leave A values unchanged. Then click on VR raster in Raster bands to highlight it and click a on Current layer extent button - this will set desired extent of the output raster. Save result as a template for A (overwrite existing file). Do the same for B.

  4. Now you have both A and B with the same extent and can freely perform calculations over them.

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.