在交互式地图上覆盖shapefile或栅格 [英] Overlaying shapefiles or raster over interactive maps

查看:138
本文介绍了在交互式地图上覆盖shapefile或栅格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用R,我想将一些栅格数据(例如模型中的温度图)覆盖在允许平移和缩放的交互式地图上.理想情况下,我想覆盖Google Maps或OpenStreetMaps.输入数据可以在shapefile,KML,raster数据或方便的任何内容中.

I'm using R, and I want to overlay some raster data (e.g. a temperature map from a model) over an interactive map which allows panning and zooming. Ideally, I'd like to overlay over Google Maps or OpenStreetMaps. The input data can be in shapefiles, KML, raster data or whatever comes in handy.

  • 我知道我可以使用googleVisggmapRgoogleMaps轻松地非交互地执行此操作.但是我不想使用图块,我想互动!直接从浏览器进行缩放,平移等.

  • I know I can easily do this non-interactively using either googleVis, ggmap or RgoogleMaps. But I do not want to use tiles, I want interaction! Zooming, panning etc., directly from the browser.

googleVis只能以交互方式显示点或地址,而不能显示区域.

googleVis, as far as I know, unfortunately only allows to show interactively points or addresses, not areas.

此问题是非常相似的,但是我绝对想尝试使用R做到这一点.我可以从R创建KML或geoJSON,但是如何直接从R覆盖它呢?

This question is very similar but I definitely want to try to do this using R. I can create the KML or geoJSON from R, but how do I overlay it from R directly?

OpenStreetMaps也很好,但是尽管OSM似乎具有

OpenStreetMaps is also fine, however I've not found any reference on how to overlay data over it from R, despite the fact that OSM seems to have a pretty straightforward API.

推荐答案

您可能会对leaflet软件包感兴趣.您可以轻松添加raster对象.从文档

The leaflet package may be of interest for you. You can easily add a raster object. From the documentation

二维RasterLayer对象(来自raster包)可以是 变成图像并使用addRasterImage添加到传单地图 功能.

Two-dimensional RasterLayer objects (from the raster package) can be turned into images and added to Leaflet maps using the addRasterImage function.

这也是文档中的示例:

And here is an example also from the documentation:

library(leaflet)
library(raster)

r <- raster("nc/oisst-sst.nc")
pal <- colorNumeric(c("#0C2C84", "#41B6C4", "#FFFFCC"), values(r),
  na.color = "transparent")

leaflet() %>% addTiles() %>%
  addRasterImage(r, colors = pal, opacity = 0.8) %>%
  addLegend(pal = pal, values = values(r),
    title = "Surface temp")

这篇关于在交互式地图上覆盖shapefile或栅格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆