adding a scale

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

adding a scale

GiBy
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
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: adding a scale

Frede Aakmann Tøgersen-2
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
[hidden email]
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:[hidden email]] On Behalf Of Gilles Benjamin Leduc
Sent: 23. april 2015 02:46
To: [hidden email]
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
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: adding a scale

Barry Rowlingson
In reply to this post by GiBy
Searching for "R map scale bar" should get you enough helpful hints,
including this nice looking blog post

http://andybeger.com/2012/08/25/scale-and-north-arrow-for-maps-in-r/
On 23 Apr 2015 01:46, "Gilles Benjamin Leduc" <[hidden email]> wrote:

> 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
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: adding a scale

GiBy
In reply to this post by Frede Aakmann Tøgersen-2
Hi again,

So, I use the plot() function.
I read a shapefile, that I convert in GPS coordinates like this:

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 <[hidden email]> 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
> [hidden email]
> 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:[hidden email]] On Behalf Of Gilles Benjamin Leduc
> Sent: 23. april 2015 02:46
> To: [hidden email]
> 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
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: adding a scale

Roger Bivand
Administrator
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 <[hidden email]> 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
>> [hidden email]
>> 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:[hidden email]] On Behalf Of Gilles Benjamin Leduc
>> Sent: 23. april 2015 02:46
>> To: [hidden email]
>> 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
>> [hidden email]
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> 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: [hidden email]
_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Roger Bivand
Department of Economics
Norwegian School of Economics
Helleveien 30
N-5045 Bergen, Norway
Reply | Threaded
Open this post in threaded view
|

Re: adding a scale

GiBy
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 <[hidden email]> 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 <[hidden email]> 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
> >> [hidden email]
> >> 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:[hidden email]] On Behalf Of Gilles Benjamin Leduc
> >> Sent: 23. april 2015 02:46
> >> To: [hidden email]
> >> 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
> >> [hidden email]
> >> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> >
> > _______________________________________________
> > R-sig-Geo mailing list
> > [hidden email]
> > 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: [hidden email]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: adding a scale

Roger Bivand
Administrator
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 <[hidden email]> 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 <[hidden email]> 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
>>>> [hidden email]
>>>> 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:[hidden email]] On Behalf Of Gilles Benjamin Leduc
>>>> Sent: 23. april 2015 02:46
>>>> To: [hidden email]
>>>> 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
>>>> [hidden email]
>>>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>>
>>> _______________________________________________
>>> R-sig-Geo mailing list
>>> [hidden email]
>>> 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: [hidden email]
>
>
>
>
--
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: [hidden email]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Roger Bivand
Department of Economics
Norwegian School of Economics
Helleveien 30
N-5045 Bergen, Norway
Reply | Threaded
Open this post in threaded view
|

Re: adding a scale

GiBy
 
 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 <[hidden email]> 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 <[hidden email]> 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 <[hidden email]> 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
> >>>> [hidden email]
> >>>> 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:[hidden email]] On Behalf Of Gilles Benjamin Leduc
> >>>> Sent: 23. april 2015 02:46
> >>>> To: [hidden email]
> >>>> 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
> >>>> [hidden email]
> >>>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> >>>
> >>> _______________________________________________
> >>> R-sig-Geo mailing list
> >>> [hidden email]
> >>> 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: [hidden email]
> >
> >
> >
> >
>
> --
> 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: [hidden email]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: adding a scale

Guido Schulz
In reply to this post by GiBy
You may want to check out this paper "Auxiliary Cartographic Functions
in R: North Arrow, Scale Bar, and Label with a Leader Arrow"
(http://www.jstatsoft.org/v19/c01/paper).

It provides functions to add arrow and scale bar for plot.


Am 24.04.2015 um 14:10 schrieb Gilles Benjamin Leduc:

> Hi again,
>
> So, I use the plot() function.
> I read a shapefile, that I convert in GPS coordinates like this:
>
> readOGR(dsn=S50V_STRANDLINA_24122014_ISN2004/IS50V_STRANDLINA_SHP", layer="is50v_strandlina_flakar_24122014")->IslHD
> spTransform(IslHD,CRS(" +proj=nglat +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 <[hidden email]> 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
>> [hidden email]
>> 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:[hidden email]] On Behalf Of Gilles Benjamin Leduc
>> Sent: 23. april 2015 02:46
>> To: [hidden email]
>> 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
>> [hidden email]
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
>

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: adding a scale

GiBy
 
 Not to bad hint :p

So From this one, I modified the function to get it work correctly:

#############################################################################################################################################################################
####                                                                     Scale                                                                     ####
#############################################################################################################################################################################

scalebar <- function(loc,length,unit="km" ,degrees = TRUE,cex=par("cex"), ...) {
        if(missing(loc)) stop("loc is missing")
        if(missing(length)) stop("length is missing")
        z <- c(0,length/c(4,2,4/3,1),length*1.1)+loc[1]
        if(degrees == TRUE) length<-180*(acos((cos(length/6371)-sin(loc[2]*pi/180)*sin(loc[2]*pi/180))/(cos(loc[2]*pi/180)*cos(loc[2]*pi/180))))/pi
        x <- c(0,length/c(4,2,4/3,1),length*1.1)+loc[1]
        y <- c(0,length/(10*3:1))+loc[2]
        cols <- rep(c("black","white"),2)
        for (i in 1:4) rect(x[i],y[1],x[i+1],y[2],col=cols[i])
         for (i in 1:5) segments(x[i],y[2],x[i],y[3])
         labels <- z[c(1,3)]-loc[1]
labels <- append(labels,paste(z[5]-loc[1],unit))
text(x[c(1,3,5)],y[4],labels=labels,cex,pos=3,offset=0) }


and pushed it in my package https://github.com/giby/Linarius if someone wanna try. I could do some improve to support other units, I'll do that latter on.  

Thanks a lot for help

Benjamin
 
On Saturday, April 25, 2015 10:36 GMT, Guido Schulz <[hidden email]> wrote:
 

> You may want to check out this paper "Auxiliary Cartographic Functions
> in R: North Arrow, Scale Bar, and Label with a Leader Arrow"
> (http://www.jstatsoft.org/v19/c01/paper).
>
> It provides functions to add arrow and scale bar for plot.
>
>
> Am 24.04.2015 um 14:10 schrieb Gilles Benjamin Leduc:
> > Hi again, > > So, I use the plot() function. > I read a shapefile, that I convert in GPS coordinates like this: > > readOGR(dsn=S50V_STRANDLINA_24122014_ISN2004/IS50V_STRANDLINA_SHP", layer="is50v_strandlina_flakar_24122014")->IslHD
> > spTransform(IslHD,CRS(" +proj=nglat +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 <[hidden email]> 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
> >> [hidden email]
> >> 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:[hidden email]] On Behalf Of Gilles Benjamin Leduc
> >> Sent: 23. april 2015 02:46
> >> To: [hidden email]
> >> 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
> >> [hidden email]
> >> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> > >
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: adding a scale

Robert Hijmans
There is also a 'scalebar' function in the raster package (I have not
compared the two)

Robert

On Mon, Apr 27, 2015 at 7:59 AM, Gilles Benjamin Leduc <[hidden email]> wrote:

>
>  Not to bad hint :p
>
> So From this one, I modified the function to get it work correctly:
>
> #############################################################################################################################################################################
> ####                                                                                     Scale                                                                                               ####
> #############################################################################################################################################################################
>
> scalebar <- function(loc,length,unit="km" ,degrees = TRUE,cex=par("cex"), ...) {
>         if(missing(loc)) stop("loc is missing")
>         if(missing(length)) stop("length is missing")
>         z <- c(0,length/c(4,2,4/3,1),length*1.1)+loc[1]
>         if(degrees == TRUE) length<-180*(acos((cos(length/6371)-sin(loc[2]*pi/180)*sin(loc[2]*pi/180))/(cos(loc[2]*pi/180)*cos(loc[2]*pi/180))))/pi
>         x <- c(0,length/c(4,2,4/3,1),length*1.1)+loc[1]
>         y <- c(0,length/(10*3:1))+loc[2]
>         cols <- rep(c("black","white"),2)
>         for (i in 1:4) rect(x[i],y[1],x[i+1],y[2],col=cols[i])
>          for (i in 1:5) segments(x[i],y[2],x[i],y[3])
>          labels <- z[c(1,3)]-loc[1]
> labels <- append(labels,paste(z[5]-loc[1],unit))
> text(x[c(1,3,5)],y[4],labels=labels,cex,pos=3,offset=0) }
>
>
> and pushed it in my package https://github.com/giby/Linarius if someone wanna try. I could do some improve to support other units, I'll do that latter on.
>
> Thanks a lot for help
>
> Benjamin
>
> On Saturday, April 25, 2015 10:36 GMT, Guido Schulz <[hidden email]> wrote:
>
>> You may want to check out this paper "Auxiliary Cartographic Functions
>> in R: North Arrow, Scale Bar, and Label with a Leader Arrow"
>> (http://www.jstatsoft.org/v19/c01/paper).
>>
>> It provides functions to add arrow and scale bar for plot.
>>
>>
>> Am 24.04.2015 um 14:10 schrieb Gilles Benjamin Leduc:
>> > Hi again, > > So, I use the plot() function. > I read a shapefile, that I convert in GPS coordinates like this: > > readOGR(dsn=S50V_STRANDLINA_24122014_ISN2004/IS50V_STRANDLINA_SHP", layer="is50v_strandlina_flakar_24122014")->IslHD
>> > spTransform(IslHD,CRS(" +proj=nglat +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 <[hidden email]> 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
>> >> [hidden email]
>> >> 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:[hidden email]] On Behalf Of Gilles Benjamin Leduc
>> >> Sent: 23. april 2015 02:46
>> >> To: [hidden email]
>> >> 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
>> >> [hidden email]
>> >> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>> > >
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> [hidden email]
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo