GeoServer发布Heatmap
转自原文 GeoServer发布Heatmap
百度等热力图是使用开源的heatmap.js做的,但是这种解决方案的缺陷是:
1 数据量大的话,从前端通过后台查询比较费时,比如arcserver默认设置返回1000条查询记录,3000条就很卡了,对动辄上万多数据可行性不高。
2 前端对大数据添加渲染压力也大。
如果所有的数据在服务端生成渲染图片输出到前端,这两个问题都迎刃而解。
本文便阐述如何使用geoserer在服务端生成热力图,返回前端地图显示。
一 环境部署
正常部署geoserver,本次版本是2.6
下载地址:http://geoserver.org/release/stable/
另外要下载
Extensions的wps扩展插件。
解压wps,将jar包放进geoserver部署的web-INF/lib中,重启geoserver。
二 生成热力图的样式文件heatmap.sld
<?xml version="1.0" encoding="ISO-8859-1"?>
<StyledLayerDescriptor version="1.0.0"
xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd"
xmlns="http://www.opengis.net/sld"
xmlns:ogc="http://www.opengis.net/ogc"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<NamedLayer>
<Name>Heatmap</Name>
<UserStyle>
<Title>Heatmap</Title>
<Abstract>A heatmap surface showing population density</Abstract>
<FeatureTypeStyle>
<Transformation>
<ogc:Function name="gs:Heatmap">
<ogc:Function name="parameter">
<ogc:Literal>data</ogc:Literal>
</ogc:Function>
<ogc:Function name="parameter">
<ogc:Literal>weightAttr</ogc:Literal>
<ogc:Literal>jan_je</ogc:Literal>
</ogc:Function>
<ogc:Function name="parameter">
<ogc:Literal>radiusPixels</ogc:Literal>
<ogc:Function name="env">
<ogc:Literal>radius</ogc:Literal>
<ogc:Literal>100</ogc:Literal>
</ogc:Function>
</ogc:Function>
<ogc:Function name="parameter">
<ogc:Literal>pixelsPerCell</ogc:Literal>
<ogc:Literal>10</ogc:Literal>
</ogc:Function>
<ogc:Function name="parameter">
<ogc:Literal>outputBBOX</ogc:Literal>
<ogc:Function name="env">
<ogc:Literal>wms_bbox</ogc:Literal>
</ogc:Function>
</ogc:Function>
<ogc:Function name="parameter">
<ogc:Literal>outputWidth</ogc:Literal>
<ogc:Function name="env">
<ogc:Literal>wms_width</ogc:Literal>
</ogc:Function>
</ogc:Function>
<ogc:Function name="parameter">
<ogc:Literal>outputHeight</ogc:Literal>
<ogc:Function name="env">
<ogc:Literal>wms_height</ogc:Literal>
</ogc:Function>
</ogc:Function>
</ogc:Function>
</Transformation>
<Rule>
<RasterSymbolizer>
<!-- specify geometry attribute to pass validation -->
<Geometry>
<ogc:PropertyName>geom</ogc:PropertyName></Geometry>
<Opacity>0.6</Opacity>
<ColorMap type="ramp" >
<ColorMapEntry color="#0000FF" quantity="0" label="nodata" opacity="0"/>
<ColorMapEntry color="#00FFFF" quantity="0.02" label="nodata"
opacity="0"/>
<ColorMapEntry color="#00FF00" quantity=".1" label="nodata"/>
<ColorMapEntry color="#FFFF00" quantity=".5" label="values" />
<ColorMapEntry color="#FF0000" quantity="1.0" label="values" />
</ColorMap>
</RasterSymbolizer>
</Rule>
</FeatureTypeStyle>
</UserStyle>
</NamedLayer>
</StyledLayerDescriptor>
weightAttr标签指定权重字段,在这里我设置weightAttrz权重字段名称为jan_je。colormap中的热力图符号和范围设置,也是可以改和设置的。
而<ogc:PropertyName>geom</ogc:PropertyName></Geometry>这里是指定渲染的图形字段,查看数据库空间数据表的图形字段名称,如果是geom就写geom,如果是the_geom就写the_geom,根据自己数据库中图形字段名称来。在geoserver>styles中发布这样的一个sld文件。
三 测试
3.1 使用geoserver发布一个点图层,加载sld
default style那设置发布的sld文件。
确定,发布。
3.2 openlayer加载wms点图层
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>热力图展示</title>
<!-- Import OL CSS, auto import does not work with our minified OL.js build -->
<!--<link rel="stylesheet" type="text/css" href="http://localhost:8090/geoserver/openlayers/theme/default/style.css"/>-->
<link rel="stylesheet" href="openlayers/theme/default/style.css" type="text/css">
<script src="openlayers/OpenLayers.js"></script>
<!-- Basic CSS definitions -->
<style type="text/css">
/* General settings */
body {
font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
font-size: small;
} /* The map and the location bar */
#map {
clear: both;
position: relative;
width: 1000px;
height: 600px;
border: 1px solid black;
} </style>
<!-- Import OpenLayers, reduced, wms read only version -->
<!--<script src="http://localhost:8090/geoserver/openlayers/OpenLayers.js" type="text/javascript"></script>-->
<script defer="defer" type="text/javascript">
var map;
var untiled; // pink tile avoidance
OpenLayers.IMAGE_RELOAD_ATTEMPTS = 5;
// make OL compute scale according to WMS spec
OpenLayers.DOTS_PER_INCH = 25.4 / 0.28; function init(){
// if this is just a coverage or a group of them, disable a few items,
// and default to jpeg format
format = 'image/png'; var bounds = new OpenLayers.Bounds(
13218259.7875, 3713786.7208,
13355533.9608, 3805832.0664
);
var options = {
controls: [],
maxExtent: bounds,
maxResolution: 536.2272394531246,
projection: "EPSG:3857",
units: 'm'
};
map = new OpenLayers.Map('map', options); // setup tiled layer
/*
tiled = new OpenLayers.Layer.WMS(
"cite:v_zhenjiang - Tiled", "http://localhost:8090/geoserver/cite/wms",
{
"LAYERS": 'cite:v_zhenjiang',
"STYLES": '',
format: format
},
{
buffer: 0,
displayOutsideMaxExtent: true,
isBaseLayer: true,
yx : {'EPSG:3857' : false}
}
);*/ // setup single tiled layer
untiled = new OpenLayers.Layer.WMS(
"cite:v_zhenjiang - Untiled", "http://localhost:8090/geoserver/cite/wms",
{
"LAYERS": 'cite:v_zhenjiang',
"transparent":"TRUE",
"STYLES": '',
format: format
},
{
singleTile: true,
ratio: 1,
isBaseLayer: false,
yx : {'EPSG:3857' : false}
}
); var osmlayer = new OpenLayers.Layer.OSM( "osm");
map.addLayers([untiled,osmlayer]);
// build up all controls
map.addControl(new OpenLayers.Control.PanZoomBar({
position: new OpenLayers.Pixel(2, 15)
}));
map.addControl(new OpenLayers.Control.Navigation());
map.addControl(new OpenLayers.Control.MousePosition());
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.zoomToExtent(bounds);
/*map.setCenter(
new OpenLayers.LonLat(119.45, 32.2).transform(
new OpenLayers.Projection("EPSG:4326"),
map.getProjectionObject()
), 15
);*/ } </script>
</head>
<body onload="init()"> <div id="map"> </div>
</body>
</html>
四 效果图
GeoServer发布Heatmap的更多相关文章
- geoServer 发布geoTiff格式的DEM数据
1/数据下载(首先感谢earthexplorer提供了免费的全球DEM数据) 下载地址 https://lta.cr.usgs.gov/GTOPO30 ,首先要注册才可以下载,登陆网站后点击get ...
- 01:Geoserver发布shapfile,中文字段乱码问题
软件环境:Geoserver 2.1.0 UDig 1.2.1 shapfile文件结构:FID 地物名称 变化图斑 ...
- Geoserver发布WMS服务出错分析
使用Geoserver发布一个空间表,在图层预览的过程中没有任何问题,但是当我根据这个空间表传创建视图再发布wms服务,访问时就会报错,错误信息如下: Caused by: java.sql.SQLE ...
- geoserver发布瓦片,geoserver发布arcgis切片和geoserver发布金字塔切片
1 转https://www.jianshu.com/p/cf046ec1efd2,分享使用geoserver发布arcgis切片 2 转 http://www.it610.com/article/1 ...
- 使用openlayers 3 在线加载天地图及GeoServer发布的地图
使用openlayers3来加载天地图卫星图和标注图层,GeoServer发布地图,一并用openlayers测试加载出来,顺便实现了7种地图控件.下面直接贴代码: <!DOCTYPE html ...
- geoserver 发布无坐标png
1.geoserver 安装一些插件的时候,直接去http://docs.geoserver.org/ 官网,选择自己geoserver对应的版本的插件就可以了. 2.geoserver 发布自身带有 ...
- 使用GeoServer发布shp数据为WMS服务和WFS服务
使用GeoServer发布shp数据为WMS服务和WFS服务 1安装GeoServer 2使用GeoServer上传数据 3使用GeoServer发布数据为WMS和WFS 看完本教程,你将学会安装Ge ...
- openlayer3 加载geoserver发布的WFS服务
转自原文 openlayer3加载geoserver发布的WFS服务 openlayers3调用GeoServer发布的wfs 1 参考一 1.1 问题 openlayer3加载WFS存在跨域问题,需 ...
- Cesium调用Geoserver发布的 WMS、WFS服务
1 GeoServer服务发布 1.1 WMS服务 下载GeoServer安装版安装,同时安装geopackage扩展,以备使用.使用XX地图下载器下载地图,导出成GeoPackage地图文件. (1 ...
随机推荐
- PAT 乙级 1009
题目 题目地址:PAT 乙级 1009 题解 本题本身属于比较简单的字符串操作题,但是因为对于string的操作和函数不熟悉导致本题做起来很费劲,需要加强对于string类以及相关方法的理解和熟练程度 ...
- 使用 ss 命令查看连接信息
作用:打印主机socket连接信息,netstate可以做的它都可以做,比netstate 更灵活,而且由于ss使用 tcp_diag 内核模块,所以速度更快. 用法: ss [ OPTIONS ] ...
- GIMP素描效果
1/打开图片,拖动图片到GIMP软件 2/复制两次图层 3/选中最上面的一个图层,mode改为Dodge 4/点击Color,选择Invert,可以看到图片变淡了 5/点击Filters,Distor ...
- python爬虫入门四:BeautifulSoup库(转)
正则表达式可以从html代码中提取我们想要的数据信息,它比较繁琐复杂,编写的时候效率不高,但我们又最好是能够学会使用正则表达式. 我在网络上发现了一篇关于写得很好的教程,如果需要使用正则表达式的话,参 ...
- scheduleWithFixedDelay和scheduleAtFixedRate源码分析
先放张图,有兴趣的话我再加细节说明. scheduleWithFixedDelay和scheduleAtFixedRate的执行流程都是一样的,如下 ScheduledThreadPoolExecut ...
- NOS跨分区灾备设计与实现
本文来自网易云社区 作者:王健 摘要 NOS(网易对象存储)在实现多机房(杭州机房,北京机房等)部署后,允许一个用户在建桶时选择桶所属机房.在此基础上,我们实现了跨机房的数据复制,进一步实现了跨机房的 ...
- Leetcode 376.摆动序列
摆动序列 如果连续数字之间的差严格地在正数和负数之间交替,则数字序列称为摆动序列.第一个差(如果存在的话)可能是正数或负数.少于两个元素的序列也是摆动序列. 例如, [1,7,4,9,2,5] 是一个 ...
- HDU-4847 Wow! Such Doge!,模拟!
Wow! Such Doge! 题意:给定的字符串中doge出现了多少次,直接模拟即可,不用KMP. char s[N]; int main() { // int n; int ans=0; whil ...
- LeetCode--二分查找相关算法
-(1)有一个升序排列的非负数组,要求利用o(logn)的时间复杂度找到数组中确定数字target的第一次出现的位置下标和最后一次出现的位置下标,如果不存在该target返回[-1,-1] 解决方案: ...
- Maven部署异常:on project standalone-pom: Cannot deploy artifact from the local repository解决方法
MAVEN部署异常 org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache. ...