pythonrastershapelyrasterio

Does updating the resolution of a raster modify its bounds?


I'm new with geo data and rasters ...

I am using a library rasterio with Python to work with rasters. Currently, I have a raster with a certain resolution and corresponding bounds defined by its extent. I would like to change the resolution of the raster while preserving its original bounds.

I understand that updating the resolution of a raster may change the pixel size and potentially the number of pixels, but I'm not sure if it would affect the bounds of the raster.

Could someone please clarify whether updating the resolution of a raster would modify its bounds? If it does, what would be the appropriate approach to adjust the bounds to match the new resolution? If it doesn't, could you explain how the bounds remain intact?

Any insights or guidance would be greatly appreciated. Thank you!

I have searched through the documentation of the library and looked for relevant information, but I couldn't find a clear answer.


Solution

  • Since this is not a coding question it is not very appropriate for this site. A better place to ask about these things is gis.stackexchange.com

    But here you go. It depends on how you would do that. The most straightforward approach is to aggrege or disaggregate cells.

    Let's consider one row of raster cells. Say we have 10 cells between x coordinates 0 and 10. This makes the horizontal size of each cell (10-0)/10 = 1. If we doubled the cell size we would get 5 cells of size 10/5=2, and they would have the same extent (bounds).

    However, if we tripled the cell size the extent would have to change. We would either reduce the extent to 0-9 and get 3 cells (1-3, 4-6, 7-9); or we would expand the extent to 0-12 and get 4 cells (1-3, 4-6, 7-9, 10-12).

    So if you want to aggregate (decrease the resolution of a raster) but keep the same extent, you need to use a divisor (a number you can divide the number of rows or columns with, without getting a remainder) of the number of rows (for the vertical aggregation) and columns (for the horizontal aggregation). If you want to disaggregate (increase the resolution of a raster) you can use any whole number.

    If keeping the extent is very important you may want to "warp" from your original raster to a new raster with the desired extent and resolution. In that case the old and new raster cells do not need to align. The values for the new cells can be estimated with e.g. bilinear interpolation.