postgis - 如何在 PostGIS 数据库中存储值网格,以便 GeoServer 可以绘制轮廓?

标签 postgis contour geoserver

我计划将 GeoServer 与 PostGIS 数据库结合使用,以通过 Web map 服务提供等高线。

我有一个简单的经纬度值网格,我想将其存储在数据库中并绘制轮廓。虽然 GeoServer 用户手册暗示在此示例中是可能的...

https://docs.geoserver.org/stable/en/user/styling/sld/extensions/rendering-transform.html#contour-extraction

...它没有讨论数据应该采用什么格式。请有人能建议一个合适的 PostGIS 数据库模式,我可以使用 GeoServer 理解并能够绘制轮廓吗?最好是一个可以与上面链接中的 GeoServer 示例一起使用的。

感谢您的帮助。

最佳答案

由于您的数据已经在 J​​ava 程序中,我将深入研究 GeoTools这是 GeoServer 的基础库用来做实际工作。

查看ContourProcess你真正需要的是 GridCoverage2D这是对二维渲染图像支持的网格数据值的基本访问。图像中的每个波段都表示为样本维度。

所以你想要获取数据数组并执行如下操作:

WritableRaster raster2 = RasterFactory.createBandedRaster(java.awt.image.DataBuffer.TYPE_INT, w,
    h, 1, null);
for (int i = 0; i < w; i++) {//width...
     for (int j = 0; j < h; j++) {
         raster2.setSample(i, j, 0, myData[i*w+j]);
     }
}
GridCoverageFactory gcf = new GridCoverageFactory();
// Here I'm using OSGB as I live in the UK you would be using something else
CoordinateReferenceSystem crs = CRS.decode("EPSG:27700");
// Position of Lower Left Corner of grid
int llx = 500000;
int lly = 105000;
// Pixel size in projection units
int resolution = 10;
ReferencedEnvelope referencedEnvelope = new ReferencedEnvelope(llx, llx + (w * resolution), lly, lly + (h * resolution),
    crs);
GridCoverage2D gc = gcf.create("name", raster2, referencedEnvelope);

然后您可以将其写成 GeoTiff 或将以上所有内容包装到 a new Process 中返回轮廓。

关于postgis - 如何在 PostGIS 数据库中存储值网格,以便 GeoServer 可以绘制轮廓?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59632884/

相关文章:

gis - PostGIS/CartoDB : Store Timestamp for each point in a MultiLineString

python - 如何将多个 gpx 文件加载到 PostGIS 中?

python - OpenCV变换图像形状变换为给定的轮廓

Python:根据 1 和 0 的数组计算结构的面积和周长

postgresql - 如何从postGIS中的给定gps坐标获取范围内的所有建筑物名称?

python - 相关模型的 GeoDjango 距离

geoserver - 带时间参数的 WFS GetFeature 查询不会在 geoserver 中过滤

Hadoop 和地理服务器

python - Matplotlib 三色错误?

gis - 如何将自定义数据源添加到GeoServer WMS服务?