How to get widescreen resolution with ggmap

I have the following data:

YEAR-STORM-DATETIME-NORTH-WEST-PRESSURE-WIND-SPEED-TRACKDATE 2011-arlene-6/28/2011 6:00-19.9-92.8-1007-30-NA-6/28/2011 2011-arlene-6/28/2011 12:00-20.3-93.1-1006-35-4-6/28/2011 2011-arlene-6/28/2011 18:00-20.7-93.5-1006-40-5-6/28/2011 so on.. 

I am new to R and I am plotting a density graph using ggmap . I also use brilliant R to display them on the website. The problem is that the output is not widescreen (square) cards. I want to have a rectangular map, such as Google maps provided by Openlayers or KML. My code is:

 library(ggplot2) library(ggmap) mydata <- read.csv("C:/R Data/Analytics/dMetrics.csv") slice_year <- mydata[mydata$YEAR=='2009',] map <- get_map(c(lon = -55.3632715, lat = 31.7632836), zoom = 3, source = 'google', maptype = c("terrain"), messaging = FALSE, color = 'color') world <- ggmap(map) #extent = 'device' world <- world + stat_density2d(data = slice_year, aes(x = WEST, y = NORTH, fill = ..level.., alpha = ..level..), show_guide = FALSE, geom = "polygon", na.rm = TRUE) + scale_fill_gradient(name = "Density", low = "maroon", high = "yellow", guide = 'colorbar') world 

I ask you to create a widescreen resolution map, possibly with a high resolution.

+4
source share
2 answers

To save the image in widescreen mode, add it to the end: ggsave(file="map.pdf", width=8, height=4.5)

To open a widescreen window, add it before calling world : windows(800,450)

Edit

It seems that ggmap just does not support proportions without sqaure.

The documentation states that the bounding block can be passed to the location property, but it just ignores it.

 scale <- 5 ratio <- 16/9 size <- c(ratio, 1) * scale latlongCenter <- c(0, 45) latlongBox <- c(latlongCenter - size/2, latlongCenter + size/2) map <- get_map(location = latlongBox) ggmap(map) 
+2
source

One solution would be to create a large map and then crop a piece that you don't need.

But I'm still trying to figure out how to create a large map with high resolution (the map I get is 1280x1280 - this is enough for most needs, but not for printing a large map). I think that there is no function for this, or bots can occupy the entire Google bandwidth. A simpler solution is to get a lot of square maps and put them together, but then you will have the Google logo in all of them.

I think the only way to do this is to create small square maps and cut the bottom where the logo and copyright information are located. To add your logo again within the borders of the final map (cutting them differently), you will get even more work ...

+1
source

Source: https://habr.com/ru/post/1469120/


All Articles