3

I try to change the GeoTools HeatmapProcess.java and HeatmapSurface.java classes (https://github.com/geotools/geotools/tree/master/modules/unsupported/process-feature/src/main/java/org/geotools/process/vector), so that the resulting Heatmap can be displayed as a tiled WMS request without the cut off edges:

enter image description here

Anybody has an hint, what I have to change in the code to enable this?

My idea was the problem lies in the coordinate -> grid transformation to calculate the kernel density grid. I tried to increase the buffer radius of the grid calculation for each tile so that all points are included which are within the Kernel Density radius.

So far I tried to change the HeatmapSurface.java class by increasing the grid size by 100, increase the point offset by 50 and extract the grid respectively just for testing purposes but it doesn't have the intended effect:

private void init() {

    gridTrans = new GridTransform(srcEnv, xSize, ySize);

    gridTrans.setClamp(false);
    gridTrans2.setClamp(false);

    int xSizeExp = (xSize + 2 * kernelRadiusGrid) + 100;
    int ySizeExp = (ySize + 2 * kernelRadiusGrid) + 100;


    grid = new float[xSizeExp][ySizeExp];

}
public void addPoint(double x, double y, double value)
{

    int gi = gridTrans.i(x) + kernelRadiusGrid + 50;
    int gj = gridTrans.j(y) + kernelRadiusGrid + 50;

    if (gi < 0 || gi > grid.length || gj < 0 || gj > grid[0].length)
        return;


    grid[gi][gj] += value;

public float[][] computeSurface() {

    computeHeatmap(grid, kernelRadiusGrid);

    float[][] gridOut = extractGrid(grid, kernelRadiusGrid + 50, kernelRadiusGrid + 50, xSize, ySize);

    return gridOut;
}
4
  • Fundamentally the issue is with the tiling.
    – nmtoken
    Commented Jun 26, 2017 at 19:36
  • Coudl'nt you theoretically calculate the whole heatmap for each tile and put them together afterwards defining just the bbox which is needed from that tile?
    – Andrej
    Commented Jun 27, 2017 at 8:06
  • you could but you would have to calculate the whole heat map for each tile request. I guess some sort of metatiling technique might work depending on the heat map parameters but it would still be very slow to calculate.
    – Ian Turton
    Commented Jun 27, 2017 at 8:21
  • Thanks for the tip. Metatiling works and I have no more artifacts. Still I would like to solve the problem on the heatmap process side. It shouldn't be too hard to calculate a heatmap for each tile which exactly fits the neighbouring tile? It just needs to take into account all points in a certain buffer radius around the tile...
    – Andrej
    Commented Jun 28, 2017 at 15:45

1 Answer 1

1

As currently designed the GeoTools heat map code is designed to produce a quick and dirty heat map based on the data in the bounds of the requested map. You can probably manage to avoid gross issues with widely scattered data such as you have with the careful application of metatiling.

In general you will be better off using an external process to create a map of your heat map and then tiling it as usual with GeoServer and GeoWebCache.

If you want to make any sort of scientific use of heat maps you should take a look at my spatial clustering code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.