The background,

The project requires the effect of thermal map. After comparing the thermal map effects generated by various combination of CESium and the limitation of large data amount, it is decided to load the thermal map by slice loading. The reasons are as follows:

1. If the amount of data is large, it takes more time to query from the front end through the background. 3000 pieces is very difficult, and the feasibility of more than 10000 pieces of data is not high.

2. There is also great pressure to add rendering to big data on the front end

Both of these problems can be solved if all the data is generated on the server to render images to the front end.

3.Geoserver can publish vector layers as raster layers. By setting the SLD (Geoserver style file), the layer can be displayed as a thermal map

I want this effect

Second, the steps

SLD set reference url to: docs.geoserver.org/latest/en/u…

First of all, you need to have a vector layer with weight. According to the fields in the vector layer, determine the influence range of the heat map. The following main content is to set the STYLE of SLD.

The < 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="vec:Heatmap"> <ogc:Function name="parameter"> <ogc:Literal>data</ogc:Literal> </ogc:Function> <ogc:Function name="parameter"> <ogc:Literal>weightAttr</ogc:Literal> <ogc:Literal>value</ogc:Literal> </ogc:Function> <ogc:Function name="parameter"> <ogc:Literal>radiusPixels</ogc:Literal> <ogc:Function name="env"> <ogc:Literal>radius</ogc:Literal> <ogc:Literal>10</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>the_geom</ogc:PropertyName></Geometry> <Opacity>0.6</Opacity> <ColorMap type="ramp" > <ColorMapEntry color="#FFFFFF" quantity="0" label="nodata" Opacity ="0"/> <ColorMapEntry color="#FFFFFF" quantity=" 0.02label ="nodata" opacity="0"/> <ColorMapEntry color="#4444FF" quantity=".1" label="nodata"/> <ColorMapEntry color="#FF0000" quantity=".5" label="values" /> <ColorMapEntry Color ="#FFFF00" quantity="1.0" label="values" /> </FeatureTypeStyle> </FeatureTypeStyle> </UserStyle> </NamedLayer> </StyledLayerDescriptor>Copy the code

The main aspects of SLD are:

Lines 14-15 define the render transformation, using the procedure VEc :Heatmap.

Lines 16-18 provide input data parameters, and data is named during the process.

Behavior 19-22 provides a value for the procedure weightAttr parameter that specifies the input attribute that provides the weight for each data point.

Lines 23-29 provide the radiusPixels parameter values, which control the “spread” of the heat map around each point. In this SLD, the value of this parameter can be provided by the SLD replacement variable named, and radius defaults to 100 pixels.

Lines 30-33 provide the pixelsPerCell parameter, which controls the resolution of the computed heat map grid.

Lines 34-38 provide the outputBBOX parameter, which gives the value of the standard SLD environment variable wMS_bbox.

Lines 40-45 provide the outputWidth parameter, which gives the value of the standard SLD environment variable wMS_width.

Lines 46-52 provide the outputHeight parameter, which gives the value wMS_height of the standard SLD environment variable.

Lines 55-70 specify aRasterSymbolizer to set the style to calculate the grid surface. Symbol contains a gradient color map of the data range [0..1].

Line 58 specifies the geometric attributes of the input element type, which are required to pass SLD validation

Third, the results

Iv. Problems arising

1. Regarding the color distinction between the transparent color around the thermal map and the 0 value in the data area, I want the effect that the color of 0 value is dark blue only in my data area, and the color outside the data area is transparent, otherwise the whole earth will be dark blue, which is not beautiful

Solution 1: Modify the range of the data area. No solution is found

Solution two: the data area of the 0 value of the database batch to 0.1, easy to achieve, temporary use this way

If you have a better idea, please leave a message or send a private message to me

Step 1: Batch change the database data 0 value to 0.1

Step 2: Modify the style by setting the 0 value transparency to 0 and the 0.1 value range to dark blue

The final style SLD is as follows:

The < 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>dc_heat</Name> <UserStyle> <Title>dc_heat</Title> <Abstract>A heatmap </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>value1</ogc:Literal> </ogc:Function> <ogc:Function name="parameter"> <ogc:Literal>radiusPixels</ogc:Literal> <ogc:Function name="env"> <ogc:Literal>radius</ogc:Literal> <ogc:Literal>2</ogc:Literal> </ogc:Function> </ogc:Function> <ogc:Function name="parameter"> <ogc:Literal>pixelsPerCell</ogc:Literal> <ogc:Literal>20</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>the_geom</ogc:PropertyName> </Geometry> <Opacity>1</Opacity> <ColorMap type="ramp" > <ColorMapEntry color="#0055ff" quantity="0" label="0000FF" Opacity ="0"/> <ColorMapEntry Color ="# 0028FF "quantity="0.0001" label=" 00FFFF "/> <ColorMapEntry Color ="# 6FC8DC" Quantity ="0.3" label=" 00FF00 "/> <ColorMapEntry color="# 00ffB2" quantity="0.3" label=" 00FF00 "/> <ColorMapEntry Color ="#ff9900" quantity="0.4" label="ffff00" /> <ColorMapEntry color="#ff0000" quantity="1" label="ff0000" /> </ColorMap> </RasterSymbolizer> </Rule> </FeatureTypeStyle> </UserStyle> </NamedLayer> </StyledLayerDescriptor>Copy the code

2. After the generated heat map is enlarged, the data turns into a grid, which is not beautiful, and the 3d model does not have the desired effect

Put the style file in

<ogc:Literal>pixelsPerCell</ogc:Literal> <ogc:Literal>20</ogc:Literal>

When you zoom in, it doesn’t look good. It’s a lump

How to plug ??????

3.Qgis can generate heat map effect, but do not support to export SLD file, a!

Reference: www.freesion.com/article/244…

You can also follow my CSDN blog, address