本文介绍了获取具有指定边界坐标的地图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我希望从R获得RgoogleMaps的地图,并且具有特定的坐标边界。 我可以调用GetMap,并指定一个中心,我必须添加缩放级别。一切工作正常,除了我没有得到与我选择的坐标有界的图像映射。 以下是一个例子: $ b $ (44.49,44.5) lon center = c(mean(lat),平均(lon)) zoom< - 14 mmap< - GetMap(center = center,zoom = zoom,maptype =satellite,destfile =m.png) 问题是只有中心被作为参数传递,因此我看到的整个图像取决于缩放水平。所以,我无法真正理解我得到的图像的边界是什么。我想要做的是让图像与我定义的坐标完全一致。这是可能的(也与其他地图包)? 解决方案这是一种方法。首先,你得到一个具有一定缩放比例的地图。然后,当您绘制一个图形时,您可以使用 scale_x_continuous 和 scale_y_continuous 来添加lon和lat限制。 library(ggmap) library(ggplot2) ###设置范围 lat lon ###获取地图地图< - get_map(location = c(lon = mean(lon),lat = mean(lat)),zoom = 14, maptype =satellite,source =google) # ##绘制图形时,限制lon和lat。 foo scale_x_continuous(limits = c(11.33,11.36),expand = c(0,0))+ scale_y_continuous(limits = c(44.49, 44.5),expand = c(0,0)) foo I want to get a map with RgoogleMaps from R, with a specific coordinates boundary.What I can call is GetMap, and specify a center, I must add a zoom level. Everything works fine, except that I am not getting an image map bounded with the coordinates I choose.Here's an example:lat <- c(44.49,44.5)lon <- c(11.33,11.36)center = c(mean(lat), mean(lon))zoom <- 14mmap <- GetMap(center = center, zoom=zoom, maptype= "satellite", destfile = "m.png")The problem is that only the center is passed as a parameter, and thus the whole image I see is dependant on the zoom level. So, I cannot really understand what are the boundaries of the image I get. What I want to do is to get an image bounded exactly with the coordinates I am defining. Is this possible (also with other map packages)? 解决方案 Here is one way. First, you get a map with a certain zoom. Then, you add the lon and lat limit when you draw a figure, which you can do with scale_x_continuous and scale_y_continuous. library(ggmap)library(ggplot2)### Set a rangelat <- c(44.49, 44.5)lon <- c(11.33, 11.36)### Get a mapmap <- get_map(location = c(lon = mean(lon), lat = mean(lat)), zoom = 14, maptype = "satellite", source = "google")### When you draw a figure, you limit lon and lat.foo <- ggmap(map)+ scale_x_continuous(limits = c(11.33, 11.36), expand = c(0, 0)) + scale_y_continuous(limits = c(44.49, 44.5), expand = c(0, 0))foo 这篇关于获取具有指定边界坐标的地图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-14 05:50