更新光栅的分辨率是否会修改其边界?

huangapple go评论68阅读模式
英文:

Does updating the resolution of a raster modify its bounds?

问题

我是新手,对地理数据和栅格数据不太熟悉...

我正在使用Python中的rasterio库来处理栅格数据。目前,我有一个具有特定分辨率和由其范围定义的相应边界的栅格。我想改变栅格的分辨率,同时保持其原始边界不变。

我理解更新栅格的分辨率可能会改变像素大小,潜在地改变像素的数量,但我不确定它是否会影响栅格的边界。

请问有人能否澄清一下,更新栅格的分辨率是否会修改其边界?如果会,应该如何调整边界以匹配新的分辨率?如果不会,您能解释一下边界是如何保持不变的吗?

非常感谢任何见解或指导。谢谢!

我已经查阅了该库的文档并寻找相关信息,但没有找到明确的答案。

英文:

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.

答案1

得分: 1

因为这不是一个编码问题,所以在这个网站上提问不太合适。一个更好的地方来询问这些问题是 gis.stackexchange.com。

但是在这里,我可以告诉你。这取决于你要如何操作。最直接的方法是对单元格进行聚合或分解。

让我们考虑一行栅格单元格。假设在x坐标0到10之间有10个单元格。这使得每个单元格的水平尺寸为(10-0)/10 = 1。如果我们将单元格大小加倍,我们将得到5个尺寸为10/5=2的单元格,它们将具有相同的范围(边界)。

然而,如果我们将单元格大小增加三倍,范围就必须改变。我们可以将范围减小到0-9并获得3个单元格(1-3、4-6、7-9);或者我们可以将范围扩展到0-12并获得4个单元格(1-3、4-6、7-9、10-12)。

因此,如果你想要聚合(降低栅格的分辨率)但保持相同的范围,你需要使用行数(用于垂直聚合)和列数(用于水平聚合)的除数(一个可以除以行数或列数而不产生余数的数字)。如果你想要分解(增加栅格的分辨率),你可以使用任何整数。

如果保持范围非常重要,你可能希望从原始栅格到具有所需范围和分辨率的新栅格进行“扭曲”。在这种情况下,旧栅格和新栅格单元格不需要对齐。可以使用双线性插值等方法估算新单元格的值。

英文:

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.

huangapple
  • 本文由 发表于 2023年7月11日 00:55:00
  • 转载请务必保留本文链接:https://go.coder-hub.com/76655835.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定