我已经将一些名为201101.dbf的.dbf文件添加到201412.dbf,并且学习区域shapefile已准备就绪。现在,寻找一种通过shapefile剪辑(子集)dbf文件的方法。
#Loading libraries
library(foreign)
library(maptools)
library(rgdal)
library(rgeos)
#set working directory
setwd('D:/Data1")
#Load the dbf files
Data=dir(,pattern="dbf")
#load study area shape file
studyarea=readShapeSpatial("D:/Data1/study-area.shp")
#Setting the projection for study area
proje4string(studyarea)=CRS("+init=epsg:32639")
#Looping
for(i in 1:length(Data)){
Data2=read.dbf(Data[i])
#setting coordinates for dbf files
coordinates(Data2)=~longitude+latitude
#Setting the projection for dbf files
proj4string(Data2)=CRS(proj4string(studyarea))
#Clipping the spatial data frames
Clip-data=gIntersection(Data2,studyarea,byid=TRUE)
#Writing clipped spatial data frames with the names of original dataframes
write.dbf(Clip-Data,Data2=paste("D:/data", paste("Clip-data",Data[i]), sep="/"))}
我的脚本出现以下错误!
(函数(classes,fdef,mtable)中的错误: 无法为签名'“list”'
找到函数'coordinates< - '的继承方法