You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Lately I've been trying to use joins for pairs of sf objects and data.frames and I came across a problematic joins. When a data.frame is the main object in join., then a new object has a geometry column, but doesn't have a sf class.
My expectation is that a geom column should be removed in these cases. I'm not sure, if my expectation is the best. What do you think?
library(tidyverse)
library(sf)
sf_obj= st_read(system.file("shape/nc.shp", package="sf")) %>% filter(NAME%in%
c("Ashe", "Surry")) %>% select(NAME)
#> Reading layer `nc' from data source `/home/jn/R/x86_64-redhat-linux-gnu-library/3.3/sf/shape/nc.shp' using driver `ESRI Shapefile'#> Simple feature collection with 100 features and 14 fields#> geometry type: MULTIPOLYGON#> dimension: XY#> bbox: xmin: -84.32385 ymin: 33.88199 xmax: -75.45698 ymax: 36.58965#> epsg (SRID): 4267#> proj4string: +proj=longlat +datum=NAD27 +no_defsdf_obj=data.frame(NAME= c("Ashe", "Surry", "Rowan"), VALUE= c(1, 4, 6))
left_join1=df_obj %>% left_join(sf_obj, by="NAME")
#> Warning: Column `NAME` joining factors with different levels, coercing to#> character vectorleft_join1#> NAME VALUE geometry#> 1 Ashe 1 MULTIPOLYGON(((-81.47275543...#> 2 Surry 4 MULTIPOLYGON(((-80.45634460...#> 3 Rowan 6 NULLright_join2=df_obj %>% right_join(sf_obj, by="NAME")
#> Warning: Column `NAME` joining factors with different levels, coercing to#> character vectorright_join2#> NAME VALUE geometry#> 1 Ashe 1 MULTIPOLYGON(((-81.47275543...#> 2 Surry 4 MULTIPOLYGON(((-80.45634460...inner_join1=df_obj %>% inner_join(sf_obj, by="NAME")
#> Warning: Column `NAME` joining factors with different levels, coercing to#> character vectorinner_join1#> NAME VALUE geometry#> 1 Ashe 1 MULTIPOLYGON(((-81.47275543...#> 2 Surry 4 MULTIPOLYGON(((-80.45634460...full_join2=df_obj %>% full_join(sf_obj, by="NAME")
#> Warning: Column `NAME` joining factors with different levels, coercing to#> character vectorfull_join2#> NAME VALUE geometry#> 1 Ashe 1 MULTIPOLYGON(((-81.47275543...#> 2 Surry 4 MULTIPOLYGON(((-80.45634460...#> 3 Rowan 6 NULL
The text was updated successfully, but these errors were encountered:
Second part of this issue - r-spatial/sf#372
Lately I've been trying to use joins for pairs of sf objects and data.frames and I came across a problematic joins. When a data.frame is the main object in join., then a new object has a geometry column, but doesn't have a sf class.
My expectation is that a geom column should be removed in these cases. I'm not sure, if my expectation is the best. What do you think?
The text was updated successfully, but these errors were encountered: