[R-es] Mapa de Calor con Google Maps de fondo

Gilsanz, Jose Luis jluis.gilsanz en eu.jll.com
Mar Oct 20 17:39:21 CEST 2015


Hola:



Estoy intentando generar un mapa de calor que muestre, dadas unas coordenadas geográficas determinadas, el “calor” (cuanto mas alto el valor de esta variable mas rojo y cuanto mas bajo mas azul) de una determinada variable.



Es decir con unos datos como estos:

x                             y                             z

-3,716575            40,41743              3.169

-3,710735            40,42179              4.134

-3,704625            40,40333              2.606

-3,703929            40,40363              2.563

-3,686431            40,36133              1.452

-3,682371            40,35542              1.523

-3,675325            40,41986              4.122

-3,673758            40,41978              4.098

-3,645127            40,42780              2.306



Donde el data frame datos contiene:

x: Longitud

y: Latitud

z:  Variable a estudiar



lo que quiero es mostrar sobre un fondo de GoogleMaps, otra capa(semitransparente)  con el  Calor de la variable.



Para ello primero calculo una aproximación de superficies de mis puntos usando MBA



##Cargamos paquetes

library(MBA)



##Calculamos aproximacion de superficies segun coordenadas y valores

superf <- mba.surf(datos, 2000, 2000,extend=FALSE)$xyz.est



##Obtenemos la capa con los colores a partir de la aproximación de superficies

image.plot(superf,  bg= NULL, nlevel = param$NIVELES)

[cid:image001.png en 01D10B5D.6039CD80]





Por otro lado obtengo el mapa de google maps sobre el cual deberia ir esto asi:

#Cargamos paquete

library(ggmap)



##Centro del mapa

center <- c(mean(datos$x), mean(datos$y))

##Zoom

zoom <- min(MaxZoom(range(datos$x), range(datos$x)))



##Obtenenmos mapa base

mapa <- get_map(center, zoom = 12)

[cid:image002.png en 01D10B5D.6039CD80]



Lo que ya no consigo hacer es poner la imagen con los colores sobre el mapa de forma que este correctamente calibrada.



Seguro que todo esto se pude hacer de un tiron con ggmap y/o RgoogleMaps pero por mas que miro no veo la manera de meter el objeto superf “dentro” de un mapa.



Muchas Gracias





TASACIONES HIPOTECARIAS S.A.
Registration number: A-28/806222.
Registered Office: Pº de la Castellana, 79 - 1ª ; 28046 Madrid

This e-mail is for the use of the intended recipient(s) only. If you have received this e-mail in error, please notify the sender immediately and then delete it. If you are not the intended recipient, you must not use, disclose or distribute this e-mail without the author's prior permission. We have taken precautions to minimise the risk of transmitting software viruses, but we advise you to carry out your own virus checks on any attachment to this message. We cannot accept liability for any loss or damage caused by software viruses. If you are the intended recipient and you do not wish to receive similar electronic messages from us in future then please respond to the sender to this effect
------------ próxima parte ------------
Se ha borrado un adjunto en formato HTML...
URL: <https://stat.ethz.ch/pipermail/r-help-es/attachments/20151020/5b501b05/attachment-0001.html>
------------ próxima parte ------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 13312 bytes
Desc: image001.png
URL: <https://stat.ethz.ch/pipermail/r-help-es/attachments/20151020/5b501b05/attachment-0002.png>
------------ próxima parte ------------
A non-text attachment was scrubbed...
Name: image002.png
Type: image/png
Size: 265395 bytes
Desc: image002.png
URL: <https://stat.ethz.ch/pipermail/r-help-es/attachments/20151020/5b501b05/attachment-0003.png>


Más información sobre la lista de distribución R-help-es