[R-sig-Geo] adding a scale

Gilles Benjamin Leduc gbl1 at hi.is
Fri Apr 24 16:34:41 CEST 2015


 
 Actually, my PhD Supervisor asked me to add a scale… and using a GPS system is requierd for technical reasons. If I use such a code, I get http://www.legtux.org/?page=upload&id=565677793, which isn't a satisfacting result. I shall do whatever my PhD supervisor ask… For it is written in Bible: "Thou shall honor, obey and respect your God, your parent and your PhD supervisor" (sotty for the joke, it's friday, start to be exhausted) 

Benjamin  
 
On Friday, April 24, 2015 13:17 GMT, Roger Bivand <Roger.Bivand at nhh.no> wrote: 
 
> On Fri, 24 Apr 2015, Gilles Benjamin Leduc wrote:
> 
> > Here i a minimal exemple:
> >
> > #Get data
> > data(state)
> > states <- data.frame(state.x77, state.center)
> > states <- states[states$x > -121,]
> > coordinates(states) <- c("x", "y")
> > proj4string(states) <- CRS("+proj=longlat +ellps=clrk66")
> > #Put in my system
> > spTransform(states,CRS(" +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0 "))->states
> > #plot it
> > plot(states,axes = TRUE)
> 
> library(sp)
> library(rgdal)
> data(state)
> states <- data.frame(state.x77, state.center)
> states <- states[states$x > -121,]
> coordinates(states) <- c("x", "y")
> proj4string(states) <- CRS("+proj=longlat +ellps=clrk66")
> states <- spTransform(states, CRS(" +proj=longlat +datum=WGS84 +no_defs
>   +ellps=WGS84 +towgs84=0,0,0 ")) # no-op at this scale
> plot(states, axes = TRUE) # scale information provided
> 
> but it isn't either easy or logical to include a metric scale, as a 1cm 
> line will represent (very) different lengths at the north and south of the 
> figure. North is upwards, but if you want a North arrow too, you get it 
> with this (clicking to place the symbol):
> 
> SpatialPolygonsRescale(layout.north.arrow(), offset=locator(1), scale=3, 
> plot.grid=FALSE)
> 
> states <- spTransform(states, CRS("+init=epsg:2163"))
> plot(states, axes=TRUE)
> SpatialPolygonsRescale(layout.north.arrow(), offset=locator(1), 
> scale=4e+5, plot.grid=FALSE)
> SpatialPolygonsRescale(layout.scale.bar(), offset=locator(1), 
> scale=500000, fill=c("transparent", "black"), plot.grid=FALSE)

> text(locator(1), "0")
> text(locator(1), "500 km")
> 
> is at least not stupid, even if not shiny graphically. They are, however, 
> redundant as information, as all that is needed is in the axes.
> 
> Roger
> 
> >
> > How to add a scale on it… the function spplot do not work with my shapefile.
> >
> > Benjamin
> >
> >
> > On Friday, April 24, 2015 12:32 GMT, Roger Bivand <Roger.Bivand at nhh.no> wrote:
> >
> >> On Fri, 24 Apr 2015, Gilles Benjamin Leduc wrote:
> >>
> >>> Hi again,
> >>>
> >>> So, I use the plot() function.
> >>> I read a shapefile, that I convert in GPS coordinates like this:

> >>
> >> Please do provide a reproducible example. When you have a working

> >> reproducible example, you'll find that you have solved your problem. Note
> >> that right-assignment is confusing. Have you consulted the R spatial
> >> graphics gallery:
> >>
> >> http://rspatial.r-forge.r-project.org/gallery/
> >>
> >> Further note that metric scales are hard to get right on maps in degrees.
> >> Usually, the inclusion of annotated axes is a rational substitute for a
> >> scale bar, and by default the vertical axis is the same as the North
> >> arrow, which is only really needed when vertical is not North.
> >>
> >> Roger
> >>
> >>>
> >>> readOGR(dsn="IS50V_STRANDLINA_24122014_ISN2004/IS50V_STRANDLINA_SHP", layer="is50v_strandlina_flakar_24122014")->IslHD
> >>> spTransform(IslHD,CRS(" +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0 "))->IslHD
> >>>
> >>> then plot : plot(IslHD)
> >>>
> >>> I tried several stuff for making a scale, results were either ugly or wrong…
> >>> The function Scalebar make a cute scale but really absurd…
> >>>
> >>> Any idea?
> >>>
> >>> Best regards
> >>>
> >>> Benjamin
> >>>
> >>>
> >>> On Thursday, April 23, 2015 05:18 GMT, Frede Aakmann Tøgersen <frtog at vestas.com> wrote:
> >>>
> >>>> Hi Benjamin
> >>>>
> >>>> Yes, there are several ways to do that. But it depends on which kind of plotting function you used. Usually it is a setting of an argument of the plotting function.
> >>>>
> >>>> I cannot help you more since I don't more than the information you provided in your email.
> >>>>
> >>>> If you want more help from this list please provide a small example showing which functions you used with information on which package(s) they belong. Then you'll probably get more help.
> >>>>
> >>>> The small example you can probably find in the example section on the help page for the plotting function.
> >>>>
> >>>> Best Regards
> >>>>
> >>>> 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 Gilles Benjamin Leduc
> >>>> Sent: 23. april 2015 02:46
> >>>> To: r-sig-geo at r-project.org
> >>>> Subject: [R-sig-Geo] adding a scale
> >>>>
> >>>> Hi all,
> >>>>
> >>>> I am ploting map from shapefiles (curently read with readOGR from rgdal).
> >>>> My PhD supervisor asked me to add a scale… Before going in crazy computation and the arrow function I wonder… Is there a function that can do it automatically (or easily)
> >>>>
> >>>> Thanks in advance
> >>>>
> >>>> Benjamin
> >>>>
> >>>> _______________________________________________
> >>>> R-sig-Geo mailing list
> >>>> R-sig-Geo at r-project.org
> >>>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> >>>
> >>> _______________________________________________
> >>> R-sig-Geo mailing list
> >>> R-sig-Geo at r-project.org
> >>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> >>
> >> --
> >> Roger Bivand
> >> Department of Economics, Norwegian School of Economics,
> >> Helleveien 30, N-5045 Bergen, Norway.
> >> voice: +47 55 95 93 55; fax +47 55 95 91 00
> >> e-mail: Roger.Bivand at nhh.no
> >
> >
> >
> >
> 
> -- 
> Roger Bivand
> Department of Economics, Norwegian School of Economics,
> Helleveien 30, N-5045 Bergen, Norway.
> voice: +47 55 95 93 55; fax +47 55 95 91 00
> e-mail: Roger.Bivand at nhh.no



More information about the R-sig-Geo mailing list