[R-sig-Geo] Loading a raster data of map PNG on ggmaps of R
Anisha Kaul
born.rebel.83 at gmail.com
Tue Jul 24 11:28:43 CEST 2012
Greetings,
I have the map as a png, so I won't be using the get_map function.
I have extracted the raster data from the png, and I wish to load the
map as it is on the display of R, and then I would like to plot a
point on it.
So, here's the way I have tried ggmaps. The program is an error with
Rscript, and there isn't any output "display window" being shown.
___________________________________________________
library (png)
library (ggmap)
latitude = c(40.702147,40.718217,40.711614)
longitude = c(-74.012318,-74.015794,-73.998284)
# Reads a PNG and outputs a raster array.
img <- readPNG (system.file ("img", "My.png", package="png"))
df <- data.frame (latitude, longitude)
# img: raster array read from the map png.
ggimage (img, fullpage = TRUE) + geom_point (data = df, aes_auto (df), size = 2)
qplot (latitude, longitude, data = df, colour = I("red"), size = I(3))
___________________________________________________
The error is:
___________________________________________________
anisha at linux-y3pi:~> Rscript uff.R
Loading required package: ggplot2
Loading required package: methods
Error in eval(expr, envir, enclos) : object 'x' not found
Calls: print ... sapply -> lapply -> eval.quoted -> lapply -> FUN -> eval
Execution halted
___________________________________________________
R info:
___________________________________________________
> sessionInfo()
R version 2.15.1 (2012-06-22)
Platform: x86_64-unknown-linux-gnu (64-bit)
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=C LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] ggmap_2.1 ggplot2_0.9.1 png_0.1-4
loaded via a namespace (and not attached):
[1] colorspace_1.1-1 dichromat_1.2-4 digest_0.5.2 grid_2.15.1
[5] labeling_0.1 MASS_7.3-18 memoise_0.1 munsell_0.3
[9] plyr_1.7.1 proto_0.3-9.2 RColorBrewer_1.0-5 reshape2_1.2.1
[13] RgoogleMaps_1.2.0 rjson_0.2.8 scales_0.2.1 stringr_0.6
[17] tools_2.15.1
>
___________________________________________________
--
Anisha Kaul
More information about the R-sig-Geo
mailing list