如何在使用geom_sf时删除边框线?

Sam*_*Sam 10 r geospatial ggplot2

我尝试过以下操作:

ggplot(geography) + geom_sf(aes(fill=rate, color = NULL))
Run Code Online (Sandbox Code Playgroud)

但那并没有摆脱边界线.

Pet*_*ter 14

如果没有可重复的示例,很难确切地知道您在寻找什么.但是,我会猜测你正在寻找一种方法来抑制标记不同多边形(区域)之间边界的线条,例如,抑制在世界地图上显示国家边界的线条.如果是这样,那么这是一个解决方案.

lwd = 0geom_sf通话中使用.

示例(您可能需要下载开发版本ggplot2)

# devtools::install_github("tidyverse/ggplot2")
library(ggplot2)
library(maps) 
library(maptools)
library(rgeos)
library(sf)

world1 <- sf::st_as_sf(map('world', plot = FALSE, fill = TRUE))

with_boundary <-
  ggplot() +
    geom_sf(data = world1, mapping = aes(fill = ID)) +
  theme(legend.position = "none") +
  ggtitle("With Country Boundaries")

without_boundary <-
  ggplot() +
    geom_sf(data = world1, mapping = aes(fill = ID), lwd = 0) +
  theme(legend.position = "none") +
  ggtitle("Without Country Boundaries")
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

  • 不知道这是否已经过时,但是`lwd`对我不起作用。执行以下操作:`library(sf)library(ggplot2)nc &lt;-st_read(system.file(“ shape / nc.shp”,package =“ sf”))ggplot(nc)+ geom_sf(aes(fill = AREA) ,颜色= NA)` (5认同)
  • 或者,对于“lwd = 0”,您可以使用“color = NA”。请参阅这篇文章的示例:/sf/ask/4186586281/#59808487 (4认同)