我使用以下映射:https://gist.github.com/simzou/6459889#file-nielsentopo-json来绘制DMA区域。
我试着按照以前的stackoverflowhttps://stackoverflow.com/questions/35493585/r-import-html-json-map-file-to-use-for-heatmap,执行,但是fortify命令不起作用,我也不知道为什么:
library(sp)
library(rgdal)
library(maptools)
library(rgeos)
library(ggplot2)
library(ggalt)
library(ggthemes)
library(jsonlite)
library(purrr)
library(viridis)
library(scales)
neil <- readOGR("~nielsentopo.json", "nielsen_dma", stringsAsFactors=FALSE, verbose=FALSE)
# there are some techincal problems with the polygon that D3 glosses over
neil <- SpatialPolygonsDataFrame(gBuffer(neil, byid=TRUE, width=0),
data=neil@data)
neildf <- as.data.frame(neil)
neil_map <- fortify(neil, region = 'id')这是我收到的错误:
Too few points in geometry component at or near point -82.061259930000006 26.499350110000002Ring Self-intersection at or near point -89.1404651 29.135150639999999Ring Self-intersection at or near point -78.518767870000005 33.867667130000001SpP is invalid
Invalid objects found; consider using set_RGEOS_CheckValidity(2L)Error in rgeos::gUnaryUnion(spgeom = SpP, id = IDs) :
TopologyException: Input geom 0 is invalid: Ring Self-intersection at or near point -78.518767870000005 33.867667130000001 at -78.518767870000005 33.867667130000001你能帮忙吗?
发布于 2020-07-23 01:47:19
找到答案了!扫帚:建议你整理一下,而不是现在加强。此外,其余部分按照这里的逻辑进行,您可以这样做:
https://stackoverflow.com/questions/63044221
复制相似问题