[R-sig-Geo] tpk files

Marta Rufino m@rt@@m@ru||no @end|ng |rom gm@||@com
Mon Apr 15 17:13:07 CEST 2019


Hi,

Finally, the full code that works
Thanks to everybody once again,

Cheers,
M.

# From Edzer Pebesma (thank you) - see also the alternative from Barry
using sqlite3
library(sf)
#open subset the file depth=1
system.time(r.d1 <- st_read("D:/EMU_Z_Opendata/EMU.gpkg", query = "select *
from EMU_Master where depth_lvl = 1"))

# Code chunks copied from below (adapted with the help of Barry Rowlingson):
require(dplyr)
dr <- r.d1 %>%
  dplyr::rename("x"=POINT_X,"y"=POINT_Y) %>%
  dplyr::mutate(NameEMUn = as.numeric(NameEMU)) %>%
  dplyr::select(x,y, NameEMUn) %>%
  st_set_geometry(NULL)

drz <- rasterFromXYZ(dr)
system.time(drzp <- rasterToPolygons(drz,dissolve=TRUE))
# spplot(drzp,"layer")

emu <- st_as_sf(drzp)
st_crs(emu)=4326
emu$NameEMU = levels(d$NameEMU)
plot(emu)
## Allright!!!
# Export as a shape file:
# write_sf(emu, "emu.shp")

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list