r中大型数据集的高效空间连接

时间:2017-05-22 10:04:04

标签: r join size spatial shapefile

我正在使用相当大的data.frames,我经常需要进行空间连接。到目前为止,我提出的最快方法是这种方法:

library(rgdal)

download.file("http://gis.ices.dk/shapefiles/ICES_ecoregions.zip",
              destfile = "ICES_ecoregions.zip")
unzip("ICES_ecoregions.zip")

# read eco region shapefiles
ices_eco <- rgdal::readOGR(".", "ICES_ecoregions_20150113_no_land", verbose = FALSE)
## Make a large data.frame (361,722 rows) with positions in the North Sea:
lon <- seq(-18.025, 32.025, by=0.05)
lat <- seq(48.025, 66.025, by=0.05)
grd <- expand.grid(lon=lon, lat=lat)

# Get the Ecoregion for each position
pings  <- SpatialPoints(c[c('lon','lat')],proj4string=ices_eco@proj4string)
grd$area   <- over(pings,ices_eco)$Ecoregion

但是这需要很长时间并且使用大量RAM,并且有时会出现错误:无法分配大小为460 Kb的向量(如果您无法重现错误,只需使c更大)。任何人都可以提出更好/更快/更有效的解决方案吗?

0 个答案:

没有答案