Building a world map in spelling projection gives "not end points",

I have a shapefile from countries downloaded from here . I can build it in R using

countries <- readOGR("shp","TM_WORLD_BORDERS-0.3",encoding="UTF-8",stringsAsFactors=F) par(mar=c(0,0,0,0),bg=rgb(0.3,0.4,1)) plot(countries,col=rgb(1,0.8,0.4)) 

Now I want to build it in spelling projection (Earth visible from space), so I'm trying

 countries <- spTransform(countries,CRS("+proj=ortho +lat_0=-10 +lon_0=-60")) 

I also played with the parameters x_0 and y_0 (as indicated here ), but always get the error:

 non finite transformation detected: [1] 45.08332 39.76804 Inf Inf Erro em .spTransform_Polygon(input[[i]], to_args = to_args, from_args = from_args, : failure in Polygons 3 Polygon 1 points 1 Alรฉm disso: Mensagens de aviso perdidas: In .spTransform_Polygon(input[[i]], to_args = to_args, from_args = from_args, : 108 projected point(s) not finite 

sometimes in the third polygon, sometimes in the 7th. Where does Inf come from? Do I need to change any parameter? I want to build a map like this

orthographic projection

but focused on South America. Thanks for your help!

+5
source share
1 answer

Try the maps package. It gives a warning about points that cannot be projected, but it does not give an error and closes the process. Fiddling a bit, namely, setting the fill color for the ocean ( this answer helped solve this problem), I was able to imitate the map that you attached with two pairs:

 library(maps) ## start plot & extract coordinates from orthographic map o <- c(-10,-60,0) # oreantation xy <- map("world",proj="orthographic", orientation=o, bg="black") xy <- na.omit(data.frame(do.call(cbind, xy[c("x","y")]))) ## draw a circle around the points for coloring the ocean polygon(max(xy$x)*sin(seq(0,2*pi,length.out=100)),max(xy$y)*cos(seq(0,2*pi,length.out=100)), col="blue4", border=rgb(1,1,1,0.5), lwd=2) ## overlay world map colRamp <- colorRampPalette(c("lemonchiffon", "orangered")) map("world",proj="orthographic", orientation=o, fill=TRUE, col=colRamp(5), add=TRUE) 

enter image description here

+4
source

Source: https://habr.com/ru/post/1203631/


All Articles