【发布时间】:2016-03-27 13:12:50
【问题描述】:
我正在尝试使用带有参考的 shapefile 切割栅格对象(来自 PostGIS 表),从多边形区域中提取栅格数据。我的目标是将裁剪栅格放入 R 中。
我是这样剪的:
CREATE TABLE clippingtable as (SELECT (ST_Union(ST_Clip(raster.rast, ST_Transform(polygon.geom, ST_SRID(raster.rast) ) ) ) )
FROM originalraster as raster, originalshape as polygon
WHERE ST_Intersects(raster.rast, polygon.geom))
gdalinfo 输出为:
$gdalinfo "PG:host=localhost port=5432 dbname='testdb' schema='public' table=clippingtable"
ERROR 1: Error retrieving raster metadata
gdalinfo failed - unable to open 'PG:host=localhost port=5432 dbname='testdb' schema='public' table=clippingtable'.
在 R 中我正在使用这些函数:
dsn="PG:dbname=testdb host=localhost port=5432 table=clippingtable"
rgdal::GDALinfo(dsn)
readGDAL(dsn)
输出是: “.local(.Object, ...) 中的错误:检索栅格元数据时出错”
在原始表中(切割前)我可以正常使用我的光栅。
知道我做错了什么吗?
谢谢。
【问题讨论】:
-
你可以使用光栅包中的
crop吗?您可以简单地使用readOGR然后crop读取shapefile。
标签: r postgis raster shapefile clipping