跳转至
🎉 SedonaDB 0.4.0 已正式发布!🗺️ 新增 Python DataFrame API、R dplyr 接口、Geography 支持及 GPU 加速空间连接。阅读发布博客 →

RS_WorldToRasterCoord

Introduction: Returns the grid coordinate of the given world coordinates as a Point.

RS_WorldToRasterCoord

Format:

RS_WorldToRasterCoord(raster: Raster, point: Geometry)

RS_WorldToRasterCoord(raster: Raster, x: Double, y: Point)

Return type: Geometry

Since: v1.5.0

SQL Example

SELECT RS_WorldToRasterCoord(ST_MakeEmptyRaster(1, 5, 5, -53, 51, 1, -1, 0, 0, 4326), -53, 51) from rasters;

Output:

POINT (1 1)

SQL Example

SELECT RS_WorldToRasterCoord(ST_MakeEmptyRaster(1, 5, 5, -53, 51, 1, -1, 0, 0, 4326), ST_GeomFromText('POINT (-52 51)')) from rasters;

Output:

POINT (2 1)

Note

If the given geometry point is not in the same CRS as the given raster, the given geometry will be transformed to the given raster's CRS. You can use ST_Transform to transform the geometry beforehand.