# How to combine 2 vector shapes created from raster files

In Qgis 2.12 Lyon, using windows 10

I downloaded 2 raster files from an area of my interest. The rasters were on information about precipitation and evapotranspiration. Each cell had a value. I wanted to combine the information from both. It means: Calculate for each cell, the difference between precipitation and evapotranspiration. I didn't know why, but couldn't find the way to do it in raster files. So I thought, let's convert these files in vector polygon files, so each cell now becomes a polygon with a value. My intention was to have the attribute table with all the cells and do the difference with the calculator.

But the thing is, when I polygonized (converted the raster into vectors) Some of the cells, are grouped, so 3 cells form a polygon, making it difficul for me to create a combination, or a calculation, cell-by-cell.

These were the images for precipitation info. Look what happens with the ET:

My wish would be to combine both vector shapes, and calculate the difference for each cell, but if the polygons are each one different.... How could I do it?

I want to step back to your original intend of combining rasters. When you have both rasters loaded, then open Raster -> Raster Calculator from the menu.

In the next dialog you will see a list of currently available raster dataset. You can define an algebraic formula by simple clicking of raster bands from the upper left list, and operators. In the example below band 1 (the only one) of raster `w001002` is subtracted from band 1 of raster `w001008`. As you see in the next picture a cell from the resulting raster, here `w001008-1002`, contains exactly the difference.

You gave already the explanation for what happens when rasters are being converted to polygons: neighboring cells having the same value are grouped to zones.

If you really want to do raster algebra with polygons, you first have to `union` the polygon layers. This will intersect polygons from both layers and join there attributes. Then you can use field calculator to do the same math with field values.

• thanks sooo much. I think I was trying to complicate myself more than needed. It is clear that the solution was so much simple than what I was trying to do. I tried it with my 2 rasters and yes, it worked. – Alex Fernández Poulussen Jan 25 '16 at 16:23