[R-sig-Geo] Convert geojson file to R
Miluji Sb
m||uj|@b @end|ng |rom gm@||@com
Mon Nov 28 13:08:42 CET 2022
Greetings everyone,
I would like to convert the geojson file (
https://drive.google.com/file/d/18h3sOjZg5jp5euLTWRi5mC40Sja8TZDN/view?usp=sharing)
to a dataframe - essentially obtain which has coordinates matched to a
country.
I have tried the following;
###
states <- geojsonsf::geojson_sf("~/countrymasks.geojson")
geo <- geojsonsf::sf_geojson(states)
sf <- sf::st_read(geo, quiet = T )
df <- as.data.frame(sf::st_coordinates(sf) )
##
But I get the following output, I am a bit lost. Any help will be highly
appreciated.
Best,
structure(list(X = c(-67.3804401, -67.36091, -67.3805899999999,
-67.3397099999998, -67.3780199, -67.3221199999999), Y = c(-55.5655699999996,
-55.5840098999999, -55.6004100000001, -55.6149699999997, -55.63521,
-55.6400899999997), L1 = c(1, 1, 1, 1, 1, 1), L2 = c(1, 1, 1,
1, 1, 1), L3 = c(1, 1, 1, 1, 1, 1)), row.names = c(NA, 6L), class =
"data.frame")
[[alternative HTML version deleted]]
More information about the R-sig-Geo
mailing list