R-将CSV文件与shapefile合并

时间:2018-09-28 18:12:10

标签: r shapefile

我想将shapefile与数据框合并,并且收到以下错误

match(bx,by,0L)中的错误:“ match”需要向量参数

我的代码是

mydat <- read.csv("PLS.csv",stringsAsFactors = F)

mydat<- mydat %>% rename_at(vars(STABR),~"STATE") 
mydat<- mydat %>% rename_at(vars(CNTY),~"COUNTY") 

mydat <- mydat[ ! mydat$STATE %in% c("AS","GU"), ]

states <- readOGR("cb_2015_us_state_20m.shp",
                  layer = "cb_2015_us_state_20m")#,stringsAsFactors = F)


states <- subset(states, states$STUSPS %in% setdiff(states$STUSPS,c("AS","GU","PR")))

states$STUSPS <- states[order(states$STUSPS), ]

map_dat <- mydat[,c("STATE",
                    "LIBNAME",  
                    "ADDRESS",
                    "CITY",
                    "ZIP",
                    "COUNTY",
                    "GEOCODE",
                    "LONGITUD",
                    "LATITUDE")]


projects.df <- merge(states, map_dat, by.x = "STUSPS", by.y = "STATE",duplicateGeoms = T)

有人可以帮助我发现我出了什么问题吗?

0 个答案:

没有答案