1

I work on a personal project, witch stands to collect and store weather data (temperature, CO2, Humidity ...) in a MySQL database (I've tried PostgreSQL with post PostGIS) from some working weather stations.

In front-end, I'm using a Laravel based web application with Leaflet to show mapped data (Laravel request the database and return GeoJSON files to Leaflet).

To make a better visualisation I decide to do some interpolation to cover missing data then generate a colorated layer for leaflet to show.

In first step I did some R scripting using IDW and Kriging interpolation algorithms, ploting the result in R was looking good, but the problem is that i need to generate shape or geoJSON file to pass it to Leaflet instead of images.

After some research I realized that i need to work with a layer server like geoserver(WMS) and to Postgres instead of MySQL ...

In this point I still so confused what to do.

Note: I need to my maps appears like those in this site: http://www.irceline.be/

please help, and thanks in advance.

Serhan
  • 605
  • 9
  • 19
  • There's a [leaflet R package](http://rstudio.github.io/leaflet/) which lets you use data directly from R. – alistaire Apr 08 '16 at 18:19

2 Answers2

2

You can implement everything on the R side like this:

library(mapview)
library(sp)
library(htmlwidgets)

## point data
data(meuse)
coordinates(meuse) <- ~x+y
proj4string(meuse) <- CRS("+init=epsg:28992")

## grid data
data(meuse.grid)
coordinates(meuse.grid) <- ~x+y
proj4string(meuse.grid) <- CRS("+init=epsg:28992")
gridded(meuse.grid) <- TRUE

## map it
m <- mapview(meuse.grid, zcol = "dist") + meuse
m

## save it
saveWidget(m@map, file = "/path/to/file.html")

meuse would be your points, meuse.grid your gridded data resulting from interpolation.

TimSalabim
  • 5,604
  • 1
  • 25
  • 36
  • Thanks, this is my first time with mapview, with my own data (lat&long instead of x & y) and my ESPG = 26191, the result is an empty map ! – Serhan Apr 12 '16 at 19:59
  • The EPSG shouldn't be a problem as mapview handles reprojection internally. What do you mean with an empty map? No data? Or no background maps? Is there any chance to provide your data (or a subset thereof)? – TimSalabim Apr 14 '16 at 19:19
1

Another option would be to implement everything using leaflet itself using the IDW plugin I have written: https://github.com/JoranBeaufort/Leaflet.idw Using the plugin you could still use your Laravel request to your database and return GeoJSON files, which you feed into the plugin to generate an IDW layer in Leaflet. To note: the plugin only works well with a limited number of points, so if you have a large amount of points you could first cluster the points (I would recommend using DBSCAN) and then pass the clusters to the plugin. Hope this helps

Mfbaer
  • 465
  • 3
  • 15