You don't need to call data.frame()
around the extract - the @data
slot already is a data.frame. Just do
df <- asf52@data
to pull out a copy. That said, you may be better served by using the newer sf
library for this task:
library(sf)
ob_kml <- file.path(getwd(), 'Outbreaks 56 (OIE).kml')
There is more than one layer in your KML - list them with e.g.
st_layers(ob_kml)
Use read_sf()
with the layers
argument to choose your point data specifically and read it in. read_sf()
defaults to stringsAsFactors = FALSE which may be preferable.
asf_c <- read_sf(ob_kml, layer = 'ASF in China.xlsx')
To get a plain dataframe, just drop the geometry as follows:
asf_c_df <- st_set_geometry(asf_c, NULL)