Skip to main content
deleted 132 characters in body; edited title
Source Link
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345

why sf :: st_intersection() returnsreturning duplicate features

why sf :: st_intersection returns duplicate features.

I can't understand whyWhy does st_intersection addsadd duplicate lines to my sf data frame.?

 sf_points

Simple feature collection with 156421 features and 9 fields
geometry type:  POINT
dimension:      XY
bbox:           xmin: 596640.7 ymin: 7317066 xmax: 607113.9 ymax: 7326187
epsg (SRID):    32722
proj4string:    +proj=utm +zone=22 +south +datum=WGS84 +units=m +no_defs

sf_polygons

Simple feature collection with 225 features and 4 fields
geometry type:  POLYGON
dimension:      XY
bbox:           xmin: 543943.6 ymin: 7317069 xmax: 607110.9 ymax: 7342239
epsg (SRID):    32722
proj4string:    +proj=utm +zone=22 +south +datum=WGS84 +units=m +no_defs


nrow(sf_points[!duplicated(sf_points), ]) == nrow(sf_points)
> TRUE

st_crs(sf_points) == st_crs(parcelas) # test crs
> TRUE

sf_points_intersection <- st_intersection(sf_points, sf_polygon)

sf_points_intersection
Simple feature collection with 121716 features and 9 fields
geometry type:  POINT
dimension:      XY
bbox:           xmin: 596646.7 ymin: 7317070 xmax: 607109.9 ymax: 7326184
epsg (SRID):    32722
proj4string:    +proj=utm +zone=22 +south +datum=WGS84 +units=m +no_defs


nrow(sf_points_intersection[!duplicated(sf_points_intersection), ]) == nrow(sf_points_intersection)
> FALSE


nrow(sf_points_intersection[duplicated(as.data.frame(sf_points_intersection)), ])
> 37056

I appreciate some help in understanding this behavior.

why sf :: st_intersection() returns duplicate features

why sf :: st_intersection returns duplicate features.

I can't understand why st_intersection adds duplicate lines to my sf data frame.

 sf_points

Simple feature collection with 156421 features and 9 fields
geometry type:  POINT
dimension:      XY
bbox:           xmin: 596640.7 ymin: 7317066 xmax: 607113.9 ymax: 7326187
epsg (SRID):    32722
proj4string:    +proj=utm +zone=22 +south +datum=WGS84 +units=m +no_defs

sf_polygons

Simple feature collection with 225 features and 4 fields
geometry type:  POLYGON
dimension:      XY
bbox:           xmin: 543943.6 ymin: 7317069 xmax: 607110.9 ymax: 7342239
epsg (SRID):    32722
proj4string:    +proj=utm +zone=22 +south +datum=WGS84 +units=m +no_defs


nrow(sf_points[!duplicated(sf_points), ]) == nrow(sf_points)
> TRUE

st_crs(sf_points) == st_crs(parcelas) # test crs
> TRUE

sf_points_intersection <- st_intersection(sf_points, sf_polygon)

sf_points_intersection
Simple feature collection with 121716 features and 9 fields
geometry type:  POINT
dimension:      XY
bbox:           xmin: 596646.7 ymin: 7317070 xmax: 607109.9 ymax: 7326184
epsg (SRID):    32722
proj4string:    +proj=utm +zone=22 +south +datum=WGS84 +units=m +no_defs


nrow(sf_points_intersection[!duplicated(sf_points_intersection), ]) == nrow(sf_points_intersection)
> FALSE


nrow(sf_points_intersection[duplicated(as.data.frame(sf_points_intersection)), ])
> 37056

I appreciate some help in understanding this behavior.

sf :: st_intersection() returning duplicate features

Why does st_intersection add duplicate lines to my sf data frame?

 sf_points

Simple feature collection with 156421 features and 9 fields
geometry type:  POINT
dimension:      XY
bbox:           xmin: 596640.7 ymin: 7317066 xmax: 607113.9 ymax: 7326187
epsg (SRID):    32722
proj4string:    +proj=utm +zone=22 +south +datum=WGS84 +units=m +no_defs

sf_polygons

Simple feature collection with 225 features and 4 fields
geometry type:  POLYGON
dimension:      XY
bbox:           xmin: 543943.6 ymin: 7317069 xmax: 607110.9 ymax: 7342239
epsg (SRID):    32722
proj4string:    +proj=utm +zone=22 +south +datum=WGS84 +units=m +no_defs


nrow(sf_points[!duplicated(sf_points), ]) == nrow(sf_points)
> TRUE

st_crs(sf_points) == st_crs(parcelas) # test crs
> TRUE

sf_points_intersection <- st_intersection(sf_points, sf_polygon)

sf_points_intersection
Simple feature collection with 121716 features and 9 fields
geometry type:  POINT
dimension:      XY
bbox:           xmin: 596646.7 ymin: 7317070 xmax: 607109.9 ymax: 7326184
epsg (SRID):    32722
proj4string:    +proj=utm +zone=22 +south +datum=WGS84 +units=m +no_defs


nrow(sf_points_intersection[!duplicated(sf_points_intersection), ]) == nrow(sf_points_intersection)
> FALSE


nrow(sf_points_intersection[duplicated(as.data.frame(sf_points_intersection)), ])
> 37056
Bumped by Community user
Source Link

why sf :: st_intersection() returns duplicate features

why sf :: st_intersection returns duplicate features.

I can't understand why st_intersection adds duplicate lines to my sf data frame.

 sf_points

Simple feature collection with 156421 features and 9 fields
geometry type:  POINT
dimension:      XY
bbox:           xmin: 596640.7 ymin: 7317066 xmax: 607113.9 ymax: 7326187
epsg (SRID):    32722
proj4string:    +proj=utm +zone=22 +south +datum=WGS84 +units=m +no_defs

sf_polygons

Simple feature collection with 225 features and 4 fields
geometry type:  POLYGON
dimension:      XY
bbox:           xmin: 543943.6 ymin: 7317069 xmax: 607110.9 ymax: 7342239
epsg (SRID):    32722
proj4string:    +proj=utm +zone=22 +south +datum=WGS84 +units=m +no_defs


nrow(sf_points[!duplicated(sf_points), ]) == nrow(sf_points)
> TRUE

st_crs(sf_points) == st_crs(parcelas) # test crs
> TRUE

sf_points_intersection <- st_intersection(sf_points, sf_polygon)

sf_points_intersection
Simple feature collection with 121716 features and 9 fields
geometry type:  POINT
dimension:      XY
bbox:           xmin: 596646.7 ymin: 7317070 xmax: 607109.9 ymax: 7326184
epsg (SRID):    32722
proj4string:    +proj=utm +zone=22 +south +datum=WGS84 +units=m +no_defs


nrow(sf_points_intersection[!duplicated(sf_points_intersection), ]) == nrow(sf_points_intersection)
> FALSE


nrow(sf_points_intersection[duplicated(as.data.frame(sf_points_intersection)), ])
> 37056

I appreciate some help in understanding this behavior.