I'm new to R and GIS so please forgive me if this is a simple request.

I was looking for a way to find out if a Lat/Long point is on land or ocean. I found this previous post from a couple of years ago which provides an array of true/false results.

Given a Lat and Lon, identify if the point is over land or ocean?

I was able to get it to display the simple world map with the points, but I had two questions:

How do I use the rworldmap with the more detailed and up to date country polygons? How do I return only the Lat/Long points that are on land?

Basically I am looking to get the Lat/Long points that are on land only and don't know where to start.

1 Answer 1


So it turns out it is a single line of code. Using the example in the link, the line of code to only return the lat/long points that are on land is:

pts_land <- pts[c(ii)]

Where pts are all the lat/long points, ii is an array of true/false values and pts_land has all the lat/long points that are on land.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.