Ошибка при загрузке файла shp: Ошибка 4 GDAL: Не удалось прочитать данные Geo JSON - PullRequest
0 голосов
/ 07 апреля 2020

У меня проблемы с загрузкой файла shp. Это мой код

knitr::opts_chunk$set(echo = FALSE,warning = FALSE, message = FALSE)

install.packages("geojsonio")
library(geojsonio)
library(rio)
library(gridExtra)
library(dplyr)
library(kableExtra)
library(JLutils) # devtools::install_github("larmarange/JLutils")
library(tidyverse)
library(cowplot)
library(sf)
library(ggrepel)
library(readxl)
library(plyr)
library(cowplot)
library(ggpubr)
install.packages("directlabels")
library(directlabels)
data <- rio::import("https://github.com/jincio/COVID_19_PERU/blob/master/docs/reportes_minsa.xlsx?raw=true")


knitr::opts_chunk$set(echo = FALSE,warning = FALSE, message = FALSE)

When I run I try to create deparamento , I get this error message:

Ошибка: невозможно открыть "https://github.com/jincio/COVID_19_PERU/tree/master/data/departamentos/DEPARTAMENTOS.shp"; Файл, кажется, не существует. Кроме того: Предупреждение: в CPL_read_ogr (dsn, layer, query, as.character (options), quiet,: GDAL Ошибка 4: Не удалось прочитать данные Geo JSON

  departamento <- read_sf("https://github.com/jincio/COVID_19_PERU/tree/master/data/departamentos/DEPARTAMENTOS.shp") %>%
    select(Departamento = DEPARTAMEN, geometry)
  data2 = import("reportes_minsa.xlsx", sheet=2)
  data3 = data2 %>%
    filter(Fecha == max(data2$Fecha)) %>%
    dplyr::rename(Departamento = REGION) %>%
    dplyr::group_by(Departamento) %>%
    dplyr::summarise(casos = sum(Positivos))
  m1 = departamento %>%
    left_join(data3, by="Departamento") %>%
    mutate(casos = replace_na(casos,0),
           casos=as.factor(casos),
           label = paste0(Departamento, ": ", casos))%>%
    ggplot() +
    geom_sf(aes(fill = casos), size = 0.05, color = "grey40") +
    # colorRampPalette crea una paleta de colores del tamaño de factor(casos) -1
    scale_fill_manual(values = c("grey80", colorRampPalette(colors = c("#FFF5F0","#FB6A4A", "#67000D"))(length(unique(data3$casos)-1)))) +
    ggrepel::geom_label_repel(
      aes(label = label, geometry = geometry),
      stat = "sf_coordinates", 
      size = 2.3,
      min.segment.length = 0
    )+
    scale_x_discrete()+
    theme_bw()+
    theme(legend.position = "none",
          axis.title = element_blank())
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...