0

When I run this code

library(rworldmap)
data("coastsCoarse")
plot(coastsCoarse)
RobinsonProj <-  "+proj=robin +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs"
crsLoc <- CRS(RobinsonProj)
coastsCoarse <- sp::spTransform(coastsCoarse, crsLoc)
plot(coastsCoarse)

coastsCoarse is a SpatialLinesDataFrame. I get one plot that looks like the coasts of the continents. The second plot, after projecting into Robinson returns a horizontal line across the top of the plot of the continents. How do I get rid of that line in the projected version? Extra credit for an explanation of how to get rid of Antarctica.

1 Answer 1

1

A kind of a workaround that seems to work for this data set (there's no general solution possible with this toolkit)

 x <- sp::spTransform(raster::crop(coastsCoarse, raster::extent(-179.95, 179.95, -90, 90)), crsLoc)
 

That just erases a little from each side of the input data, to avoid the ambiguity of -180/180 longitude way under the hood. (I name the result x to differentiate it from the data in the package).

To get rid of Antarctica 😱 set ymin to -60.

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.