Convert shapefile (class sf) to data.table of lat and lon columns Makes lat and lon columns, from a sfc_POINT class geometry field, or finds centroids of POLYGONS
Source:R/shapefile_xyz.R
latlon_from_shapefile.RdConvert shapefile (class sf) to data.table of lat and lon columns Makes lat and lon columns, from a sfc_POINT class geometry field, or finds centroids of POLYGONS
Arguments
- shp
shapefile that is class sf, as from
shapefile_from_any()orsf::st_read(), with geometry column that has points so is class sfc_POINT- include_only_latlon
set to FALSE to have function return lat lon columns plus all of columns in shp. If TRUE, just returns lat lon columns.
Value
data.table with columns named lat and lon,
and optionally all from shp as well,
as can be used as input to ejamit(), mapfast(), etc.