[R-sig-Geo] adding a scale

Gilles Benjamin Leduc gbl1 at hi.is
Fri Apr 24 14:49:27 CEST 2015


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) 
 
 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



More information about the R-sig-Geo mailing list