8

I'm attempting to make the full switch from ArcGIS to QGIS, but there are a few snags I'm hitting along the way, one of which is in the GDAL "Rasterize" function. My process goes like this: I have a raster which I convert to point file using SAGA "Raster values to points" which creates a point at the centroid of each pixel (with XY coordinates as attributes). I then run a function on this dbf outside of QGIS (in R). Then I want to convert the point file back into a raster. I use the GDAL "Rasterize", but this uses the points as vertices, effectively shifting the raster by half a pixel down and to the right. By comparison, ArcGIS views the point as the centroid, and using the "point to raster" returns a raster that lines up with the original. How can I tell QGIS that the point is the centroid?

I have tried the roundabout way of making a VRT, but as the pixels are shifted exactly half a pixel, the resultant raster is shifted an additional half-pixel down and to the right (so now the pixel vertices line up, but are shifted a complete pixel diagonally down and to the right).

1
  • Huh, so I was not the only person puzzled by this! I have no idea how to solve this. As alternative the xyz2grd tool from GMT allows conversion of ascii grids to cdf (which you can then easily use in QGIS or convert in GDAL). This tool uses the points as centroids of the raster cells. Commented Jul 16, 2016 at 15:59

1 Answer 1

2

I haven't tested it, but I would use the following methods:

Are the X and Y coordinates exported to your table? If not, add the coordinates to the attribute table before you start your calculations.

During your transformation to points, the pixel size became the horizontal and vertical distance between adjacent points. Measure this distance value and divide by half. Then use this new value to subtract it from your x coordinates (moving the point half a pixel to the left) and add it to your y coordinates (moving the point half a pixel upwards). You can use the Field Calculator for these changes.

Now your data is ready to be rasterized.

1
  • 1
    Thanks, yes, I figured out that way, too. That's the best way I've come up with to do it in QGIS. With millions of pixels, it was a lot faster to do the point shift outside of QGIS (I used R, but just within Excel would probably be fine). Either way the map needs to be loaded again, specifying the new, shifted x and y columns. This gets the job done, but it's so convoluted and messy (multiple csv files with the same info=room for human error) that I open ArcGIS just to do this one operation
    – user77942
    Commented Dec 12, 2016 at 15:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.