代码之家  ›  专栏  ›  技术社区  ›  Sharif Amlani

如何修复加州大学洛杉矶分校国会选区地图

  •  1
  • Sharif Amlani  · 技术社区  · 6 年前

    我正在使用以下国会选区地图:

    get_congress_map <- function(cong=113) {
      tmp_file <- tempfile()
      tmp_dir  <- tempdir()
      zp <- sprintf("http://cdmaps.polisci.ucla.edu/shp/districts%03i.zip",cong)
      download.file(zp, tmp_file)
      unzip(zipfile = tmp_file, exdir = tmp_dir)
      fpath <- paste(tmp_dir, sprintf("districtShapes/districts%03i.shp",cong), sep = "/")
      st_read(fpath)
    }
    
    cd114 <- get_congress_map(114)
    
    ggplot() + 
      geom_sf(data=cd114.1,aes(geometry = geometry,),inherit.aes=FALSE,alpha=0.9) + 
      scale_fill_gradient(low = "white", high = "black", limits=c(20,80)) +
      theme_void() +
      theme(axis.title.x=element_blank(),
            axis.text.x=element_blank(),
            axis.ticks.x=element_blank(),
            axis.title.y=element_blank(),
            axis.text.y=element_blank(),
            axis.ticks.y=element_blank())
    

    看起来是这样的: enter image description here

    非常感谢你的帮助。

    0 回复  |  直到 6 年前