我使用 dput()
和 dget()
来导出和导入数据 . 导入SpatialPolygonsDataFrame的导出文本文件时出错 .
解析时出错(file = file,keep.source = keep.source):MapFrance.txt:161:23:'<'inattendu(e)160:),row.names = c(NA,96L),class = “data.frame”)161 :, polygons = list(<^
使用数据框时不会出现错误 . 它也适用于SpatialPointsDataFrame .
代码是:
library(sp)
library(rgdal)
library(rgeos)
MyDirectory <- "" # fill with the directory
MapFrance <- readOGR(dsn = paste0(MyDirectory, "Departements"), layer = "DEPARTEMENT")
dput(x = MapFrance, file = paste0(MyDirectory, "MapFrance.txt"))
Load_MapFrance <- dget(file = paste0(MyDirectory, "MapFrance.txt"))
指向地理数据的链接(SPH文件):https://drive.google.com/file/d/1wksMnkufQPdOfSbhWoZbPKMqlcLcll_j