3

I'm working with R as a GIS software, thanks to the mapview,gstat,sp and other packages.

I plot the result with mapView() function

m <- vgm(psill=.49,model="Sph",range=600000,nugget=3.8)
idw <- krige(formula = temp~1, locations = data_test, newdata = grd, model=m)
idw.output = as.data.frame(idw)
names(idw.output)[1:3] <- c("long", "lat", "temp")
coordinates(idw.output) <- ~long+lat
morocco <- readOGR("/opt/lampp/htdocs/ardusky/public/data/TNG", "TNG")
proj4string(idw.output)<-proj4string(morocco)
tempData <- idw.output[morocco,]
proj4string(data_test)<-proj4string(morocco)
gridded(tempData) <- TRUE
m<-mapView(tempData, zcol = "temp") + data_test
m

result:

enter image description here

I want to control the coloration, 0->blue 50->red for example.

there is any way to do that ?

Serhan
  • 605
  • 9
  • 19
  • 1
    Post code .... not pictures. – IRTFM May 03 '16 at 22:44
  • there is no code to show man, only one function witch is : mapView(tempData, zcol = "temp") – Serhan May 03 '16 at 22:53
  • just a SpatialPixelsDataFrame – Serhan May 03 '16 at 23:00
  • > summary(tempData) Object of class SpatialPixelsDataFrame Coordinates: min max long -5.991 -5.741 lat 35.575 35.811 Is projected: FALSE proj4string : [+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0] Number of points: 8833 Grid attributes: cellcentre.offset cellsize cells.dim long -5.990 0.002 125 lat 35.576 0.002 118 Data attributes: temp Min. :22.91 1st Qu.:22.91 Median :22.91 Mean :22.91 3rd Qu.:22.91 Max. :22.91 – Serhan May 03 '16 at 23:01

1 Answers1

6

Similar to spplot the at argument in mapview is what you want to use:

library(mapview)
library(sp)

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

mapview(meuse.grid, zcol = "dist", at = seq(0, 1, 0.25))

Note: In the CRAN version this only works for Raster* objects, but I assume that is what you are after.

TimSalabim
  • 5,604
  • 1
  • 25
  • 36
  • I get this error ! : Error in leaflet::addCircleMarkers(m, lng = coordinates(lst[[i]])[, 1], : unused argument (at = c(0, 0.25, 0.5, 0.75, 1)) – Serhan May 20 '16 at 12:00
  • Could you provide a minimal reproducible example to reproduce the error and also let me know which versions of mapview and leaflet you are using? – TimSalabim May 20 '16 at 12:04