[R] Zoom In/Out maps library

Roy Mendelssohn - NOAA Federal roy@mende|@@ohn @end|ng |rom no@@@gov
Wed Mar 6 23:48:12 CET 2019


see https://r-spatial.github.io/mapview/index.html

The main thing is the data types that map view supports,  so you must have a raster or an spatial object like an "sf" object.   So points would have to also be an sf object and the two combined  (sf has commands to do this) or perhaps you can do ti directly in mapview,  I haven't played with it much.

The plotly example I sent works with ggplot2,  so if you know how to build up the map in ggplot2 you can try that,  though again as far as I can see plotly for maps needs sf objects.

Mainly sent you the links to get you started.  I haven't played with either much,  just know that they exist and zoom maps.

HTH,

-Roy

> On Mar 6, 2019, at 2:36 PM, <reichmanj using sbcglobal.net> <reichmanj using sbcglobal.net> wrote:
> 
> Roy
> 
> Thank you - that's helpful.  Going to have to read up on sf and mapview
> library. Those are new ones.  Then to add a point feature layer (lat/long)
> where would I insert that?
> 
> Library(maps)
> Library(sf) # simple features
> Library(mapview)
> 
> world.map <- maps::map("world", plot = FALSE, fill = TRUE) 
> p <- sf::st_as_sf(world.map, coords = c('x', 'y')) 
> mapview::mapview(p, legend=FALSE)
> 
> 
> 
> -----Original Message-----
> From: rmendelss gmail <rmendelss using gmail.com> 
> Sent: Wednesday, March 6, 2019 4:11 PM
> To: reichmanj using sbcglobal.net
> Cc: R help Mailing list <r-help using r-project.org>
> Subject: Re: [R] Zoom In/Out maps library
> 
> world.map <- maps::map("world", plot = FALSE, fill = TRUE) p <- sf::
> st_as_sf(world.map, coords = c('x', 'y')) map view::map view(p)
> 
> HTH,
> 
> -Roy
> 
>> On Mar 6, 2019, at 1:44 PM, reichmanj using sbcglobal.net wrote:
>> 
>> R Help
>> 
>> Anyone know if I can add a zoom In/Out function to the maps available via
> the "maps" library? Or do I need to use a different mapping library?
>> 
>> world.map <- map_data("world")
>> 
>> ggplot(data = world.map) +
>> geom_polygon(mapping = aes(x=long, y=lat, group=group))
>> 
>> Jeff
>> 
>> ______________________________________________
>> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see 
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide 
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
> 
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



**********************
"The contents of this message do not reflect any position of the U.S. Government or NOAA."
**********************
Roy Mendelssohn
Supervisory Operations Research Analyst
NOAA/NMFS
Environmental Research Division
Southwest Fisheries Science Center
***Note new street address***
110 McAllister Way
Santa Cruz, CA 95060
Phone: (831)-420-3666
Fax: (831) 420-3980
e-mail: Roy.Mendelssohn using noaa.gov www: http://www.pfeg.noaa.gov/

"Old age and treachery will overcome youth and skill."
"From those who have been given much, much will be expected" 
"the arc of the moral universe is long, but it bends toward justice" -MLK Jr.



More information about the R-help mailing list