Hi,
I’m trying to achieve drawing isolines of elevations on a leaflet map.
I thought using d3.contours or d3.contourDensity but I’ve the following problem.
I’ve as data object an array of 8094 objects with 3 values (altitude, latitude, longitude).
Data values cover an area with altitude point each 25 meters.
When I use contourDensity I can specify x and y using such code:
The density contours are here to count the points in a given neighborhood—for your goal I think you’ll need to use the (simple) contour function. However note that this function operates on gridded data.
In case your data is not gridded, you need to follow the same strategy as Plot.contour instead—it can operate on non-gridded samples with three accessors x, y, and value, by applying spatial interpolators. (Plot’s spatial interpolators can be used independently of Plot, to pre-compute a grid on which you can apply d3.contour).
Sorry if this is a bit complicated—I can build an example if there is interest.
It contains in my case altitude values, then d3.contours as well produces geoJson MultiPolygon structure with altitude values, then how can I return back to latitude and longitude corresponding values ?
I think I’ve lost relation from altitudes and lat,long values.
The relation between lon lat and grid coordinates is through the x and y scales. You’ll need to apply them in reverse. I added the necessary code in the notebook.