GithubHelp home page GithubHelp logo

Heatmap from GeoJSON about leaflet.heat HOT 10 CLOSED

leaflet avatar leaflet commented on May 27, 2024
Heatmap from GeoJSON

from leaflet.heat.

Comments (10)

tayden avatar tayden commented on May 27, 2024

I'm also interested in this

from leaflet.heat.

sergei-maertens avatar sergei-maertens commented on May 27, 2024

Yeah, me too

from leaflet.heat.

ryankdalton avatar ryankdalton commented on May 27, 2024

This would be a great enhancement!

from leaflet.heat.

brianrusso avatar brianrusso commented on May 27, 2024

+1

from leaflet.heat.

xuejinruan avatar xuejinruan commented on May 27, 2024

I am also looking for the support of GeoJson data for heatmap. If we could optionally choose any attribute field as weighting factor, that would be ever better! Thanks!!!

from leaflet.heat.

mattesCZ avatar mattesCZ commented on May 27, 2024

I think this plugin should have as simple API as possible. You can always transform your GeoJSON data with simple function like this:

function geoJson2heat(geojson, intensity) {
  return geojson.features.map(function(feature) {
    return [
      feature.geometry.coordinates[0][1],
      feature.geometry.coordinates[0][0],
      feature.properties[intensity]
    ];
  });
}

from leaflet.heat.

princeshahnawaz2012 avatar princeshahnawaz2012 commented on May 27, 2024

While using this function to fetch the data...I get this following error....
Uncaught RangeError: Maximum call stack size exceeded on leaflet.js:6

var geoData = geoJson2heat(layer.data, 2);
// returns 0: Array[3] 0: "42.3439925" 1: "-3.696906" 2: "4", 1: Array[3] 0: "38.2733071"1: "-3.6065861"2: "3" .....
var heatMap = L.heatLayer(geoData,{ radius: 20,blur: 15, maxZoom: 17})
map.addLayer(heatMap);

function geoJson2heat(geojson, intensity) {
return geojson.features.map(function(feature) {
return [
feature.geometry.coordinates[1],
feature.geometry.coordinates[0],
feature.properties[intensity]
];
});
}

from leaflet.heat.

princeshahnawaz2012 avatar princeshahnawaz2012 commented on May 27, 2024

the main problem was double quotes in each array. Therefore, i did a tiny change(using parseFloat) in the same function and passing to directly L.heatLayer.. It seems working.

var geoData = geoJson2heat(layer.data, intensity);
var heatMap = new L.heatLayer(geoData,{radius: 30,blur: 15, maxZoom: 17});

geoJson2heat = function(geojson, intensity) {
return geojson.features.map(function(feature) {
return [parseFloat(feature.geometry.coordinates[1]), parseFloat(feature.geometry.coordinates[0]), intensity];
});
}

from leaflet.heat.

mourner avatar mourner commented on May 27, 2024

I agree with @mattesCZ, it should be easy enough to transform GeoJSON into a flat list of coordinates.

from leaflet.heat.

Abhishek950650 avatar Abhishek950650 commented on May 27, 2024

thankyou @ajgeers and @Jmuccigr i solved this issue
geoJson2heat = function(geojson) {
return geojson.features.map(function(feature) {
return [parseFloat(feature.geometry.coordinates[1]), parseFloat(feature.geometry.coordinates[0])];
});
}

function addObsToMap(obs, map) {
var geoData = geoJson2heat(obs, 1);
var heatMap = new L.heatLayer(geoData,{radius: 50, blur: 25, maxZoom: 17});
map.addLayer(heatMap);
}

from leaflet.heat.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.