[R-sig-Geo] Unable to perform intersection operations with vectors
Coyo Tepe
coyotepe@2203 @end|ng |rom gm@||@com
Mon Jul 13 15:56:54 CEST 2020
Platform and versions
Windows 64 bit
R version 4.0.2 (2020-06-22) -- "Taking Off Again"
Rstudio Version 1.3.959
rgdal: 1.5-12 / gdal: 3.0.4
rgeos version: 0.5-3, (SVN revision 634)
GEOS runtime version: 3.8.0-CAPI-1.13.1
Linking to sp version: 1.4-2
Polygon checking: TRUE
Problem
We are trying to perform an intersection operation between two vector
layers in shapefile format and we get an error:
Warning message:
In proj4string(x) : CRS object has comment, which is lost in output
Below you can have a REPEX:
´´´
library(rgdal)
library(raster)
library(rgeos)
#layer a
bbox_a<-c(497555,500000,137000,138000)
extent_a<-extent(bbox_a)
extent_a
capa_a<-as(extent_a,'SpatialPolygons') #creamos un objeto tipo SpatialPolygons
crs(capa_a)<- "+proj=utm +zone=16 +datum=WGS84 +units=m +no_defs"
crs(capa_a)
shapefile(capa_a,paste("capa_a_re",sep="/"),overwrite=TRUE)
plot(capa_a,col="green") #plot(capa_a,col="green")
#layer b
bbox_b<-c(497995,500050,137100,138100)
extent_b<-extent(bbox_b)
extent_b
capa_b<-as(extent_b,'SpatialPolygons') #creamos un objeto tipo SpatialPolygons
crs(capa_b)<- "+proj=utm +zone=16 +datum=WGS84 +units=m +no_defs"
crs(capa_b)
shapefile(capa_b,paste("capa_b_re",sep="/"),overwrite=TRUE)
plot(capa_b,add=T)
#buffer
b_buf<-buffer(capa_b,width=50)
plot(b_buf,add=T) #plot(b_buf,add=T,col="blue")
#intersect
b_intersect<-intersect(capa_a,b_buf)
#Warning messages:
# 1: In proj4string(x) : CRS object has comment, which is lost in output
# 2: In proj4string(y) : CRS object has comment, which is lost in output
More information about the R-sig-Geo
mailing list