mapView: basic interactive viewing of spatial data in R

classic Classic list List threaded Threaded
19 messages Options
Reply | Threaded
Open this post in threaded view
|

mapView: basic interactive viewing of spatial data in R

Tim Appelhans
Dear list members,

I would like to draw your attention to a little 'project' I've been
working on over the past few weeks.

Using leaflet for R, I have defined some methods for spatial data (e.g.
Raster*, Spatial* objects) to quickly visualise them in either the
RStudio Viewer pan or the default web browser. The function I created
for this is called mapView().

Think of it as an interactive version of spplot()/plot() for spatial
data (though less versatile). It enables zooming, paning and basic layer
queries (i.e. printing of the attributes in the @data slot of Spatial*
objects + the x/y location of the feature). For Raster* objects queries
are currently not available as leaflet translates the data into RGB
values for display. Furthermore, background maps can be defined and
multiple different spatial object layers can be overlaid.
At the moment mapView() lives in our Rsenal package on github
(https://github.com/environmentalinformatics-marburg/Rsenal) but this is
likely going to change at some point in the not too distant future. This
also depends on whether there is active interest in developping this
sort of thing further to provide more than the current admittedly rather
limited functionality. This, however, would involve JavaScript coding
which I do not have any experience with.

A quick (non-interactive) intorduction can be found here:

https://metvurst.wordpress.com/

The full introductory article including interactive examples is
published here:

http://environmentalinformatics-marburg.github.io/web-presentations/20150723_mapView.html

I hope this may prove useful for some of you.
Also, if anyone is keen to get involved in taking this further, please
let me know and we will see how to best proceed.

Best,
Tim

--
#####################################
Tim Appelhans
Department of Geography
Environmental Informatics
Philipps Universität Marburg
Deutschhausstraße 12
35032 Marburg (Paketpost: 35037 Marburg)
Germany

Tel +49 (0) 6421 28-25957

http://environmentalinformatics-marburg.de/


        [[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: mapView: basic interactive viewing of spatial data in R

Rainer M Krug
Tim Appelhans <[hidden email]> writes:

> Dear list members,
>
> I would like to draw your attention to a little 'project' I've been
> working on over the past few weeks.
>
> Using leaflet for R, I have defined some methods for spatial data (e.g.
> Raster*, Spatial* objects) to quickly visualise them in either the
> RStudio Viewer pan or the default web browser. The function I created
> for this is called mapView().
>
> Think of it as an interactive version of spplot()/plot() for spatial
> data (though less versatile). It enables zooming, paning and basic layer
> queries (i.e. printing of the attributes in the @data slot of Spatial*
> objects + the x/y location of the feature). For Raster* objects queries
> are currently not available as leaflet translates the data into RGB
> values for display. Furthermore, background maps can be defined and
> multiple different spatial object layers can be overlaid.
> At the moment mapView() lives in our Rsenal package on github
> (https://github.com/environmentalinformatics-marburg/Rsenal) but this is
> likely going to change at some point in the not too distant future. This
> also depends on whether there is active interest in developping this
> sort of thing further to provide more than the current admittedly rather
> limited functionality. This, however, would involve JavaScript coding
> which I do not have any experience with.
>
> A quick (non-interactive) intorduction can be found here:
>
> https://metvurst.wordpress.com/
>
> The full introductory article including interactive examples is
> published here:
>
> http://environmentalinformatics-marburg.github.io/web-presentations/20150723_mapView.html
>
> I hope this may prove useful for some of you.
This looks like something I was really missing! I was always exporting
my spatial data into GRASS and viewing it there - but this looks really
brilliant! This makes out of R a very powerful command line GIS.

I would really like to see this functionality in a separate R package on
CRAN - even with only its current functionality, it is very useful!

Thanks a lot and keep us posted,

Rainer

> Also, if anyone is keen to get involved in taking this further, please
> let me know and we will see how to best proceed.
>
> Best,
> Tim

--
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany)

Centre of Excellence for Invasion Biology
Stellenbosch University
South Africa

Tel :       +33 - (0)9 53 10 27 44
Cell:       +33 - (0)6 85 62 59 98
Fax :       +33 - (0)9 58 10 27 44

Fax (D):    +49 - (0)3 21 21 25 22 44

email:      [hidden email]

Skype:      RMkrug

PGP: 0x0F52F982

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

signature.asc (490 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: mapView: basic interactive viewing of spatial data in R

geobernadotte
Hi,

can some one tell me how I can install this package?
Cloning and copying it to the R folder does not do it, installing in from  
file wants to have a tar.gz.
I usually use RStudio.

Thanx
Bernd


Am 24.07.2015, 12:03 Uhr, schrieb Rainer M Krug <[hidden email]>:

> Tim Appelhans <[hidden email]> writes:
>
>> Dear list members,
>>
>> I would like to draw your attention to a little 'project' I've been
>> working on over the past few weeks.
>>
>> Using leaflet for R, I have defined some methods for spatial data (e.g.
>> Raster*, Spatial* objects) to quickly visualise them in either the
>> RStudio Viewer pan or the default web browser. The function I created
>> for this is called mapView().
>>
>> Think of it as an interactive version of spplot()/plot() for spatial
>> data (though less versatile). It enables zooming, paning and basic layer
>> queries (i.e. printing of the attributes in the @data slot of Spatial*
>> objects + the x/y location of the feature). For Raster* objects queries
>> are currently not available as leaflet translates the data into RGB
>> values for display. Furthermore, background maps can be defined and
>> multiple different spatial object layers can be overlaid.
>> At the moment mapView() lives in our Rsenal package on github
>> (https://github.com/environmentalinformatics-marburg/Rsenal) but this is
>> likely going to change at some point in the not too distant future. This
>> also depends on whether there is active interest in developping this
>> sort of thing further to provide more than the current admittedly rather
>> limited functionality. This, however, would involve JavaScript coding
>> which I do not have any experience with.
>>
>> A quick (non-interactive) intorduction can be found here:
>>
>> https://metvurst.wordpress.com/
>>
>> The full introductory article including interactive examples is
>> published here:
>>
>> http://environmentalinformatics-marburg.github.io/web-presentations/20150723_mapView.html
>>
>> I hope this may prove useful for some of you.
>
> This looks like something I was really missing! I was always exporting
> my spatial data into GRASS and viewing it there - but this looks really
> brilliant! This makes out of R a very powerful command line GIS.
>
> I would really like to see this functionality in a separate R package on
> CRAN - even with only its current functionality, it is very useful!
>
> Thanks a lot and keep us posted,
>
> Rainer
>
>> Also, if anyone is keen to get involved in taking this further, please
>> let me know and we will see how to best proceed.
>>
>> Best,
>> Tim
>


--
Bernd Vogelgesang
Siedlerstraße 2
91083 Baiersdorf/Igelsdorf
Tel: 09133-825374

_______________________________________________
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: mapView: basic interactive viewing of spatial data in R

Tim Appelhans


On 24.07.2015 13:13, Bernd Vogelgesang wrote:

> Hi,
>
> can some one tell me how I can install this package?
> Cloning and copying it to the R folder does not do it, installing in
> from file wants to have a tar.gz.
> I usually use RStudio.
>
> Thanx
> Bernd
>

you can use library("devtools") for this. devtools is available on CRAN

library("devtools")
install_github("environmentalinformatics-marburg/Rsenal")

That should do it

>
> Am 24.07.2015, 12:03 Uhr, schrieb Rainer M Krug <[hidden email]>:
>
>> Tim Appelhans <[hidden email]> writes:
>>
>>> Dear list members,
>>>
>>> I would like to draw your attention to a little 'project' I've been
>>> working on over the past few weeks.
>>>
>>> Using leaflet for R, I have defined some methods for spatial data (e.g.
>>> Raster*, Spatial* objects) to quickly visualise them in either the
>>> RStudio Viewer pan or the default web browser. The function I created
>>> for this is called mapView().
>>>
>>> Think of it as an interactive version of spplot()/plot() for spatial
>>> data (though less versatile). It enables zooming, paning and basic
>>> layer
>>> queries (i.e. printing of the attributes in the @data slot of Spatial*
>>> objects + the x/y location of the feature). For Raster* objects queries
>>> are currently not available as leaflet translates the data into RGB
>>> values for display. Furthermore, background maps can be defined and
>>> multiple different spatial object layers can be overlaid.
>>> At the moment mapView() lives in our Rsenal package on github
>>> (https://github.com/environmentalinformatics-marburg/Rsenal) but
>>> this is
>>> likely going to change at some point in the not too distant future.
>>> This
>>> also depends on whether there is active interest in developping this
>>> sort of thing further to provide more than the current admittedly
>>> rather
>>> limited functionality. This, however, would involve JavaScript coding
>>> which I do not have any experience with.
>>>
>>> A quick (non-interactive) intorduction can be found here:
>>>
>>> https://metvurst.wordpress.com/
>>>
>>> The full introductory article including interactive examples is
>>> published here:
>>>
>>> http://environmentalinformatics-marburg.github.io/web-presentations/20150723_mapView.html 
>>>
>>>
>>> I hope this may prove useful for some of you.
>>
>> This looks like something I was really missing! I was always exporting
>> my spatial data into GRASS and viewing it there - but this looks really
>> brilliant! This makes out of R a very powerful command line GIS.
>>
>> I would really like to see this functionality in a separate R package on
>> CRAN - even with only its current functionality, it is very useful!
>>
>> Thanks a lot and keep us posted,
>>
>> Rainer
>>
>>> Also, if anyone is keen to get involved in taking this further, please
>>> let me know and we will see how to best proceed.
>>>
>>> Best,
>>> Tim
>>
>
>

--
#####################################
Tim Appelhans
Department of Geography
Environmental Informatics
Philipps Universität Marburg
Deutschhausstraße 12
35032 Marburg (Paketpost: 35037 Marburg)
Germany

Tel +49 (0) 6421 28-25957

http://environmentalinformatics-marburg.de/

_______________________________________________
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: mapView: basic interactive viewing of spatial data in R

geobernadotte
Thanks a lot!
First it complained that latticeExtra was missing, but now everything is  
in place and running.
I never managed to learn how to create proper plots, so this is really  
nice.
I'm kind of excited!

Bernd

Am 24.07.2015, 13:20 Uhr, schrieb Tim Appelhans <[hidden email]>:

> library("devtools")
> install_github("environmentalinformatics-marburg/Rsenal")


--

_______________________________________________
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: mapView: basic interactive viewing of spatial data in R

Tim Appelhans
In reply to this post by Tim Appelhans


On 24.07.2015 13:29, Agustin Diez Castillo wrote:
> I’m getting an error when testing
>
> error: 'colour_ramp' is not an exported object from 'namespace:scales'

This is strange as 'colour_ramp' is an exported object from
'namespace:scales' as can be seen here

https://github.com/cran/scales/blob/master/NAMESPACE

This function is used by leaflet

https://github.com/cran/leaflet/blob/master/R/colors.R

I do not get this error, my sessionInfo() is

R version 3.2.1 (2015-06-18)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 14.04.2 LTS

locale:
  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C LC_TIME=de_DE.UTF-8        
LC_COLLATE=en_US.UTF-8
  [5] LC_MONETARY=de_DE.UTF-8    LC_MESSAGES=en_US.UTF-8
LC_PAPER=de_DE.UTF-8       LC_NAME=C
  [9] LC_ADDRESS=C               LC_TELEPHONE=C
LC_MEASUREMENT=de_DE.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods base

other attached packages:
[1] Rsenal_0.1.81      raster_2.4-15      sp_1.1-1 leaflet_1.0.0.9999

loaded via a namespace (and not attached):
  [1] htmlwidgets_0.5.1 colorspace_1.2-6  scales_0.2.5 plyr_1.8.3        
magrittr_1.5      htmltools_0.2.6
  [7] tools_3.2.1       Rcpp_0.11.6       grid_3.2.1 digest_0.6.8      
munsell_0.4.2     lattice_0.20-33

which suggests I am using the same version of scales as you are...

I really am not sure what is happening here.

>
>  From the help page
> data(meuse.grid)
> coordinates(meuse.grid) = ~x+y
> proj4string(meuse.grid) <- CRS("+init=epsg:28992")
> gridded(meuse.grid) = TRUE
> meuse_rst <- stack(meuse.grid)
> m1 <- mapView(meuse_rst)
>
> sessionInfo()
> R version 3.1.3 (2015-03-09)
> Platform: x86_64-apple-darwin10.8.0 (64-bit)
> Running under: OS X 10.9.5 (Mavericks)
>
> locale:
> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
>
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  methods   base
>
> other attached packages:
>   [1] leaflet_1.0.0       Rsenal_0.1.81       colorspace_1.2-6    automap_1.0-14      scales_0.2.5        outliers_0.14       spatstat_1.41-1     foreign_0.8-63
>   [9] plyr_1.8.1          rasterVis_0.35      latticeExtra_0.6-26 RColorBrewer_1.1-2  data.table_1.9.4    Bchron_4.1.1        inline_0.3.14       raster_2.3-40
> [17] rgeos_0.3-8         rgdal_0.9-2         lattice_0.20-31     ggplot2_1.0.1       devtools_1.7.0      spdep_0.5-88        Matrix_1.2-0        sp_1.0-17
>
> loaded via a namespace (and not attached):
>   [1] abind_1.4-3      bitops_1.0-6     boot_1.3-16      chron_2.3-45     coda_0.17-1      deldir_0.1-9     digest_0.6.8     ellipse_0.3-8    FNN_1.1          goftest_1.0-2
> [11] grid_3.1.3       gstat_1.0-22     gtable_0.1.2     hdrcde_3.1       hexbin_1.27.0    htmltools_0.2.6  htmlwidgets_0.5  httr_0.6.1       intervals_0.15.0 LearnBayes_2.15
> [21] magrittr_1.5     MASS_7.3-40      mclust_5.0.0     mgcv_1.8-6       munsell_0.4.2    nlme_3.1-120     polyclip_1.3-0   proto_0.3-10     Rcpp_0.11.5      RCurl_1.95-4.5
> [31] reshape_0.8.5    reshape2_1.4.1   spacetime_1.1-3  splines_3.1.3    stringr_0.6.2    tensor_1.5       tools_3.1.3      xts_0.9-7        zoo_1.7-12
>
> On 24Jul, 2015, at 1:20 PM, Tim Appelhans <[hidden email]> wrote:
>
>>
>> On 24.07.2015 13:13, Bernd Vogelgesang wrote:
>>> Hi,
>>>
>>> can some one tell me how I can install this package?
>>> Cloning and copying it to the R folder does not do it, installing in from file wants to have a tar.gz.
>>> I usually use RStudio.
>>>
>>> Thanx
>>> Bernd
>>>
>> you can use library("devtools") for this. devtools is available on CRAN
>>
>> library("devtools")
>> install_github("environmentalinformatics-marburg/Rsenal")
>>
>> That should do it
>>
>>> Am 24.07.2015, 12:03 Uhr, schrieb Rainer M Krug <[hidden email]>:
>>>
>>>> Tim Appelhans <[hidden email]> writes:
>>>>
>>>>> Dear list members,
>>>>>
>>>>> I would like to draw your attention to a little 'project' I've been
>>>>> working on over the past few weeks.
>>>>>
>>>>> Using leaflet for R, I have defined some methods for spatial data (e.g.
>>>>> Raster*, Spatial* objects) to quickly visualise them in either the
>>>>> RStudio Viewer pan or the default web browser. The function I created
>>>>> for this is called mapView().
>>>>>
>>>>> Think of it as an interactive version of spplot()/plot() for spatial
>>>>> data (though less versatile). It enables zooming, paning and basic layer
>>>>> queries (i.e. printing of the attributes in the @data slot of Spatial*
>>>>> objects + the x/y location of the feature). For Raster* objects queries
>>>>> are currently not available as leaflet translates the data into RGB
>>>>> values for display. Furthermore, background maps can be defined and
>>>>> multiple different spatial object layers can be overlaid.
>>>>> At the moment mapView() lives in our Rsenal package on github
>>>>> (https://github.com/environmentalinformatics-marburg/Rsenal) but this is
>>>>> likely going to change at some point in the not too distant future. This
>>>>> also depends on whether there is active interest in developping this
>>>>> sort of thing further to provide more than the current admittedly rather
>>>>> limited functionality. This, however, would involve JavaScript coding
>>>>> which I do not have any experience with.
>>>>>
>>>>> A quick (non-interactive) intorduction can be found here:
>>>>>
>>>>> https://metvurst.wordpress.com/
>>>>>
>>>>> The full introductory article including interactive examples is
>>>>> published here:
>>>>>
>>>>> http://environmentalinformatics-marburg.github.io/web-presentations/20150723_mapView.html
>>>>>
>>>>> I hope this may prove useful for some of you.
>>>> This looks like something I was really missing! I was always exporting
>>>> my spatial data into GRASS and viewing it there - but this looks really
>>>> brilliant! This makes out of R a very powerful command line GIS.
>>>>
>>>> I would really like to see this functionality in a separate R package on
>>>> CRAN - even with only its current functionality, it is very useful!
>>>>
>>>> Thanks a lot and keep us posted,
>>>>
>>>> Rainer
>>>>
>>>>> Also, if anyone is keen to get involved in taking this further, please
>>>>> let me know and we will see how to best proceed.
>>>>>
>>>>> Best,
>>>>> Tim
>>>
>> --
>> #####################################
>> Tim Appelhans
>> Department of Geography
>> Environmental Informatics
>> Philipps Universität Marburg
>> Deutschhausstraße 12
>> 35032 Marburg (Paketpost: 35037 Marburg)
>> Germany
>>
>> Tel +49 (0) 6421 28-25957
>>
>> http://environmentalinformatics-marburg.de/
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> [hidden email]
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

--
#####################################
Tim Appelhans
Department of Geography
Environmental Informatics
Philipps Universität Marburg
Deutschhausstraße 12
35032 Marburg (Paketpost: 35037 Marburg)
Germany

Tel +49 (0) 6421 28-25957

http://environmentalinformatics-marburg.de/

_______________________________________________
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: mapView: basic interactive viewing of spatial data in R

Rainer M Krug
In reply to this post by Tim Appelhans
Tim Appelhans <[hidden email]> writes:

> On 24.07.2015 13:13, Bernd Vogelgesang wrote:
>> Hi,
>>
>> can some one tell me how I can install this package?
>> Cloning and copying it to the R folder does not do it, installing in
>> from file wants to have a tar.gz.
>> I usually use RStudio.
>>
>> Thanx
>> Bernd
>>
>
> you can use library("devtools") for this. devtools is available on CRAN
>
> library("devtools")
> install_github("environmentalinformatics-marburg/Rsenal")
>
> That should do it
That installed it, but "leaflet" is not installed:

,----
| > library(Rsenal
| + )
| Loading required package: raster
| Loading required package: sp
|
| Attaching package: ‘Rsenal’
|
| The following object is masked from ‘package:raster’:
|
|     addLayer
|
| > data(meuse.grid)
| > coordinates(meuse.grid) = ~x+y
| > proj4string(meuse.grid) <- CRS("+init=epsg:28992")
| > gridded(meuse.grid) = TRUE
| > meuse_rst <- stack(meuse.grid)
| > mapView(meuse_rst[[3]])
| Error in loadNamespace(name) : there is no package called ‘leaflet’
| >
`----

After installing and loading leaflet, it works.

After that, "leaflet does not need to be loaded explicitly.

,----
| > sessionInfo()
| R version 3.2.1 (2015-06-18)
| Platform: x86_64-apple-darwin14.4.0 (64-bit)
| Running under: OS X 10.10.4 (Yosemite)
|
| locale:
| [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
|
| attached base packages:
| [1] stats     graphics  grDevices utils     datasets  methods   base
|
| other attached packages:
| [1] Rsenal_0.1.81 raster_2.4-15 sp_1.1-1
|
| loaded via a namespace (and not attached):
|  [1] Rcpp_0.11.6      lattice_0.20-31  png_0.1-7        digest_0.6.8
|  [5] grid_3.2.1       plyr_1.8.3       jsonlite_0.9.16  magrittr_1.5
|  [9] scales_0.2.5     leaflet_1.0.0    rgdal_1.0-4      tools_3.2.1
| [13] htmlwidgets_0.5  munsell_0.4.2    yaml_2.1.13      base64enc_0.1-2
| [17] colorspace_1.2-6 htmltools_0.2.6
| > version
|                _
| platform       x86_64-apple-darwin14.4.0
| arch           x86_64
| os             darwin14.4.0
| system         x86_64, darwin14.4.0
| status
| major          3
| minor          2.1
| year           2015
| month          06
| day            18
| svn rev        68531
| language       R
| version.string R version 3.2.1 (2015-06-18)
| nickname       World-Famous Astronaut
| >
`----

Cheers,

Rainer



Rainer

>
>>
>> Am 24.07.2015, 12:03 Uhr, schrieb Rainer M Krug <[hidden email]>:
>>
>>> Tim Appelhans <[hidden email]> writes:
>>>
>>>> Dear list members,
>>>>
>>>> I would like to draw your attention to a little 'project' I've been
>>>> working on over the past few weeks.
>>>>
>>>> Using leaflet for R, I have defined some methods for spatial data (e.g.
>>>> Raster*, Spatial* objects) to quickly visualise them in either the
>>>> RStudio Viewer pan or the default web browser. The function I created
>>>> for this is called mapView().
>>>>
>>>> Think of it as an interactive version of spplot()/plot() for spatial
>>>> data (though less versatile). It enables zooming, paning and basic
>>>> layer
>>>> queries (i.e. printing of the attributes in the @data slot of Spatial*
>>>> objects + the x/y location of the feature). For Raster* objects queries
>>>> are currently not available as leaflet translates the data into RGB
>>>> values for display. Furthermore, background maps can be defined and
>>>> multiple different spatial object layers can be overlaid.
>>>> At the moment mapView() lives in our Rsenal package on github
>>>> (https://github.com/environmentalinformatics-marburg/Rsenal) but
>>>> this is
>>>> likely going to change at some point in the not too distant
>>>> future. This
>>>> also depends on whether there is active interest in developping this
>>>> sort of thing further to provide more than the current admittedly
>>>> rather
>>>> limited functionality. This, however, would involve JavaScript coding
>>>> which I do not have any experience with.
>>>>
>>>> A quick (non-interactive) intorduction can be found here:
>>>>
>>>> https://metvurst.wordpress.com/
>>>>
>>>> The full introductory article including interactive examples is
>>>> published here:
>>>>
>>>> http://environmentalinformatics-marburg.github.io/web-presentations/20150723_mapView.html 
>>>>
>>>>
>>>> I hope this may prove useful for some of you.
>>>
>>> This looks like something I was really missing! I was always exporting
>>> my spatial data into GRASS and viewing it there - but this looks really
>>> brilliant! This makes out of R a very powerful command line GIS.
>>>
>>> I would really like to see this functionality in a separate R package on
>>> CRAN - even with only its current functionality, it is very useful!
>>>
>>> Thanks a lot and keep us posted,
>>>
>>> Rainer
>>>
>>>> Also, if anyone is keen to get involved in taking this further, please
>>>> let me know and we will see how to best proceed.
>>>>
>>>> Best,
>>>> Tim
>>>
>>
>>
--
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany)

Centre of Excellence for Invasion Biology
Stellenbosch University
South Africa

Tel :       +33 - (0)9 53 10 27 44
Cell:       +33 - (0)6 85 62 59 98
Fax :       +33 - (0)9 58 10 27 44

Fax (D):    +49 - (0)3 21 21 25 22 44

email:      [hidden email]

Skype:      RMkrug

PGP: 0x0F52F982

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

signature.asc (490 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: mapView: basic interactive viewing of spatial data in R

edzer
In reply to this post by Tim Appelhans
Hi Tim, thanks for starting the discussion.

I started a similar discussion (off-list, with package maintainers) for
the case where google map or openstreetmap maps are used as background
in map plots created in R, support for which is now scattered over
ggmap::get_map, RgoogleMaps::GetMap, dismo::gmap and
https://github.com/hadley/rastermap. (on r-forge, sp::plot and
sp::spplot can now deal with these, see sp::demo(webmap)).

The (un)projection mapView does is towards epsg:4326 (longlat WGS84),
leaflet assumes this and takes care of the projection to web mercator;
the message printed in mapView (if verbose = TRUE) and your tutorial do
the correct thing but suggest they convert to mercator.

Some remaining questions:
- package leaflet also supports plotting Spatial* and Raster* objects,
what is exactly added by mapView?
- have you thought about integrating this functionality into the leaflet
R package?
- could we strive towards argument compatibility, so that we can get
things done by simply changing "plot" or "spplot" into "leaflet"?

On 07/24/2015 11:39 AM, Tim Appelhans wrote:

> Dear list members,
>
> I would like to draw your attention to a little 'project' I've been
> working on over the past few weeks.
>
> Using leaflet for R, I have defined some methods for spatial data (e.g.
> Raster*, Spatial* objects) to quickly visualise them in either the
> RStudio Viewer pan or the default web browser. The function I created
> for this is called mapView().
>
> Think of it as an interactive version of spplot()/plot() for spatial
> data (though less versatile). It enables zooming, paning and basic layer
> queries (i.e. printing of the attributes in the @data slot of Spatial*
> objects + the x/y location of the feature). For Raster* objects queries
> are currently not available as leaflet translates the data into RGB
> values for display. Furthermore, background maps can be defined and
> multiple different spatial object layers can be overlaid.
> At the moment mapView() lives in our Rsenal package on github
> (https://github.com/environmentalinformatics-marburg/Rsenal) but this is
> likely going to change at some point in the not too distant future. This
> also depends on whether there is active interest in developping this
> sort of thing further to provide more than the current admittedly rather
> limited functionality. This, however, would involve JavaScript coding
> which I do not have any experience with.
>
> A quick (non-interactive) intorduction can be found here:
>
> https://metvurst.wordpress.com/
>
> The full introductory article including interactive examples is
> published here:
>
> http://environmentalinformatics-marburg.github.io/web-presentations/20150723_mapView.html
>
> I hope this may prove useful for some of you.
> Also, if anyone is keen to get involved in taking this further, please
> let me know and we will see how to best proceed.
>
> Best,
> Tim
>
--
Edzer Pebesma
Institute for Geoinformatics (ifgi),  University of Münster,
Heisenbergstraße 2, 48149 Münster, Germany; +49 251 83 33081
Journal of Statistical Software:   http://www.jstatsoft.org/
Computers & Geosciences:   http://elsevier.com/locate/cageo/
Spatial Statistics Society http://www.spatialstatistics.info


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

signature.asc (501 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: mapView: basic interactive viewing of spatial data in R

Thomas Adams-2
In reply to this post by Tim Appelhans
Tim,

WOW! This is very cool...

Using the tips from others, I did the following (to summarize):

install.packages("leaflet",dependencies=T)
library("devtools")
install_github("environmentalinformatics-marburg/Rsenal")

Works great in the few minutes I've tried it.

Thanks!!

Tom

On Fri, Jul 24, 2015 at 4:39 AM, Tim Appelhans <[hidden email]>
wrote:

> Dear list members,
>
> I would like to draw your attention to a little 'project' I've been
> working on over the past few weeks.
>
> Using leaflet for R, I have defined some methods for spatial data (e.g.
> Raster*, Spatial* objects) to quickly visualise them in either the
> RStudio Viewer pan or the default web browser. The function I created
> for this is called mapView().
>
> Think of it as an interactive version of spplot()/plot() for spatial
> data (though less versatile). It enables zooming, paning and basic layer
> queries (i.e. printing of the attributes in the @data slot of Spatial*
> objects + the x/y location of the feature). For Raster* objects queries
> are currently not available as leaflet translates the data into RGB
> values for display. Furthermore, background maps can be defined and
> multiple different spatial object layers can be overlaid.
> At the moment mapView() lives in our Rsenal package on github
> (https://github.com/environmentalinformatics-marburg/Rsenal) but this is
> likely going to change at some point in the not too distant future. This
> also depends on whether there is active interest in developping this
> sort of thing further to provide more than the current admittedly rather
> limited functionality. This, however, would involve JavaScript coding
> which I do not have any experience with.
>
> A quick (non-interactive) intorduction can be found here:
>
> https://metvurst.wordpress.com/
>
> The full introductory article including interactive examples is
> published here:
>
>
> http://environmentalinformatics-marburg.github.io/web-presentations/20150723_mapView.html
>
> I hope this may prove useful for some of you.
> Also, if anyone is keen to get involved in taking this further, please
> let me know and we will see how to best proceed.
>
> Best,
> Tim
>
> --
> #####################################
> Tim Appelhans
> Department of Geography
> Environmental Informatics
> Philipps Universität Marburg
> Deutschhausstraße 12
> 35032 Marburg (Paketpost: 35037 Marburg)
> Germany
>
> Tel +49 (0) 6421 28-25957
>
> http://environmentalinformatics-marburg.de/
>
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>



--
Thomas E Adams, III
718 McBurney Drive
Lebanon, OH 45036

1 (513) 739-9512 (cell)

        [[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: mapView: basic interactive viewing of spatial data in R

Tim Appelhans
In reply to this post by edzer
Edzer,
see my answers below.

On 24.07.2015 14:26, Edzer Pebesma wrote:
> Hi Tim, thanks for starting the discussion.
>
> I started a similar discussion (off-list, with package maintainers) for
> the case where google map or openstreetmap maps are used as background
> in map plots created in R, support for which is now scattered over
> ggmap::get_map, RgoogleMaps::GetMap, dismo::gmap and
> https://github.com/hadley/rastermap. (on r-forge, sp::plot and
> sp::spplot can now deal with these, see sp::demo(webmap)).

The idea behind mapView was not to be able to underly google imagery or
other map layers as such. The motivation was to avoid the detour via the
hard drive in order to get interactive viewing capabilities (either via
saving and opening manually or automatically as in plotKml).
I have not tested rastermap or sp::webmap so far, so I don't know their
exact capabilities.

> The (un)projection mapView does is towards epsg:4326 (longlat WGS84),
> leaflet assumes this and takes care of the projection to web mercator;
> the message printed in mapView (if verbose = TRUE) and your tutorial do
> the correct thing but suggest they convert to mercator.

It is true that mapView (un)projects to epsg:4326 for Spatial* objects.
The rest is handled by the leaflet package.
For Raster* objects this is not so straight forward as the current
leaflet implementation expects two things. From the entry for projection
argument in the help of addRasterImage:

"if TRUE, automatically project x to the map projection expected by
Leaflet (EPSG:3857); if FALSE, it's the caller's responsibility to
ensure that x is already projected, and that extent(x) is expressed in
WGS84 latitude/longitude coordinates"

which means that the layer needs to be in wgs84 web mercator, whereas
the extent needs to be in epsg:4326 (longlat WGS84). Therefore this is
all handled by leaflet at the moment. Giving the user a bit more control
over this would be desirable in the future.

I included the "projecting to web mercator" message to make people aware
of the fact that reprojection is done under hood by leaflet. In my
opinion, this is one of the things that many people do not realise (e.g.
many of our students) when loading data into classic GIS systems like
ArcGIS or QGIS who also do on-the-fly reprojection but without telling
the user. In the case of mapView where we usually simply want to inspect
the data this is rather unimportant (that's why verbose is set to FALSE
by default) but once you want to do calculations this becomes an issue.
Given that calculations in R will be done using the designated packages
(e.g. sp or raster) this is taken care of anyway.

>
> Some remaining questions:
> - package leaflet also supports plotting Spatial* and Raster* objects,
> what is exactly added by mapView?

leaflet is great for individual maps. MapView simply provides some
resonable default behaviour for the most commonly used objects from the
R spatial universe, e.g. automatic parsing of layer names, pop-up text,
backgraound maps. Also it enables automatic addition to existing maps
without the need to manually look up existing layer (group) names.

> - have you thought about integrating this functionality into the leaflet
> R package?

I have contacted Joe Cheng a couple of weeks ago about this, but have
not heard back from him so far.

> - could we strive towards argument compatibility, so that we can get
> things done by simply changing "plot" or "spplot" into "leaflet"?

Compatibility would be very desirable! Up to now, my efforts into
mapView were more of a proof-of-concept than a structured
implementation. This is exactly why I wanted to make the spatial
community aware of it, so we can together decide where to take this
approach (ideally including the leaflet maintainers from RStudio). Ther
are some additional things to consider here, for example the use of
magrittr pipes implemented in leaflet...


At the end of the day, I think we all agree that interactive GIS-like
functionality in native R would be a great thing to have. I do recall a
suggestion by Barry Rowlingson (if I remember correctly) who stated that
one day a call to library("gis") would be nice. Maybe mapView is merely
another puzzle piece along these lines.

Tim

>
> On 07/24/2015 11:39 AM, Tim Appelhans wrote:
>> Dear list members,
>>
>> I would like to draw your attention to a little 'project' I've been
>> working on over the past few weeks.
>>
>> Using leaflet for R, I have defined some methods for spatial data (e.g.
>> Raster*, Spatial* objects) to quickly visualise them in either the
>> RStudio Viewer pan or the default web browser. The function I created
>> for this is called mapView().
>>
>> Think of it as an interactive version of spplot()/plot() for spatial
>> data (though less versatile). It enables zooming, paning and basic layer
>> queries (i.e. printing of the attributes in the @data slot of Spatial*
>> objects + the x/y location of the feature). For Raster* objects queries
>> are currently not available as leaflet translates the data into RGB
>> values for display. Furthermore, background maps can be defined and
>> multiple different spatial object layers can be overlaid.
>> At the moment mapView() lives in our Rsenal package on github
>> (https://github.com/environmentalinformatics-marburg/Rsenal) but this is
>> likely going to change at some point in the not too distant future. This
>> also depends on whether there is active interest in developping this
>> sort of thing further to provide more than the current admittedly rather
>> limited functionality. This, however, would involve JavaScript coding
>> which I do not have any experience with.
>>
>> A quick (non-interactive) intorduction can be found here:
>>
>> https://metvurst.wordpress.com/
>>
>> The full introductory article including interactive examples is
>> published here:
>>
>> http://environmentalinformatics-marburg.github.io/web-presentations/20150723_mapView.html
>>
>> I hope this may prove useful for some of you.
>> Also, if anyone is keen to get involved in taking this further, please
>> let me know and we will see how to best proceed.
>>
>> Best,
>> Tim
>>
>
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
--
#####################################
Tim Appelhans
Department of Geography
Environmental Informatics
Philipps Universit�t Marburg
Deutschhausstra�e 12
35032 Marburg (Paketpost: 35037 Marburg)
Germany

Tel +49 (0) 6421 28-25957

http://environmentalinformatics-marburg.de/


        [[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: mapView: basic interactive viewing of spatial data in R

PingYang
In reply to this post by Tim Appelhans
Hi Tim,

I installed the packages with the hints (with devtools and leaflet library)
successfully, however, when I tried to run the code from
http://environmentalinformatics-marburg.github.io/web-presentations/20150723_mapView.html
I got issues:
First, the error came for
 meuse_rst <- stack(meuse.grid)
Error in nlayers(b) :
  error in evaluating the argument 'x' in selecting a method for function
'nlayers': Error in .newCRS(value) :
  4 arguments passed to .Internal(nchar) which requires 3

And I tried the the code with spatialPolygons:
data("DEU_adm2")
m <- mapView(gadm, burst = FALSE)
m

However, the map did not show up instead created a pdf file (with a link
inside), I need to copy this link into browser for viewing the map.

Any ideas?

Thanks,

Peter

On Fri, Jul 24, 2015 at 4:39 AM, Tim Appelhans <[hidden email]>
wrote:

> Dear list members,
>
> I would like to draw your attention to a little 'project' I've been
> working on over the past few weeks.
>
> Using leaflet for R, I have defined some methods for spatial data (e.g.
> Raster*, Spatial* objects) to quickly visualise them in either the
> RStudio Viewer pan or the default web browser. The function I created
> for this is called mapView().
>
> Think of it as an interactive version of spplot()/plot() for spatial
> data (though less versatile). It enables zooming, paning and basic layer
> queries (i.e. printing of the attributes in the @data slot of Spatial*
> objects + the x/y location of the feature). For Raster* objects queries
> are currently not available as leaflet translates the data into RGB
> values for display. Furthermore, background maps can be defined and
> multiple different spatial object layers can be overlaid.
> At the moment mapView() lives in our Rsenal package on github
> (https://github.com/environmentalinformatics-marburg/Rsenal) but this is
> likely going to change at some point in the not too distant future. This
> also depends on whether there is active interest in developping this
> sort of thing further to provide more than the current admittedly rather
> limited functionality. This, however, would involve JavaScript coding
> which I do not have any experience with.
>
> A quick (non-interactive) intorduction can be found here:
>
> https://metvurst.wordpress.com/
>
> The full introductory article including interactive examples is
> published here:
>
>
> http://environmentalinformatics-marburg.github.io/web-presentations/20150723_mapView.html
>
> I hope this may prove useful for some of you.
> Also, if anyone is keen to get involved in taking this further, please
> let me know and we will see how to best proceed.
>
> Best,
> Tim
>
> --
> #####################################
> Tim Appelhans
> Department of Geography
> Environmental Informatics
> Philipps Universität Marburg
> Deutschhausstraße 12
> 35032 Marburg (Paketpost: 35037 Marburg)
> Germany
>
> Tel +49 (0) 6421 28-25957
>
> http://environmentalinformatics-marburg.de/
>
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> 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: mapView: basic interactive viewing of spatial data in R

Tim Appelhans
Peter,
can you please provide the output from sessionInfo() so we know which
packages are available and what platform you are using?

Cheers
Tim

On 24.07.2015 15:54, ping yang wrote:

> Hi Tim,
>
> I installed the packages with the hints (with devtools and leaflet
> library) successfully, however, when I tried to run the code from
> http://environmentalinformatics-marburg.github.io/web-presentations/20150723_mapView.html 
> I got issues:
> First, the error came for
>  meuse_rst <- stack(meuse.grid)
> Error in nlayers(b) :
>   error in evaluating the argument 'x' in selecting a method for
> function 'nlayers': Error in .newCRS(value) :
>   4 arguments passed to .Internal(nchar) which requires 3
>
> And I tried the the code with spatialPolygons:|
> data("DEU_adm2")
> m <- mapView(gadm, burst = FALSE)
> m
> |
> However, the map did not show up instead created a pdf file (with a
> link inside), I need to copy this link into browser for viewing the map.
>
> Any ideas?
>
> Thanks,
>
> Peter
>
> On Fri, Jul 24, 2015 at 4:39 AM, Tim Appelhans
> <[hidden email] <mailto:[hidden email]>> wrote:
>
>     Dear list members,
>
>     I would like to draw your attention to a little 'project' I've been
>     working on over the past few weeks.
>
>     Using leaflet for R, I have defined some methods for spatial data
>     (e.g.
>     Raster*, Spatial* objects) to quickly visualise them in either the
>     RStudio Viewer pan or the default web browser. The function I created
>     for this is called mapView().
>
>     Think of it as an interactive version of spplot()/plot() for spatial
>     data (though less versatile). It enables zooming, paning and basic
>     layer
>     queries (i.e. printing of the attributes in the @data slot of Spatial*
>     objects + the x/y location of the feature). For Raster* objects
>     queries
>     are currently not available as leaflet translates the data into RGB
>     values for display. Furthermore, background maps can be defined and
>     multiple different spatial object layers can be overlaid.
>     At the moment mapView() lives in our Rsenal package on github
>     (https://github.com/environmentalinformatics-marburg/Rsenal) but
>     this is
>     likely going to change at some point in the not too distant
>     future. This
>     also depends on whether there is active interest in developping this
>     sort of thing further to provide more than the current admittedly
>     rather
>     limited functionality. This, however, would involve JavaScript coding
>     which I do not have any experience with.
>
>     A quick (non-interactive) intorduction can be found here:
>
>     https://metvurst.wordpress.com/
>
>     The full introductory article including interactive examples is
>     published here:
>
>     http://environmentalinformatics-marburg.github.io/web-presentations/20150723_mapView.html
>
>     I hope this may prove useful for some of you.
>     Also, if anyone is keen to get involved in taking this further, please
>     let me know and we will see how to best proceed.
>
>     Best,
>     Tim
>
>     --
>     #####################################
>     Tim Appelhans
>     Department of Geography
>     Environmental Informatics
>     Philipps Universität Marburg
>     Deutschhausstraße 12
>     35032 Marburg (Paketpost: 35037 Marburg)
>     Germany
>
>     Tel +49 (0) 6421 28-25957 <tel:%2B49%20%280%29%206421%2028-25957>
>
>     http://environmentalinformatics-marburg.de/
>
>
>             [[alternative HTML version deleted]]
>
>     _______________________________________________
>     R-sig-Geo mailing list
>     [hidden email] <mailto:[hidden email]>
>     https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
>

--
#####################################
Tim Appelhans
Department of Geography
Environmental Informatics
Philipps Universität Marburg
Deutschhausstraße 12
35032 Marburg (Paketpost: 35037 Marburg)
Germany

Tel +49 (0) 6421 28-25957

http://environmentalinformatics-marburg.de/


        [[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: mapView: basic interactive viewing of spatial data in R

geobernadotte
In reply to this post by Tim Appelhans
Hi Tim,
you mentioned that it is also possible to view the map in the default web  
browser.
So far I could not find out by myself how to accomplish this from RStudio.

Thank you
Bernd



Am 24.07.2015, 11:39 Uhr, schrieb Tim Appelhans <[hidden email]>:

> Dear list members,
>
> I would like to draw your attention to a little 'project' I've been
> working on over the past few weeks.
>
> Using leaflet for R, I have defined some methods for spatial data (e.g.
> Raster*, Spatial* objects) to quickly visualise them in either the
> RStudio Viewer pan or the default web browser. The function I created
> for this is called mapView().
>
> Think of it as an interactive version of spplot()/plot() for spatial
> data (though less versatile). It enables zooming, paning and basic layer
> queries (i.e. printing of the attributes in the @data slot of Spatial*
> objects + the x/y location of the feature). For Raster* objects queries
> are currently not available as leaflet translates the data into RGB
> values for display. Furthermore, background maps can be defined and
> multiple different spatial object layers can be overlaid.
> At the moment mapView() lives in our Rsenal package on github
> (https://github.com/environmentalinformatics-marburg/Rsenal) but this is
> likely going to change at some point in the not too distant future. This
> also depends on whether there is active interest in developping this
> sort of thing further to provide more than the current admittedly rather
> limited functionality. This, however, would involve JavaScript coding
> which I do not have any experience with.
>
> A quick (non-interactive) intorduction can be found here:
>
> https://metvurst.wordpress.com/
>
> The full introductory article including interactive examples is
> published here:
>
> http://environmentalinformatics-marburg.github.io/web-presentations/20150723_mapView.html
>
> I hope this may prove useful for some of you.
> Also, if anyone is keen to get involved in taking this further, please
> let me know and we will see how to best proceed.
>
> Best,
> Tim
>


--
Bernd Vogelgesang
Siedlerstraße 2
91083 Baiersdorf/Igelsdorf
Tel: 09133-825374

_______________________________________________
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: mapView: basic interactive viewing of spatial data in R

MAURICIO ZAMBRANO BIGIARINI
In reply to this post by edzer
On 24 July 2015 at 09:26, Edzer Pebesma <[hidden email]> wrote:
> Hi Tim, thanks for starting the discussion.

Thanks Tim for this nice implementation and to all of you for this
very interesting discussion.

>
> I started a similar discussion (off-list, with package maintainers) for
> the case where google map or openstreetmap maps are used as background
> in map plots created in R, support for which is now scattered over
> ggmap::get_map, RgoogleMaps::GetMap, dismo::gmap and
> https://github.com/hadley/rastermap. (on r-forge, sp::plot and
> sp::spplot can now deal with these, see sp::demo(webmap)).

by the way Edzer, the sp::demo(webmap) din't work for me with  sp_1.1-1:

library(sp)
demo(meuse)    # working
demo(webmap) # not working

could you tell me what I'm doing wrong ?


Thanks in advance,

Mauricio Zambrano-Bigiarini, PhD

=====================================
Dept. of Civil Engineering
Faculty of Engineering and Sciences
Universidad de La Frontera
PO Box 54-D, Temuco, Chile
=====================================
mailto     : [hidden email]
work-phone : +56 45 259 2812
http://ingenieriacivil.ufro.cl/
=====================================
"When the pupil is ready, the master arrives."
(Zen proverb)
=====================================
Linux user #454569 -- Linux Mint use

_______________________________________________
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: mapView: basic interactive viewing of spatial data in R

edzer


On 07/24/2015 04:52 PM, MAURICIO ZAMBRANO BIGIARINI wrote:

> On 24 July 2015 at 09:26, Edzer Pebesma <[hidden email]> wrote:
>> Hi Tim, thanks for starting the discussion.
>
> Thanks Tim for this nice implementation and to all of you for this
> very interesting discussion.
>
>>
>> I started a similar discussion (off-list, with package maintainers) for
>> the case where google map or openstreetmap maps are used as background
>> in map plots created in R, support for which is now scattered over
>> ggmap::get_map, RgoogleMaps::GetMap, dismo::gmap and
>> https://github.com/hadley/rastermap. (on r-forge, sp::plot and
>> sp::spplot can now deal with these, see sp::demo(webmap)).
>
> by the way Edzer, the sp::demo(webmap) din't work for me with  sp_1.1-1:
>
> library(sp)
> demo(meuse)    # working
> demo(webmap) # not working
>
> could you tell me what I'm doing wrong ?
>
I mentioned "on r-forge, ..."

Install sp 1.1-2 (devel) from r-forge; see
https://r-forge.r-project.org/R/?group_id=1014

--
Edzer Pebesma
Institute for Geoinformatics (ifgi),  University of Münster,
Heisenbergstraße 2, 48149 Münster, Germany; +49 251 83 33081
Journal of Statistical Software:   http://www.jstatsoft.org/
Computers & Geosciences:   http://elsevier.com/locate/cageo/
Spatial Statistics Society http://www.spatialstatistics.info


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

signature.asc (501 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: mapView: basic interactive viewing of spatial data in R

Roger Bivand
Administrator
In reply to this post by Tim Appelhans
Please also see my comments on a parallel issue in the leaflet github:

https://github.com/rstudio/leaflet/issues/139#issuecomment-124035792

Briefly, no automatic system can help if the input geometries (raster or vector) have an incomplete CRS, which is very often the case. Users need not only a warning, but first to be told that their input CRS is probably incomplete, where to look for help, and then more help if the input CRS was complete but was wrong (or the Eastings and Northings were reversed in the input data. There is no easy way to do this, and indeed fundamental parts of our infrastructure for handling CRS, like the PROJ.4 library (bug corrections), datum grid versions, and the copy of the EPSG CRS definitions used do all change over time. Arguably, automatic projection or reprojection should be treated with sufficient caution unless all data acquisition is strictly managed (as it would/should be in a large professional organization employing its own surveyors or contracting photogrametric and surveying services). If position matters, it is worth taking the time to find an appropriate CRS, or we all end up at sea without an anchor.

Roger

--
Roger Bivand
Norwegian School of Economics
Helleveien 30, 5045 Bergen, Norway
[hidden email]


________________________________________
Fra: R-sig-Geo [[hidden email]] p&#229; vegne av Tim Appelhans [[hidden email]]
Sendt: 24. juli 2015 3:14
Til: [hidden email]
Emne: Re: [R-sig-Geo] mapView: basic interactive viewing of spatial data in R

Edzer,
see my answers below.

On 24.07.2015 14:26, Edzer Pebesma wrote:
> Hi Tim, thanks for starting the discussion.
>
> I started a similar discussion (off-list, with package maintainers) for
> the case where google map or openstreetmap maps are used as background
> in map plots created in R, support for which is now scattered over
> ggmap::get_map, RgoogleMaps::GetMap, dismo::gmap and
> https://github.com/hadley/rastermap. (on r-forge, sp::plot and
> sp::spplot can now deal with these, see sp::demo(webmap)).

The idea behind mapView was not to be able to underly google imagery or
other map layers as such. The motivation was to avoid the detour via the
hard drive in order to get interactive viewing capabilities (either via
saving and opening manually or automatically as in plotKml).
I have not tested rastermap or sp::webmap so far, so I don't know their
exact capabilities.

> The (un)projection mapView does is towards epsg:4326 (longlat WGS84),
> leaflet assumes this and takes care of the projection to web mercator;
> the message printed in mapView (if verbose = TRUE) and your tutorial do
> the correct thing but suggest they convert to mercator.

It is true that mapView (un)projects to epsg:4326 for Spatial* objects.
The rest is handled by the leaflet package.
For Raster* objects this is not so straight forward as the current
leaflet implementation expects two things. From the entry for projection
argument in the help of addRasterImage:

"if TRUE, automatically project x to the map projection expected by
Leaflet (EPSG:3857); if FALSE, it's the caller's responsibility to
ensure that x is already projected, and that extent(x) is expressed in
WGS84 latitude/longitude coordinates"

which means that the layer needs to be in wgs84 web mercator, whereas
the extent needs to be in epsg:4326 (longlat WGS84). Therefore this is
all handled by leaflet at the moment. Giving the user a bit more control
over this would be desirable in the future.

I included the "projecting to web mercator" message to make people aware
of the fact that reprojection is done under hood by leaflet. In my
opinion, this is one of the things that many people do not realise (e.g.
many of our students) when loading data into classic GIS systems like
ArcGIS or QGIS who also do on-the-fly reprojection but without telling
the user. In the case of mapView where we usually simply want to inspect
the data this is rather unimportant (that's why verbose is set to FALSE
by default) but once you want to do calculations this becomes an issue.
Given that calculations in R will be done using the designated packages
(e.g. sp or raster) this is taken care of anyway.

>
> Some remaining questions:
> - package leaflet also supports plotting Spatial* and Raster* objects,
> what is exactly added by mapView?

leaflet is great for individual maps. MapView simply provides some
resonable default behaviour for the most commonly used objects from the
R spatial universe, e.g. automatic parsing of layer names, pop-up text,
backgraound maps. Also it enables automatic addition to existing maps
without the need to manually look up existing layer (group) names.

> - have you thought about integrating this functionality into the leaflet
> R package?

I have contacted Joe Cheng a couple of weeks ago about this, but have
not heard back from him so far.

> - could we strive towards argument compatibility, so that we can get
> things done by simply changing "plot" or "spplot" into "leaflet"?

Compatibility would be very desirable! Up to now, my efforts into
mapView were more of a proof-of-concept than a structured
implementation. This is exactly why I wanted to make the spatial
community aware of it, so we can together decide where to take this
approach (ideally including the leaflet maintainers from RStudio). Ther
are some additional things to consider here, for example the use of
magrittr pipes implemented in leaflet...


At the end of the day, I think we all agree that interactive GIS-like
functionality in native R would be a great thing to have. I do recall a
suggestion by Barry Rowlingson (if I remember correctly) who stated that
one day a call to library("gis") would be nice. Maybe mapView is merely
another puzzle piece along these lines.

Tim

>
> On 07/24/2015 11:39 AM, Tim Appelhans wrote:
>> Dear list members,
>>
>> I would like to draw your attention to a little 'project' I've been
>> working on over the past few weeks.
>>
>> Using leaflet for R, I have defined some methods for spatial data (e.g.
>> Raster*, Spatial* objects) to quickly visualise them in either the
>> RStudio Viewer pan or the default web browser. The function I created
>> for this is called mapView().
>>
>> Think of it as an interactive version of spplot()/plot() for spatial
>> data (though less versatile). It enables zooming, paning and basic layer
>> queries (i.e. printing of the attributes in the @data slot of Spatial*
>> objects + the x/y location of the feature). For Raster* objects queries
>> are currently not available as leaflet translates the data into RGB
>> values for display. Furthermore, background maps can be defined and
>> multiple different spatial object layers can be overlaid.
>> At the moment mapView() lives in our Rsenal package on github
>> (https://github.com/environmentalinformatics-marburg/Rsenal) but this is
>> likely going to change at some point in the not too distant future. This
>> also depends on whether there is active interest in developping this
>> sort of thing further to provide more than the current admittedly rather
>> limited functionality. This, however, would involve JavaScript coding
>> which I do not have any experience with.
>>
>> A quick (non-interactive) intorduction can be found here:
>>
>> https://metvurst.wordpress.com/
>>
>> The full introductory article including interactive examples is
>> published here:
>>
>> http://environmentalinformatics-marburg.github.io/web-presentations/20150723_mapView.html
>>
>> I hope this may prove useful for some of you.
>> Also, if anyone is keen to get involved in taking this further, please
>> let me know and we will see how to best proceed.
>>
>> Best,
>> Tim
>>
>
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

--
#####################################
Tim Appelhans
Department of Geography
Environmental Informatics
Philipps Universit�t Marburg
Deutschhausstra�e 12
35032 Marburg (Paketpost: 35037 Marburg)
Germany

Tel +49 (0) 6421 28-25957

http://environmentalinformatics-marburg.de/


        [[alternative HTML version deleted]]

_______________________________________________
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: mapView: basic interactive viewing of spatial data in R

Tim Appelhans
In reply to this post by geobernadotte
Bernd,
in RStudio there is a little button on top of the viewer that will open
the current content in the default browser. I do not know how to tell
RStudio to use the browser by default.

HTH
Tim

On 24.07.2015 16:37, Bernd Vogelgesang wrote:

> Hi Tim,
> you mentioned that it is also possible to view the map in the default
> web browser.
> So far I could not find out by myself how to accomplish this from
> RStudio.
>
> Thank you
> Bernd
>
>
>
> Am 24.07.2015, 11:39 Uhr, schrieb Tim Appelhans
> <[hidden email]>:
>
>> Dear list members,
>>
>> I would like to draw your attention to a little 'project' I've been
>> working on over the past few weeks.
>>
>> Using leaflet for R, I have defined some methods for spatial data (e.g.
>> Raster*, Spatial* objects) to quickly visualise them in either the
>> RStudio Viewer pan or the default web browser. The function I created
>> for this is called mapView().
>>
>> Think of it as an interactive version of spplot()/plot() for spatial
>> data (though less versatile). It enables zooming, paning and basic layer
>> queries (i.e. printing of the attributes in the @data slot of Spatial*
>> objects + the x/y location of the feature). For Raster* objects queries
>> are currently not available as leaflet translates the data into RGB
>> values for display. Furthermore, background maps can be defined and
>> multiple different spatial object layers can be overlaid.
>> At the moment mapView() lives in our Rsenal package on github
>> (https://github.com/environmentalinformatics-marburg/Rsenal) but this is
>> likely going to change at some point in the not too distant future. This
>> also depends on whether there is active interest in developping this
>> sort of thing further to provide more than the current admittedly rather
>> limited functionality. This, however, would involve JavaScript coding
>> which I do not have any experience with.
>>
>> A quick (non-interactive) intorduction can be found here:
>>
>> https://metvurst.wordpress.com/
>>
>> The full introductory article including interactive examples is
>> published here:
>>
>> http://environmentalinformatics-marburg.github.io/web-presentations/20150723_mapView.html 
>>
>>
>> I hope this may prove useful for some of you.
>> Also, if anyone is keen to get involved in taking this further, please
>> let me know and we will see how to best proceed.
>>
>> Best,
>> Tim
>>
>
>

--
#####################################
Tim Appelhans
Department of Geography
Environmental Informatics
Philipps Universität Marburg
Deutschhausstraße 12
35032 Marburg (Paketpost: 35037 Marburg)
Germany

Tel +49 (0) 6421 28-25957

http://environmentalinformatics-marburg.de/

_______________________________________________
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: mapView: basic interactive viewing of spatial data in R

Tim Appelhans
In reply to this post by Rainer M Krug
Dear list,
after some really good discussions and good feedback at Geostat 2015
summer school in Lancaster (Many thanks to Tom, Barry, Edzer, Roger and
all the others for inviting me), I have now ported the mapView code into
its own package called mapview (mind the small 'v'!)

The package can be found at

https://github.com/environmentalinformatics-marburg/mapview

and can be installed using library(devtools)

devtools::install_github("environmentalinformatics-marburg/mapview")


Any suggestions, bug reports or feature requests should be filed here

https://github.com/environmentalinformatics-marburg/mapview/issues


Cheers
Tim



On 24.07.2015 12:03, Rainer M Krug wrote:

> Tim Appelhans <[hidden email]> writes:
>
>> Dear list members,
>>
>> I would like to draw your attention to a little 'project' I've been
>> working on over the past few weeks.
>>
>> Using leaflet for R, I have defined some methods for spatial data (e.g.
>> Raster*, Spatial* objects) to quickly visualise them in either the
>> RStudio Viewer pan or the default web browser. The function I created
>> for this is called mapView().
>>
>> Think of it as an interactive version of spplot()/plot() for spatial
>> data (though less versatile). It enables zooming, paning and basic layer
>> queries (i.e. printing of the attributes in the @data slot of Spatial*
>> objects + the x/y location of the feature). For Raster* objects queries
>> are currently not available as leaflet translates the data into RGB
>> values for display. Furthermore, background maps can be defined and
>> multiple different spatial object layers can be overlaid.
>> At the moment mapView() lives in our Rsenal package on github
>> (https://github.com/environmentalinformatics-marburg/Rsenal) but this is
>> likely going to change at some point in the not too distant future. This
>> also depends on whether there is active interest in developping this
>> sort of thing further to provide more than the current admittedly rather
>> limited functionality. This, however, would involve JavaScript coding
>> which I do not have any experience with.
>>
>> A quick (non-interactive) intorduction can be found here:
>>
>> https://metvurst.wordpress.com/
>>
>> The full introductory article including interactive examples is
>> published here:
>>
>> http://environmentalinformatics-marburg.github.io/web-presentations/20150723_mapView.html
>>
>> I hope this may prove useful for some of you.
> This looks like something I was really missing! I was always exporting
> my spatial data into GRASS and viewing it there - but this looks really
> brilliant! This makes out of R a very powerful command line GIS.
>
> I would really like to see this functionality in a separate R package on
> CRAN - even with only its current functionality, it is very useful!
>
> Thanks a lot and keep us posted,
>
> Rainer
>
>> Also, if anyone is keen to get involved in taking this further, please
>> let me know and we will see how to best proceed.
>>
>> Best,
>> Tim

--
#####################################
Tim Appelhans
Department of Geography
Environmental Informatics
Philipps Universität Marburg
Deutschhausstraße 12
35032 Marburg (Paketpost: 35037 Marburg)
Germany

Tel +49 (0) 6421 28-25957

http://environmentalinformatics-marburg.de/

_______________________________________________
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: mapView: basic interactive viewing of spatial data in R

Rainer M Krug
Tim Appelhans <[hidden email]> writes:

> Dear list,
> after some really good discussions and good feedback at Geostat 2015
> summer school in Lancaster (Many thanks to Tom, Barry, Edzer, Roger
> and all the others for inviting me), I have now ported the mapView
> code into its own package called mapview (mind the small 'v'!)
>
> The package can be found at
>
> https://github.com/environmentalinformatics-marburg/mapview
>
> and can be installed using library(devtools)
>
> devtools::install_github("environmentalinformatics-marburg/mapview")
>
>
> Any suggestions, bug reports or feature requests should be filed here
>
> https://github.com/environmentalinformatics-marburg/mapview/issues
>
Thanks a lot.

I am looking forward of using this package a little bit more (at the
moment nothing spatial happening here)

Cheers,

Rainer

>
> Cheers
> Tim
>
>
>
> On 24.07.2015 12:03, Rainer M Krug wrote:
>> Tim Appelhans <[hidden email]> writes:
>>
>>> Dear list members,
>>>
>>> I would like to draw your attention to a little 'project' I've been
>>> working on over the past few weeks.
>>>
>>> Using leaflet for R, I have defined some methods for spatial data (e.g.
>>> Raster*, Spatial* objects) to quickly visualise them in either the
>>> RStudio Viewer pan or the default web browser. The function I created
>>> for this is called mapView().
>>>
>>> Think of it as an interactive version of spplot()/plot() for spatial
>>> data (though less versatile). It enables zooming, paning and basic layer
>>> queries (i.e. printing of the attributes in the @data slot of Spatial*
>>> objects + the x/y location of the feature). For Raster* objects queries
>>> are currently not available as leaflet translates the data into RGB
>>> values for display. Furthermore, background maps can be defined and
>>> multiple different spatial object layers can be overlaid.
>>> At the moment mapView() lives in our Rsenal package on github
>>> (https://github.com/environmentalinformatics-marburg/Rsenal) but this is
>>> likely going to change at some point in the not too distant future. This
>>> also depends on whether there is active interest in developping this
>>> sort of thing further to provide more than the current admittedly rather
>>> limited functionality. This, however, would involve JavaScript coding
>>> which I do not have any experience with.
>>>
>>> A quick (non-interactive) intorduction can be found here:
>>>
>>> https://metvurst.wordpress.com/
>>>
>>> The full introductory article including interactive examples is
>>> published here:
>>>
>>> http://environmentalinformatics-marburg.github.io/web-presentations/20150723_mapView.html
>>>
>>> I hope this may prove useful for some of you.
>> This looks like something I was really missing! I was always exporting
>> my spatial data into GRASS and viewing it there - but this looks really
>> brilliant! This makes out of R a very powerful command line GIS.
>>
>> I would really like to see this functionality in a separate R package on
>> CRAN - even with only its current functionality, it is very useful!
>>
>> Thanks a lot and keep us posted,
>>
>> Rainer
>>
>>> Also, if anyone is keen to get involved in taking this further, please
>>> let me know and we will see how to best proceed.
>>>
>>> Best,
>>> Tim
--
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany)

Centre of Excellence for Invasion Biology
Stellenbosch University
South Africa

Tel :       +33 - (0)9 53 10 27 44
Cell:       +33 - (0)6 85 62 59 98
Fax :       +33 - (0)9 58 10 27 44

Fax (D):    +49 - (0)3 21 21 25 22 44

email:      [hidden email]

Skype:      RMkrug

PGP: 0x0F52F982

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

signature.asc (490 bytes) Download Attachment