I have a shapefile (mult_point_example.shp
) in a multipoint geometry:
# Packages
require(sf)
# get AOI
download.file(
"https://github.com/Leprechault/trash/raw/main/mult_point_example.zip",
zip_path <- tempfile(fileext = ".zip")
)
unzip(zip_path, exdir = tempdir())
# Open the files
setwd(tempdir())
my_multi_points <- sf::st_read("mult_point_example.shp")
#Reading layer `mult_point_example' from data source `C:\Users\fores\AppData\Local\Temp\RtmpmQybFP\mult_point_example.shp' using driver `ESRI Shapefile'
#Simple feature collection with 8 features and 10 fields
#Geometry type: MULTIPOINT
#Dimension: XYZ
#Bounding box: xmin: -52.73354 ymin: -19.79479 xmax: -52.72586 ymax: -19.79067
#z_range: zmin: 0 zmax: 0
#Geodetic CRS: WGS 84
But, I'd like to convert the multipoint object to point geometry. Please I need some help to convert each point in (my_multi_points
) to individuals features.
Use
st_cast(., "POINT")
. However, note that when you cast toPOINT
, the features are repeated, i.e. in the case of oneMULTIPOINT
(one row with several features ) containing 20 points, when you cast toPOINT
you get 20 rowsPOINT
with the same features than the originalMULTIPOINT
:Created on 2021-05-26 by the reprex package (v2.0.0)