Cartography and data analyses on Rstudio


I have extracted data on plant harvests from the Tropicos database. I have a table of data (CSV format) with many columns, 3 of which are of interest to me:

  • LatitudeDecimal
  • LongitudeDecimal
  • Species (this table contains many different species)

I have already managed to create a distribution map of these species with the background of the Malagasy map. Here is the code:

data_unique <- data %>
group_by(LongitudeDecimal, LatitudeDecimal) %>%
slice_head(n = 1) %>%

Convert the dataset to a SpatialPointsDataFrame object

data_sp <- SpatialPointsDataFrame(data_unique[,c("LongitudeDecimal", "LatitudeDecimal")], data_unique)

data_sf <- st_as_sf(data_sp)

assign the CRS of madagascar to data_sf

st_crs(data_sf) <- st_crs(madagascar)
data_sf <- data_sf[st_intersects(data_sf, madagascar),]


ggplot() +
geom_sf(data = data_sf) +
geom_sf(data = madagascar, fill = NA, color = "red «

My question is how can I create distribution areas for each species? I would like to connect all the points of the same species and create an area that contains all these points.