- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在以下脚本中,我读入了许多点对并在 map 上绘制了线条。我正在使用 ggmap 从谷歌提取 map 来绘制这条线:
source('./library/latlong2state.R')
library(maps)
library(mapproj)
library(mapdata)
library(geosphere)
library(ggmap)
fileName = "_CanadaData/CanadaHospitalComplete.csv"
getLineColor <- function(val) {
pal <- colorRampPalette(lineColours)
colors <- pal(80)
val.log <- log(val)
if (val > 50) {
col <- colors[80]
} else {
colindex <- max(1, round( 80 * val / 50))
col <- colors[colindex]
}
return(col)
}
# Load the data
location <- read.csv(fileName, stringsAsFactors=FALSE)
# Omit locations that are not on the map of focus (not needed for city maps unless they are on a border)
location$state <- latlong2state(data.frame(location$lng, location$lat))
location$nearstate <- latlong2state(data.frame(location$lngnear, location$latnear))
location <- na.omit(location)
createMap <- function(bbox, thedata, mapzoom=3, linesize=0.6, pointsize=2) {
basemap <- get_map(location=bbox, zoom=mapzoom, source='google', maptype="roadmap", color="color")
ggmap(basemap) + geom_segment(aes(x=lng, xend=lngnear, y=lat, yend=latnear, color=dist_miles), size=0.6, data=thedata) + geom_point(aes(x=lngnear, y=latnear), size=2, color="#000000", border="black", data=thedata) + scale_color_gradient(low="blue", high="red", limits=c(0, max(thedata$dist_miles))) + coord_map("orthographic")
}
# Country bounding box c(left, bottom, right, top)
canada <- c(-140.920514, 42.016722, -52.524864, 83.2911)
createMap(canada, location)
projection=mapprojection(orthographic)
来更改线的绘制方式的投影。在 createMap 函数内部,但我无法更改从 Google 获取的 map 图像的投影 - 它卡在 Web Mercator 投影中。有没有办法使用 ggmap 来做到这一点,还是我必须尝试不同的包?如果是这样,你有什么建议?
最佳答案
最简洁的答案是不”。你被谷歌所谓的“网络墨卡托”投影困住了。 (它不是 WGS84。那是一个基准,而不是一个投影。)
我不知道是否有任何 R 库,但您可能需要使用 WMS 服务器。一个不错的选择可能是 GeoBase,它是加拿大特有的。 http://www.geobase.ca/geobase/en/wms/index.html
此外,我建议避免使用正投影,而是使用适合加拿大的投影,例如为加拿大 map 集选择的投影:EPSG:42304。
关于r - 使用 ggmap 创建正交 map ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20936792/
当我尝试将 ggmap 与形状文件结合时,我遇到了剪切问题。 Kahle 和 Wickham (2013: 158) 中的示例工作正常,因为来自 ggmap 的光栅图像覆盖了整个形状文件。下面是当我尝
我正在尝试解决以下问题。 我使用 ggplot2 绘制岛屿 map : island = get_map(location = c(lon = -63.247593, lat = 17.631598)
我正在生成一些 map ,我想在 ggmap 上显示县的边界路线图。这是使用德克萨斯州部分地区的示例。 library(ggmap) map = get_map(location = c(-95.31
我有一个城市和相关信息的列表,我已经放在一个数据框中,如下所示: library(plyr) library(dplyr) library(ggmap) library(Imap) cities <-
我试图用 ggmap 在北极绘制一个特定区域.该地区的中心在纬度附近。 80 长。 0,不幸的是只显示灰色背景和经纬度轴。我试图绘制不同的区域,我的代码似乎适用于每个位置,除了纬度以外的区域。 73.
我正在使用一个空间数据集(主要是一个城市区域上的多边形),并且我想根据不同的缩放级别来产生不同的 View 。 当绘图边界框大于包含多边形的区域时,一切都很好。但是在放大时,某些多边形会得到边界框之外
我正在尝试使用 ggmap 在 map 上绘制点,但我不知道如何从 map 背景中删除国家名称 library(ggmap) library(mapproj) map tbl plot<-ggmap
我正在使用 ggmap,希望有一张以澳大利亚为中心的世界地图,我可以轻松地绘制地理编码点。与其他一些 map 包相比,ggmap 似乎更容易使用。然而,当我使用下面的代码浏览 map 时,它会出错。
我最近遇到了 ggmap 函数的问题 - 从来没有遇到过。 我有这个data.frame: > head(df) longitude latitude freq 1 -118.7093 34.13
我在 ggmap 包中使用了 Stamen 背景 map 。我想用 "#C0C0C0" 替换光栅背景图像中的所有黑色元素(即颜色 "#000000" - 基本上看起来更像 toner light 背景
我想用 R 和 ggmap 包可视化一个数据框。 df: | lon | lat | |-----------|-----------| | 6.585863 | 51.09
我正在使用 ggmap 来查找位置。某些位置会产生错误。例如, library(ggmap) loc = 'Blue Grass Airport' geocode(loc, output = c("m
我想知道是否有人使用 ggmap 围绕纬度/经度点绘制圆半径?例如,我想绘制一个给定的点,然后在该点周围 2,500 英尺的半径范围内绘制和着色。我脑子里有一个关于如何使用更大的圆周公式来做到这一点的
是否可以将 ggmap 保存到本地文件? 上下文:我需要一个大区域的高分辨率 map ,它需要 stamen服务器好久才搞定。我认为最好先获取 map ,然后将其保存到文件中,然后再处理本地副本。 我
我正在 ggmap 上绘制路线和点,我需要添加一个图例来列出点代表的名称 IE。 1 比尔哈里斯, 2 安妮·琼斯 等等.. 我已经准备好了样本数据。 structure(list(business.
一张图片胜过千言万语: 观察到的行为:从上图可以看出,国家名称与其实际几何形状不匹配。 预期行为:我想正确地将数据框与其几何图形连接起来,并在 ggmap 中显示结果。 我以前加入过不同的数据框,但显
我正在尝试绘制一些显示完整人口的信息,然后按 map 上的位置绘制该人口的子集。我见过使用同心圆或 3-d 倒锥体来表达这一点的数据可视化。我就是不知道怎么做 ggplot/ggmap 这是 Pain
我想在谷歌的灰色 map 上绘制各个城市的数据点。由于这些城市彼此之间有一些距离,我想我会使用多面图。 创建 map 很容易;请参阅下面的图像和代码。但是,每个方面都显示相同的区域 - 在本例中为大伦
我有以下代码。 library(ggmap) x = geocode("641123",output='all') x$results[[1]]$geometry$location$lat 显示 55
我想在 ggmap 上绘制热图。 library(ggmap) turku<-get_map('turku', zoom=13) turkumap<-ggmap(turku, extent
我是一名优秀的程序员,十分优秀!