Я привык читать в шейп-файлах в Python
со следующим простым кодом:
import geopandas
url='https://opendata.arcgis.com/datasets/01fd6b2d7600446d8af768005992f76a_3.geojson'
gdf = geopandas.read_file(url)
Я пытаюсь сделать это в R
, чтобы люди немне нужно скачать шейп-файлы, но я изо всех сил.
Я пробовал это, но получаю 'cannot open data source'
ошибка:
sp <- readOGR(dsn="https://opendata.arcgis.com/datasets/01fd6b2d7600446d8af768005992f76a_3.geojson", layer="OGRGeoJSON")
Если я загружаюшейп-файл , мой код выглядит так:
#load shape file
shape_file_name<- "D:/Users/XXX/Documents/R/NUTS_Level_2_January_2018_Generalised_Clipped_Boundaries_in_the_United_Kingdom.shp"
#import the shape file
shape_file <- readOGR(shape_file_name, stringsAsFactors = F)
#fortify shapefile
shp <- fortify(shape_file)
#creates the NUTS map
NUTS_map <- ggplot() +
geom_polygon(data = shp,
aes(x = long, y = lat, group = group),
color = 'lightsteelblue', fill = 'lightcyan', size = .9) +coord_fixed(1.7)+ theme_void()
Я просто хочу заменить следующие строки:
shape_file_name<- "D:/Users/XXX/Documents/R/NUTS_Level_2_January_2018_Generalised_Clipped_Boundaries_in_the_United_Kingdom.shp"
shape_file <- readOGR(shape_file_name, stringsAsFactors = F)
С вызовом API можно найти на следующей веб-странице:
https://geoportal.statistics.gov.uk/datasets/nuts-level-2-january-2018-names-and-codes-in-the-united-kingdom
Большое спасибо