[R-sig-Geo] making wrld_simpl longitude borders something other than (-180, 180)
Nick Matzke
matzke at nimbios.org
Mon Sep 14 08:04:32 CEST 2015
Ah, this did it:
http://stackoverflow.com/questions/17718928/how-to-switch-to-a-map-that-is-centered-on-the-china-instead-of-the-default-set
(plotting to PDF helps speed it up)
library(geosphere)
library(gdata) # for read.xls
library(maptools) # for e.g. wrld_simpl
library(rgdal)
library(gpclib) # for polygon clipping
pdffn = "wrld_simpl.pdf"
pdf(file=pdffn, width=12, height=6)
data(wrld_simpl) #The world as a SpatialPolygonsDataFrame
#To avoid the lines crossing the map after reprojection we need to cut the
polygons at the new break:
w <- nowrapRecenter(wrld_simpl, offset = 180-100, avoidGEOS=TRUE)
#Then proceed with the reprojection (note the proj4 string for a mollweide
projection with 150°E as the new center)
wrld_reCentered <- spTransform(w, CRS("+proj=moll +lon_0=-100"))
plot(wrld_reCentered, border="grey", lwd=0.5)
dev.off()
cmdstr = paste0("open ", pdffn)
system(cmdstr)
On Mon, Sep 14, 2015 at 3:46 PM, Nick Matzke <matzke at nimbios.org> wrote:
> Apologies, I got my wires crossed.
>
> What I meant was, how would I make a map where the left edge was at
> longitude 100 (e.g. Thailand), and the right edge is at, say 99
> (again Thailand). The Pacific Ocean, and the International Dateline, would
> be in the middle of this map.
>
> I tried the obvious thing:
> plot(wrld_simpl, xlim = c(100, 99))
>
> ...but that produces a flipped map...
>
> Cheers!
> Nick
>
>
> On Mon, Sep 14, 2015 at 3:38 PM, Frede Aakmann Tøgersen <frtog at vestas.com>
> wrote:
>
>> Hi Nick
>>
>> To be honest I do not understand your question so I am guessing that you
>> probably only need to set the xlim to c(-100, 100). Here is an example:
>>
>> > data(wrld_simpl)
>> > plot(wrld_simpl)
>> > plot(wrld_simpl, xlim = c(-100, 100))
>>
>> Why would one wants to redefine the longitudes from the interval (-180,
>> 180) to (-100, 100)?
>>
>>
>> Yours sincerely / Med venlig hilsen
>>
>> Frede Aakmann Tøgersen
>> Specialist, M.Sc., Ph.D.
>> Plant Performance & Modeling
>>
>> Technology & Service Solutions
>> T +45 9730 5135
>> M +45 2547 6050
>> frtog at vestas.com
>> http://www.vestas.com
>>
>> Company reg. name: Vestas Wind Systems A/S
>> This e-mail is subject to our e-mail disclaimer statement.
>> Please refer to www.vestas.com/legal/notice
>> If you have received this e-mail in error please contact the sender.
>>
>>
>> -----Original Message-----
>> From: R-sig-Geo [mailto:r-sig-geo-bounces at r-project.org] On Behalf Of
>> Nick Matzke
>> Sent: 14. september 2015 06:51
>> To: r-sig-geo at stat.math.ethz.ch
>> Subject: [R-sig-Geo] making wrld_simpl longitude borders something other
>> than (-180, 180)
>>
>> Hi all,
>>
>> I would like to plot wrld_simpl, but have the left and right edges of the
>> map be at something like 100 degrees longitude, rather than (-180, 180).
>>
>> I tried messing with the bounding box with no luck.
>>
>> I can imagine something like burrowing into the object and subtracting 80
>> degrees from all the longitudes, but I suspect there must be a better way?
>>
>> Any help appreciated!
>> Nick
>>
>> [[alternative HTML version deleted]]
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
>
>
[[alternative HTML version deleted]]
More information about the R-sig-Geo
mailing list