Round geographical coordinates for classes with intervals of 0.5° latitude/longitude

Asked

Viewed 102 times

1

I have the following data.frame with the occurrence coordinates of a species:

 df <- data.frame(
    especie = c("sp1", "sp2", "sp3"),
    longitude = c(-48.97376, -36.08333, -41.66931),
    latitude = c(-21.138258, -9.933333, -14.197054))
       
df

 especie longitude   latitude
     sp1 -48.97376 -21.138258
     sp2 -36.08333  -9.933333
     sp3 -41.66931 -14.197054

I need to round these coordinates so that they are distributed in classes of 0.5 degrees latitude/longitude. For example:

 longitude latitude
    -71.75    12.25
    -71.25    12.25
    -72.25    11.75
    -71.75    11.75
    -73.75    11.25
    -73.25    11.25
  • I edited the question but it remained closed. The function round_any package plyr will round the coordinates the way you want them.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.