# Overlay polygons on raster in different projections

I'm overlaying polygons on a raster to get the average value inside the polygon (using `SAGA->Shapes-Grid->Add grid values to shapes` in the QGIS Processing Toolbox), using a geographic and a projected coordinate system.

When I compare the average polygon values, they are different based on the projection. That is, when I use a polygon layer and raster in WGS84 (EPSG: 4326), I get one value. If I reproject both the polygon layer and the raster to MGA56 (EPSG: 28356) and redo the average calculation, I get different values for most of the polygons. Why is this? I feel that the average should be preserved. Is it because of the algorithm used to determine which raster cells are inside the polygon? Is one value "more correct" than the other?

• The difference will be minor and mostly caused by the process of projecting the raster from WGS84 to MGA56 (WGS84 UTM Zone 56s, it's interchangable +/- a few mm). In projecting you inevitably resample the raster based on an algorithm like Bilinear, Cubic.. this causes the values to change a very small amount hence the average will change. – Michael Stimson Mar 17 '15 at 1:39
• So the cells change ever so slightly? I can see that the reprojected raster does not overlap exactly with the original, while the reprojected vector does. My theory is that this affects which cells are considered to be inside the polygon by the overlay algorithm. For the case I'm comparing, the polygons are fairly small compared to the grid size (5-6 grid cells per polygon), which might increase the effect. – bananafish Mar 17 '15 at 1:47
• Yes, geographic cells are trapezoidal in projected coordinates, rasters must have rectangular cells so to project from geographic to projected spatial reference the raster is resampled from trapezoid to rectangle. There may be a slight difference between in/out pixels as the shape of the polygon will change slightly (narrowing in the X), this distortion is more evident as you move further away from the equator, as the shape is thinned the angles change and cells that were previously inside are no longer; to minimize this effect densify your polygons to prevent long edges. – Michael Stimson Mar 17 '15 at 2:01
• It is generally best practice to project the boundaries (vectors) to the coordinate system of the raster and not to project rasters if you can help it especially if you intend to perform some sort of analysis on it - keep it as you got it and if you must project something project the results of your analysis, which can also be problematic for classified rasters! Most modern GIS systems will let you project-on-the-fly to display so you can avoid projecting any rasters. – Michael Stimson Mar 17 '15 at 2:05
• Thanks for all the good points, really helpful. I am creating the raster myself as well, so I have the option of reprojecting the points to a projected coordinate system before interpolating the raster, and I want to know if this would be a "better" result or just a "slightly different" one. My original data is points in latlong (near Brisbane actually!) but within a small enough area that I could use MGA56. It sounds like this would not give a better result and I can stick with latlong. – bananafish Mar 17 '15 at 2:23