I have data on polling booths as points and data on village boundaries as polygons. I want to create buffers of 1km around the polling booths and (a) save the ID of all the villages that intersect with the buffer (b) in another column have the amount of area that intersects in Km2.
I have tried everything but it doesn't work. I am sharing my code below. When i use intersect on Spatialpolygons my R crashes with fatal error. I tried to rasterise but i get some strange output that i do not understand.
sample dataset - https://drive.google.com/open?id=1Ha47ZqwG7bCuxExJk6zOs8KoqDiqD5A4
rm(list=ls()) ##LOADING DATASETS REQUIRED FOR THIS load("sampledata.Rdata") #booths data - dataframe - upbooths_raw #booths data - spatial file - up_booths_sample #village data - up_villages_sample #loading libraries that i might use library(rgeos) library(raster) up_booths<-up_booths_raw #up_booths_raw<-subset(upid2017matched_gis2,district_name_17=="Jhansi") up_booths<-subset(up_booths, is.na(latitude.x)==FALSE & is.na(longitude.x)==FALSE) #project the booths coordinates(up_booths) <- ~longitude.x+latitude.x #make same coordinates copy village CRS to booths up_booths@proj4string <- up_villages_sample@proj4string #new CRS which is good for Uttar Pradesh India newcrs <- CRS("+proj=utm +zone=42N +datum=WGS84 +units=km") #transforms booths and villages to new crs up_booths_transform <- spTransform(up_booths, newcrs) up_villages_transform<- spTransform(up_villages_sample,newcrs ) #create booths with 1km buffer up_booths_transform_buffer1km <- gBuffer(up_booths_transform, byid = TRUE, width = 1, capStyle="ROUND") #runinng this crashes R into fatal error pi <- intersect(up_booths_transform_buffer1km, up_villages_transform)