【问题标题】:Cut raster objects in PostGIS在 PostGIS 中剪切栅格对象
【发布时间】: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


【解决方案1】:

完成了。我需要创建约束以在表格列中加载空间信息。

我使用 PostGIS 函数“AddRasterConstraints”来解决问题

函数文档: http://postgis.net/docs/manual-2.2/RT_AddRasterConstraints.html

【讨论】:

    猜你喜欢
    • 2016-07-29
    • 2013-11-27
    • 2017-03-04
    • 1970-01-01
    • 2017-01-16
    • 2017-03-25
    • 2012-10-29
    • 1970-01-01
    • 2019-05-20
    相关资源
    最近更新 更多