Created
August 9, 2017 22:18
-
-
Save yutannihilation/e9c56f476ff708f3e0c098d2fb3fee24 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(dplyr) | |
#> | |
#> Attaching package: 'dplyr' | |
#> The following objects are masked from 'package:stats': | |
#> | |
#> filter, lag | |
#> The following objects are masked from 'package:base': | |
#> | |
#> intersect, setdiff, setequal, union | |
library(sf) | |
#> Linking to GEOS 3.6.1, GDAL 2.2.0, proj.4 4.9.3 | |
library(ggplot2) | |
library(spData) | |
d <- world %>% | |
group_by(continent) %>% | |
summarize(pop = sum(pop, na.rm = TRUE), country_n = n()) | |
d | |
#> Simple feature collection with 8 features and 3 fields | |
#> geometry type: GEOMETRY | |
#> dimension: XY | |
#> bbox: xmin: -180 ymin: -90 xmax: 180 ymax: 83.64513 | |
#> epsg (SRID): 4326 | |
#> proj4string: +proj=longlat +datum=WGS84 +no_defs | |
#> # A tibble: 8 x 4 | |
#> continent pop country_n geom | |
#> <chr> <dbl> <int> <simple_feature> | |
#> 1 Africa 1147005839 51 <MULTIPOLYGON...> | |
#> 2 Antarctica 0 1 <MULTIPOLYGON...> | |
#> 3 Asia 4306025131 47 <MULTIPOLYGON...> | |
#> 4 Europe 739178065 39 <MULTIPOLYGON...> | |
#> 5 North America 565318889 18 <MULTIPOLYGON...> | |
#> 6 Oceania 37422867 7 <MULTIPOLYGON...> | |
#> 7 Seven seas (open ocean) 0 1 <POLYGON((68....> | |
#> 8 South America 414017917 13 <MULTIPOLYGON...> | |
ggplot(d) + | |
geom_sf(aes(geometry = geom, fill = continent)) | |
#> type is 0 | |
#> Error in CPL_gdal_dimension(st_geometry(x), NA_if_empty): writing this sf type is not supported, please file an issue |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment