纬度/经度点的PostGIS栅格值


13

我的PostGIS 2.0数据库中有一个tiff栅格。我想获取指定纬度/经度点的栅格值。

我有:

  • PostgreSQL的9.1
  • 具有栅格支持的postgis-2.0-svn
  • 导入PostGIS的栅格,其SRID为3035

Answers:


11

您可以使用ST_Transform()将纬度/经度点即时转换为栅格CRS。合并后,查询看起来像这样:

ST_Value(your_raster, ST_Transform(ST_SetSRID(ST_MakePoint(lon,lat),4326),3035))


4

当ST_Value工作时,您仍然还需要在空间上连接到该点:

SELECT ST_Value(your_raster.rast, ST_Transform(ST_SetSRID(ST_MakePoint(lon,lat),4326),3035))
FROM your_raster
WHERE ST_Intersects(your_raster.rast, ST_SetSRID(ST_MakePoint(lon,lat),4326),3035))

或搭配桌子:

SELECT ST_Value(your_raster.rast, ST_Transform(ST_SetSRID(ST_MakePoint(your_table.lon,your_table.lat),4326),3035))
FROM your_raster
JOIN your_table ON ST_Intersects(your_raster.rast, ST_SetSRID(ST_MakePoint(your_table.lon,your_table.lat),4326),3035))
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.