Subscribe to R-sig-geo feed
This is an archive for R-sig-geo, not a forum. It is not possible to post through Nabble - you may not start a new thread nor follow up an existing thread. If you wish to post, but are not subscribed to the list through the list homepage, subscribe first (through the list homepage, not via Nabble) and post from your subscribed email address. Until 2015-06-20, subscribers could post through Nabble, but policy has been changed as too many non-subscribers misunderstood the interface.
Updated: 1 hour 57 min ago

Feedback request and heads-up: open source book

Wed, 09/05/2018 - 04:50
Hi all,

*Summary*

As mentioned on this list already there is a new book project on R-spatial
called Geocomputation with R. It's an open source and publicly accessible
project which can be found in its entirety here:
https://geocompr.robinlovelace.net/

The purpose of this email is to inform you that the book is now mostly
complete and ready for use. It's also to request feedback before it gets
sent to the printers in early October. There's a ~month long window of
opportunity to contribute, alongside others who have kindly helped already,
to the printed version:
https://github.com/robinlovelace/geocompr#contributing

...

*Details*

A major aim of the project is to provide high quality, up-to-date teaching
material free of charge to people around the world. We have been working on
it for over a year. But only in the last month have we got a cohesive draft
of all 15 chapters, so now is a good time to take a look and start using it
for your own teaching/learning: few things will change in the content.
However, we have a deadline at the end of September to submit the final
draft for the physical book.

Each of us is an experienced R user for geographic applications. We have
some development experience. And each chapter (except for 10, 14 and 15)
have undergone a formal process of 'technical review'. But there will still
inevitably be mistakes, parts that are not clear, and a huge amount of room
for improvement.

We are therefore sending this message to ask for feedback. People in the
wider R-spatial community, and especially readers of the r-sig-geo list
messages, have a huge amount of expertise. We would therefore be grateful
for suggestions from you. Especially useful would feedback on:

   - Any key functions or topics we're missing (note the commonly requested
   topic of spatial interpolation is well-covered in other resources, and gets
   a mention in an extended example at ).
   - Any bits of the explanation that are not crystal clear? Please let us
   know. We try to use plain English but there is definitely room for
   improvement in the prose in many sections.
   - Any exercises that don't make sense, are too easy/hard or are
   unhelpful?

We've had loads of support so far from many people in the form of comments,
reviews and suggestions. And the fact that R-spatial exists at all is
thanks to developers like Edzer and Roger who's code underlies much of what
we have written. So the final thing to say is thanks for being part of the
community that has made this possible. We hope the book contributes to the
community.

For info on how to contribute and the book directly via a Pull Request, see
here: https://geocompr.robinlovelace.net/index.html#how-to-contribute but
emails to me on this address are equally appreciated if you spot anything.

Robin, Jakub and Jannes.

        [[alternative HTML version deleted]]

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

Re: Leaflet map nested in RShiny App - Improving speed & portability

Wed, 09/05/2018 - 02:48
On Wed, Sep 5, 2018 at 12:56 AM, Erin Stearns <[hidden email]> wrote:

> Hello all!
>
> I hope this message finds you all well!
>
> I have 2 questions pertaining to the creation of interactive maps via
> Leaflet nested inside an RShiny app. One question has to do with
> computation while the other has to do with sharing/off-line interactivity.
>
> *Computation question*
> As you see, the RShiny app takes quite a bit of time to render. Does anyone
> have any suggestions for improving this? As previously said, this version
> only contains 5 countries, thus I cannot continue with my current method to
> reach a global map. I have considered finding centroids of all Admin 2
> polygons and retaining attribute information here, then rasterizing the
> malaria risk shapefile for visualization and using the 2 instead of a
> single shapefile with polygon boundaries and attributes.
>
> Unless you plan to add any computational functions to this map then I'd
strongly recommend creating it as a standalone web app and not a shiny app.
This will enable you to use lots of useful Leaflet plugins for speeding
things up, such as only showing country outlines at low zoom levels, and
showing subdivisions only at high zoom levels. This *might* be possible
with R's various leaflet packages but I'd go for full javascript control.

A standalone map would take its data from a JSON file or similar, and you
would then be writing R code that generated that. The mapping app itself is
written in HTML and JS with CSS styling. There are plenty of guides to
web-based interactive mapping, starting with Leaflet.


> *Sharing the app/offline interactivity*
> I am planning to share this with people who likely do not have R installed
> on their laptops nor have they ever coded. Does anyone have any suggestions
> for the best way to do this while retaining interactivity?
>
>  Here's the big win of creating a standalone web map. You only have to
distribute the HTML/CSS/JS and they can be viewed directly (or you also
supply a tiny server that runs locally and only has to feed the files on a
localhost port). No need to have a shiny server anywhere, or install R. Its
simple and clean. It also needs no network connectivity, but you'll not get
a base map - but you could include a low or medium resolution basemap
raster in your package.

The only reason to need Shiny here would be if you wanted people to do
something computational, like click on a bunch of polygons and then fit a
linear model to the selection, since that would require a round-trip to the
server for R to compute the fit. (although I suspect there's a JS package
for linear modelling.... you can do ML in JS these days...)



> Thank you all, any insight is greatly appreciated.
>
> Best,
> Erin
>
>         [[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

Re: Leaflet map nested in RShiny App - Improving speed & portability

Wed, 09/05/2018 - 01:28
Regarding sharing, you will need to deploy this to a shiny server.
shinyapps.io offer a paid option which has more functionality and may work
for you if you don't have infrastructure capabilities. If you do, and I've
learnt of this just recently, another option is shinyproxy. It offer some
login capabilities, deploying through docker and is "easy" to setup
(provided nothing goes wrong).

Cheers,
Roman

On Wed, Sep 5, 2018 at 1:57 AM Erin Stearns <[hidden email]> wrote:

> Hello all!
>
> I hope this message finds you all well!
>
> I have 2 questions pertaining to the creation of interactive maps via
> Leaflet nested inside an RShiny app. One question has to do with
> computation while the other has to do with sharing/off-line interactivity.
>
> *Project description:*
> I am creating a global map depicting binary malaria risk (at risk, not at
> risk) at the Admin 2 level(current state only uses 5 countries and can be
> found here <https://erstearns.shinyapps.io/malariarisk5/>).  I am using an
> ESRI base map, then a polygons shapefile containing geometry and attributes
> (geographical hierarchy & risk).
>
> *Computation question*
> As you see, the RShiny app takes quite a bit of time to render. Does anyone
> have any suggestions for improving this? As previously said, this version
> only contains 5 countries, thus I cannot continue with my current method to
> reach a global map. I have considered finding centroids of all Admin 2
> polygons and retaining attribute information here, then rasterizing the
> malaria risk shapefile for visualization and using the 2 instead of a
> single shapefile with polygon boundaries and attributes.
>
> *Sharing the app/offline interactivity*
> I am planning to share this with people who likely do not have R installed
> on their laptops nor have they ever coded. Does anyone have any suggestions
> for the best way to do this while retaining interactivity?
>
> Thank you all, any insight is greatly appreciated.
>
> Best,
> Erin
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

--
In God we trust, all others bring data.

        [[alternative HTML version deleted]]

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

Re: Leaflet map nested in RShiny App - Improving speed & portability

Wed, 09/05/2018 - 00:40
Hi Erin,

a couple of thoughts regarding computation:

1. you could try using the preferCanvas option in leaflet(options =
leafletOptions(preferCanvas = TRUE) which likely won't help to speed up
the rendering but should make the map more responsive.

2. simplify your shapes using the rmapshaper package. Your shapes,
especially coastlines are quite detailed which puts heavy load on the
browser.

3. maybe use a simpler world file all-together with less details. I am
especially thinking of small islands and such.

(My personal priority list would be 3, 2, 1)

Regarding sharing I am not sure I understand. Do you mean sharing as in
hosting it somewhere on a server, or sharing a file (or similar) with
someone? If the latter, the RInno package may help (though only supports
windows).

HTH,

Tim


On 09/05/2018 01:56 AM, Erin Stearns wrote:
> Hello all!
>
> I hope this message finds you all well!
>
> I have 2 questions pertaining to the creation of interactive maps via
> Leaflet nested inside an RShiny app. One question has to do with
> computation while the other has to do with sharing/off-line interactivity.
>
> *Project description:*
> I am creating a global map depicting binary malaria risk (at risk, not at
> risk) at the Admin 2 level(current state only uses 5 countries and can be
> found here <https://erstearns.shinyapps.io/malariarisk5/>).  I am using an
> ESRI base map, then a polygons shapefile containing geometry and attributes
> (geographical hierarchy & risk).
>
> *Computation question*
> As you see, the RShiny app takes quite a bit of time to render. Does anyone
> have any suggestions for improving this? As previously said, this version
> only contains 5 countries, thus I cannot continue with my current method to
> reach a global map. I have considered finding centroids of all Admin 2
> polygons and retaining attribute information here, then rasterizing the
> malaria risk shapefile for visualization and using the 2 instead of a
> single shapefile with polygon boundaries and attributes.
>
> *Sharing the app/offline interactivity*
> I am planning to share this with people who likely do not have R installed
> on their laptops nor have they ever coded. Does anyone have any suggestions
> for the best way to do this while retaining interactivity?
>
> Thank you all, any insight is greatly appreciated.
>
> Best,
> Erin
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> 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

Leaflet map nested in RShiny App - Improving speed & portability

Tue, 09/04/2018 - 18:56
Hello all!

I hope this message finds you all well!

I have 2 questions pertaining to the creation of interactive maps via
Leaflet nested inside an RShiny app. One question has to do with
computation while the other has to do with sharing/off-line interactivity.

*Project description:*
I am creating a global map depicting binary malaria risk (at risk, not at
risk) at the Admin 2 level(current state only uses 5 countries and can be
found here <https://erstearns.shinyapps.io/malariarisk5/>).  I am using an
ESRI base map, then a polygons shapefile containing geometry and attributes
(geographical hierarchy & risk).

*Computation question*
As you see, the RShiny app takes quite a bit of time to render. Does anyone
have any suggestions for improving this? As previously said, this version
only contains 5 countries, thus I cannot continue with my current method to
reach a global map. I have considered finding centroids of all Admin 2
polygons and retaining attribute information here, then rasterizing the
malaria risk shapefile for visualization and using the 2 instead of a
single shapefile with polygon boundaries and attributes.

*Sharing the app/offline interactivity*
I am planning to share this with people who likely do not have R installed
on their laptops nor have they ever coded. Does anyone have any suggestions
for the best way to do this while retaining interactivity?

Thank you all, any insight is greatly appreciated.

Best,
Erin

        [[alternative HTML version deleted]]

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

Re: spatial-temporal variograms

Tue, 09/04/2018 - 09:42
Thanks so much!

Exactly what I was looking for.

Sincerely,
Erin

Erin Hodgess, PhD
mailto: [hidden email]


On Tue, Sep 4, 2018 at 1:41 AM Dr. Benedikt Gräler <[hidden email]>
wrote:

> Dear Erin,
>
> as you say "it depends", but what I have seen so far from several
> studies, I would consider the sum-metric model as a rather flexible and
> useful model that seems to catch the spatio-temporal dependencies quite
> well ("realistic" is an even tougher question).
>
> HTH,
>
>   Ben
>
>
> On 28.08.2018 23:45, Erin Hodgess wrote:
> > Hello everyone!
> >
> > Hope you are having a good day.
> >
> > This is an opinion question, please:  Typically, we think of the
> separable
> > model for s/t variograms as not realistic.  Which ones are better, as a
> > rule, please?  I know the correct answer is "It depends".  But would we
> > consider metric, or sum-metric (or some of the others) more realistic,
> > please?
> >
> > Thanks,
> > Erin
> >
> >
> > Erin Hodgess, PhD
> > mailto: [hidden email]
> >
> >       [[alternative HTML version deleted]]
> >
> > _______________________________________________
> > R-sig-Geo mailing list
> > [hidden email]
> > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> >
>
> --
> Dr. Benedikt Gräler
> 52°North Initiative for Geospatial Open Source Software GmbH
> Martin-Luther-King-Weg 24
> 48155 Muenster, Germany
>
> E-Mail: [hidden email]
> Fon: +49-(0)-251/396371-39
> Fax: +49-(0)-251/396371-11
>
> http://52north.org/
> Twitter: @FiveTwoN
>
> General Managers:
> Prof. Dr. Albert Remke, Prof. Dr. Andreas Wytzisk-Arens
> Local Court Muenster HRB 10849
>
> _______________________________________________
> 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

Possibly breaking changes in rgeos

Tue, 09/04/2018 - 05:51
In this sf issue (https://github.com/r-spatial/sf/issues/822), it was
pointed out that error handling in rgeos (and sf) leaked memory at least
when invalid geometries triggered an exception, leading to an R error, but
without the GEOS objects being freed/destroyed. An attempt has been made
to address this problem in rgeos, and is available for testing from
R-Forge (version 0.4-1):

install.packages("rgeos", repos="http://R-Forge.R-project.org")

Please check whether this version (throwing the R error after freeing
memory in calling function rather than throwing the R error immediately on
exception) has missed any important points in your typical workflows - if
you find any, please write directly to me as maintainer with a small
reproducible example for adding to tests/leak_by_exception.R. If you find
anything, also consider using gdb and/or valgrind to backtrack to the
rgeos C function causing the mayhem.

Grateful for any reports,

Roger
(rgeos maintainer)

--
Roger Bivand
Department of Economics, Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; e-mail: [hidden email]
http://orcid.org/0000-0003-2392-6140
https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en

_______________________________________________
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

Re: Adding great circle routes as polylines in Leaflet

Tue, 09/04/2018 - 05:25
On Tue, Sep 4, 2018 at 12:18 AM, Dhiraj Khanna <[hidden email]>
wrote:

> @Kent Johnson <[hidden email]> yes, this is shipping data and you are right, great circle routes are not the best visualization. The problem I am facing is that I have oil trade happening over a period of time from various ports that I need to visualize. Over the selected period of time, there are hundreds of voyages being undertaken by ships. Plotting them all as gc routes looks ugly. My approach has been to classify these ports into regions, which I drew using mapedit and saved them as SF polygons. I then calculated their centroids and those are the coordinates in the ByRoute dataframe. Would appreciate your comments on any other visualization which you think might be appropriate.
>
> If your primary interest is to visualize the flows (not the geography)
then a circle plot might work well. Here is an example showing migration
flows:
https://gjabel.wordpress.com/2016/05/18/updated-circular-plots-for-directional-bilateral-migration-data/
made with
https://cran.r-project.org/web/packages/circlize/index.html

Kent


> Regards
> Dhiraj Khanna
>

        [[alternative HTML version deleted]]

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

Re: spatial-temporal variograms

Tue, 09/04/2018 - 02:41
Dear Erin,

as you say "it depends", but what I have seen so far from several
studies, I would consider the sum-metric model as a rather flexible and
useful model that seems to catch the spatio-temporal dependencies quite
well ("realistic" is an even tougher question).

HTH,

  Ben


On 28.08.2018 23:45, Erin Hodgess wrote:
> Hello everyone!
>
> Hope you are having a good day.
>
> This is an opinion question, please:  Typically, we think of the separable
> model for s/t variograms as not realistic.  Which ones are better, as a
> rule, please?  I know the correct answer is "It depends".  But would we
> consider metric, or sum-metric (or some of the others) more realistic,
> please?
>
> Thanks,
> Erin
>
>
> Erin Hodgess, PhD
> mailto: [hidden email]
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
--
Dr. Benedikt Gräler
52°North Initiative for Geospatial Open Source Software GmbH
Martin-Luther-King-Weg 24
48155 Muenster, Germany

E-Mail: [hidden email]
Fon: +49-(0)-251/396371-39
Fax: +49-(0)-251/396371-11

http://52north.org/
Twitter: @FiveTwoN

General Managers:
Prof. Dr. Albert Remke, Prof. Dr. Andreas Wytzisk-Arens
Local Court Muenster HRB 10849

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

Re: P-Tree

Tue, 09/04/2018 - 01:43
Thank’ you.

But, I’m looking for Peano Count Tree algorithm. This seems in decission trees algorithm.


Enviado desde mi iPhone

> El 3 sept 2018, a las 17:43, Ben Tupper <[hidden email]> escribió:
>
> Hi,
>
> Have you explored RSeek.org?
>
> https://rseek.org/?q=p-tree
>
> Cheers,
> Ben
>> On Sep 3, 2018, at 11:16 AM, Jose luis Aguilar colmenero via R-sig-Geo <[hidden email]> wrote:
>>
>> Hi,
>>
>> I’m student PhD of Data science. I need know if exist any package that contains p-tree algorithm.
>>
>> Thank’s you
>>
>> Enviado desde mi iPhone
>> _______________________________________________
>> R-sig-Geo mailing list
>> [hidden email]
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
>
> Ben Tupper
> Bigelow Laboratory for Ocean Sciences
> 60 Bigelow Drive, P.O. Box 380
> East Boothbay, Maine 04544
> http://www.bigelow.org
>
> Ecological Forecasting: https://eco.bigelow.org/
>
>
>
>
>
        [[alternative HTML version deleted]]

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

Re: Adding great circle routes as polylines in Leaflet

Mon, 09/03/2018 - 23:18
Ben and Kent, thank you so much for your replies. Both work!

@Ben next time will make sure the code is more “calorie-free” :)

@Kent Johnson <[hidden email]> I modified the weight for the lines by
using a scaling factor.

myScale <- function(x){(x-min(x))/(max(x)-min(x))}

ByRoute$AvgTCE <- myScale(ByRoute$AvgTCE)*5 + 1

@Kent Johnson <[hidden email]> yes, this is shipping data and you are
right, great circle routes are not the best visualization. The problem I am
facing is that I have oil trade happening over a period of time from
various ports that I need to visualize. Over the selected period of time,
there are hundreds of voyages being undertaken by ships. Plotting them all
as gc routes looks ugly. My approach has been to classify these ports into
regions, which I drew using mapedit and saved them as SF polygons. I then
calculated their centroids and those are the coordinates in the ByRoute
dataframe. Would appreciate your comments on any other visualization which
you think might be appropriate.

Regards
Dhiraj Khanna
Mob:09873263331

On Mon, Sep 3, 2018 at 10:22 PM Kent Johnson <[hidden email]> wrote:

> From: Dhiraj Khanna <[hidden email]>
>> To: [hidden email]
>> Subject: [R-sig-Geo] Adding great circle routes as polylines in
>>         Leaflet
>> Message-ID:
>>         <CANHhK31knXB+8ev2LEQWOa3y+ZaUgkJ5noAV=
>> [hidden email]>
>> Content-Type: text/plain; charset="utf-8"
>>
>> I am trying to add great circle routes between various regions in R.
>>
>> I would like to plot great circle routes between CommencingRegion to
>> LoadingRegion and then from LoadingRegion to DischargeRegion for every
>> row.
>> Additionally, every row needs to be in a different color and the thickness
>> needs to be proportional to AvgTCE. The last 6 variables in the data above
>> are the coordinates in Lat Long for the commencing, loading and
>> discharging
>> regions respectively. I am quite clueless on how to go about achieving
>> this. This is what I have tried and failed:
>>
>> leaflet() %>%
>>   addTiles() %>%
>>   for(i in 1:6){
>>
>> addPolylines(data=gcIntermediate(c(ByRoute$CLon[i],ByRoute$CLat[i]),c(ByRoute$LLon[i],ByRoute$CLat[i]),n=100,addStartEnd
>> = T,sp=T))
>>   }
>>
>> Here is a (rather clunky) start:
> library(leaflet)
> library(geosphere)
> library(dplyr)
>
> d = byRoute %>%
>   rowwise() %>%
>   do(leg1=gcIntermediate(c(.$CLon, .$CLat), c(.$LLon, .$LLat), n=50,
> addStartEnd=TRUE),
>      leg2=gcIntermediate(c(.$LLon, .$LLat), c(.$DLon, .$DLat), n=50,
> addStartEnd=TRUE))
>
> colors=palette()
> map = leaflet() %>% addTiles()
> for (i in seq_len(nrow(d)))
>   map = map %>% addPolylines(data=d$leg1[[i]], color=colors[i],
> weight=byRoute$AvgTCE[i]/3000-5) %>%
>   addPolylines(data=d$leg2[[i]], color=colors[i],
> weight=byRoute$AvgTCE[i]/3000-5)
> map
>
> You will have to split the great circles using something like
> the plot_my_connection function here:
>
> https://www.r-graph-gallery.com/how-to-draw-connecting-routes-on-map-with-r-and-great-circles/
>
> Is this shipping data? Maybe great circles are not the correct route...
> Kent
>
>
>> Regards
>> Dhiraj Khanna
>> Mob:09873263331
>
>
        [[alternative HTML version deleted]]

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

Re: Adding great circle routes as polylines in Leaflet

Mon, 09/03/2018 - 11:52
>
> From: Dhiraj Khanna <[hidden email]>
> To: [hidden email]
> Subject: [R-sig-Geo] Adding great circle routes as polylines in
>         Leaflet
> Message-ID:
>         <CANHhK31knXB+8ev2LEQWOa3y+ZaUgkJ5noAV=iX7Z14j_foqZw@
> mail.gmail.com>
> Content-Type: text/plain; charset="utf-8"
>
> I am trying to add great circle routes between various regions in R.
>
> I would like to plot great circle routes between CommencingRegion to
> LoadingRegion and then from LoadingRegion to DischargeRegion for every row.
> Additionally, every row needs to be in a different color and the thickness
> needs to be proportional to AvgTCE. The last 6 variables in the data above
> are the coordinates in Lat Long for the commencing, loading and discharging
> regions respectively. I am quite clueless on how to go about achieving
> this. This is what I have tried and failed:
>
> leaflet() %>%
>   addTiles() %>%
>   for(i in 1:6){
>     addPolylines(data=gcIntermediate(c(ByRoute$CLon[
> i],ByRoute$CLat[i]),c(ByRoute$LLon[i],ByRoute$CLat[i]),n=100,addStartEnd
> = T,sp=T))
>   }
>
> Here is a (rather clunky) start: library(leaflet)
library(geosphere)
library(dplyr)

d = byRoute %>%
  rowwise() %>%
  do(leg1=gcIntermediate(c(.$CLon, .$CLat), c(.$LLon, .$LLat), n=50,
addStartEnd=TRUE),
     leg2=gcIntermediate(c(.$LLon, .$LLat), c(.$DLon, .$DLat), n=50,
addStartEnd=TRUE))

colors=palette()
map = leaflet() %>% addTiles()
for (i in seq_len(nrow(d)))
  map = map %>% addPolylines(data=d$leg1[[i]], color=colors[i],
weight=byRoute$AvgTCE[i]/3000-5) %>%
  addPolylines(data=d$leg2[[i]], color=colors[i],
weight=byRoute$AvgTCE[i]/3000-5)
map

You will have to split the great circles using something like
the plot_my_connection function here:
https://www.r-graph-gallery.com/how-to-draw-connecting-routes-on-map-with-r-and-great-circles/

Is this shipping data? Maybe great circles are not the correct route...
Kent


> Regards
> Dhiraj Khanna
> Mob:09873263331

        [[alternative HTML version deleted]]

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

Re: P-Tree

Mon, 09/03/2018 - 10:43
Hi,

Have you explored RSeek.org <http://rseek.org/>?

https://rseek.org/?q=p-tree <https://rseek.org/?q=p-tree>

Cheers,
Ben
> On Sep 3, 2018, at 11:16 AM, Jose luis Aguilar colmenero via R-sig-Geo <[hidden email]> wrote:
>
> Hi,
>
> I’m student PhD of Data science. I need know if exist any package that contains p-tree algorithm.
>
> Thank’s you
>
> Enviado desde mi iPhone
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
Ben Tupper
Bigelow Laboratory for Ocean Sciences
60 Bigelow Drive, P.O. Box 380
East Boothbay, Maine 04544
http://www.bigelow.org

Ecological Forecasting: https://eco.bigelow.org/






        [[alternative HTML version deleted]]

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

P-Tree

Mon, 09/03/2018 - 10:16
Hi,

I’m student PhD of Data science. I need know if exist any package that contains p-tree algorithm.

Thank’s you

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

Re: Adding great circle routes as polylines in Leaflet

Mon, 09/03/2018 - 09:57
Hi,

Your example is so close to being reproducible, but not quite close enough.  After some noodling around I figured out that you are using geosphere package in addition to leaflet, and that your tibble is assigned to the `ByRoute` variable.  The following gets you closer - you'll want to resolve the warning messages ...

Warning messages:
1: In .pointsToMatrix(p2) :longitude > 180
2: In .pointsToMatrix(p2) :longitude > 180
3: In .pointsToMatrix(p2) : longitude > 180


... which you can fix in your tibble.

When adding layers to a map, you really want to create a map object, store it in a variable, say 'm', and ad each layer in an iteration enclosing the pipes (rather than within the pipes).  I'm sure that there will be some wrapping issues if you copy-and-paste from this email.  (Also, please put a bit more white space in your code.  They are calorie-free and make life so much easier on us old fellows.)

Cheers,
Ben


library(leaflet)
library(geosphere)
ByRoute = structure(list(CommencingRegion = c("RedSea", "EastAfrica", "GulfofMexico",
                                        "FarEast", "RedSea", "GulfofMexico"), LoadRegion = c("RedSea",
                                                                                             "RedSea", "GulfofMexico", "FarEast", "RedSea", "GulfofMexico"
                                        ), DischargeRegion = c("NorthWestAfrica", "WestMedditerranean",
                                                               "WestCoastLatinAmerica", "AustraliaNewZealand", "WestMedditerranean",
                                                               "WestCoastCentralAmerica"), Count = c(1L, 1L, 2L, 1L, 2L, 5L),
                   AvgTCE = c(38879.53, 31783.55, 28520.79, 26068.8, 26054.28,
                              25883.81), CLon = c(37.8274879335485, 47.0791103099334, -90.9633701509553,
                                                  146.2727573458, 37.8274879335485, -90.9633701509553), CLat =
                       c(21.4460561443517,
                         -12.9570828789565, 25.2035802054683, 47.6530892619773, 21.4460561443517,
                         25.2035802054683), LLon = c(37.8274879335485, 37.8274879335485,
                                                     -90.9633701509553, 146.2727573458, 37.8274879335485, -90.9633701509553
                         ), LLat = c(21.4460561443517, 21.4460561443517, 25.2035802054683,
                                     47.6530892619773, 21.4460561443517, 25.2035802054683), DLon =
                       c(-17.1597117430475,
                         7.03639948506481, -73.4238157230412, 151.051220297802, 7.03639948506481,
                         255.83509305644), DLat = c(24.2308740597312, 38.8907379374372,
                                                    -25.8934046406896, -25.1880219406131, 38.8907379374372, 21.8130318388702
                         )), row.names = c(NA, -6L), class = c("tbl_df", "tbl", "data.frame"
                         ))



# create the map object
m <- leaflet() %>%
    addTiles()

# iteratively add each polyline commence-to-load and load-to-destination
for(i in 1:6){
        m <- m %>%
            addPolylines(data=gcIntermediate(c(ByRoute$CLon[i], ByRoute$CLat[i]), c(ByRoute$LLon[i], ByRoute$CLat[i]),
                                            n=100, addStartEnd = TRUE, sp = TRUE)) %>%
            addPolylines(data=gcIntermediate(c(ByRoute$LLon[i], ByRoute$LLat[i]), c(ByRoute$DLon[i], ByRoute$DLat[i]),
                                             n=100, addStartEnd = TRUE, sp = TRUE))
}        

m      





> On Sep 2, 2018, at 10:34 PM, Dhiraj Khanna <[hidden email]> wrote:
>
> I am trying to add great circle routes between various regions in R. Here’s
> the sample data:
>
> structure(list(CommencingRegion = c("RedSea", "EastAfrica", "GulfofMexico",
> "FarEast", "RedSea", "GulfofMexico"), LoadRegion = c("RedSea",
> "RedSea", "GulfofMexico", "FarEast", "RedSea", "GulfofMexico"
> ), DischargeRegion = c("NorthWestAfrica", "WestMedditerranean",
> "WestCoastLatinAmerica", "AustraliaNewZealand", "WestMedditerranean",
> "WestCoastCentralAmerica"), Count = c(1L, 1L, 2L, 1L, 2L, 5L),
>    AvgTCE = c(38879.53, 31783.55, 28520.79, 26068.8, 26054.28,
>    25883.81), CLon = c(37.8274879335485, 47.0791103099334, -90.9633701509553,
>    146.2727573458, 37.8274879335485, -90.9633701509553), CLat =
> c(21.4460561443517,
>    -12.9570828789565, 25.2035802054683, 47.6530892619773, 21.4460561443517,
>    25.2035802054683), LLon = c(37.8274879335485, 37.8274879335485,
>    -90.9633701509553, 146.2727573458, 37.8274879335485, -90.9633701509553
>    ), LLat = c(21.4460561443517, 21.4460561443517, 25.2035802054683,
>    47.6530892619773, 21.4460561443517, 25.2035802054683), DLon =
> c(-17.1597117430475,
>    7.03639948506481, -73.4238157230412, 151.051220297802, 7.03639948506481,
>    255.83509305644), DLat = c(24.2308740597312, 38.8907379374372,
>    -25.8934046406896, -25.1880219406131, 38.8907379374372, 21.8130318388702
>    )), row.names = c(NA, -6L), class = c("tbl_df", "tbl", "data.frame"
> ))
>
> I would like to plot great circle routes between CommencingRegion to
> LoadingRegion and then from LoadingRegion to DischargeRegion for every row.
> Additionally, every row needs to be in a different color and the thickness
> needs to be proportional to AvgTCE. The last 6 variables in the data above
> are the coordinates in Lat Long for the commencing, loading and discharging
> regions respectively. I am quite clueless on how to go about achieving
> this. This is what I have tried and failed:
>
> leaflet() %>%
>  addTiles() %>%
>  for(i in 1:6){
>    addPolylines(data=gcIntermediate(c(ByRoute$CLon[i],ByRoute$CLat[i]),c(ByRoute$LLon[i],ByRoute$CLat[i]),n=100,addStartEnd
> = T,sp=T))
>  }
>
> Regards
> Dhiraj Khanna
> Mob:09873263331
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
Ben Tupper
Bigelow Laboratory for Ocean Sciences
60 Bigelow Drive, P.O. Box 380
East Boothbay, Maine 04544
http://www.bigelow.org

Ecological Forecasting: https://eco.bigelow.org/

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

Adding great circle routes as polylines in Leaflet

Sun, 09/02/2018 - 21:34
I am trying to add great circle routes between various regions in R. Here’s
the sample data:

structure(list(CommencingRegion = c("RedSea", "EastAfrica", "GulfofMexico",
"FarEast", "RedSea", "GulfofMexico"), LoadRegion = c("RedSea",
"RedSea", "GulfofMexico", "FarEast", "RedSea", "GulfofMexico"
), DischargeRegion = c("NorthWestAfrica", "WestMedditerranean",
"WestCoastLatinAmerica", "AustraliaNewZealand", "WestMedditerranean",
"WestCoastCentralAmerica"), Count = c(1L, 1L, 2L, 1L, 2L, 5L),
    AvgTCE = c(38879.53, 31783.55, 28520.79, 26068.8, 26054.28,
    25883.81), CLon = c(37.8274879335485, 47.0791103099334, -90.9633701509553,
    146.2727573458, 37.8274879335485, -90.9633701509553), CLat =
c(21.4460561443517,
    -12.9570828789565, 25.2035802054683, 47.6530892619773, 21.4460561443517,
    25.2035802054683), LLon = c(37.8274879335485, 37.8274879335485,
    -90.9633701509553, 146.2727573458, 37.8274879335485, -90.9633701509553
    ), LLat = c(21.4460561443517, 21.4460561443517, 25.2035802054683,
    47.6530892619773, 21.4460561443517, 25.2035802054683), DLon =
c(-17.1597117430475,
    7.03639948506481, -73.4238157230412, 151.051220297802, 7.03639948506481,
    255.83509305644), DLat = c(24.2308740597312, 38.8907379374372,
    -25.8934046406896, -25.1880219406131, 38.8907379374372, 21.8130318388702
    )), row.names = c(NA, -6L), class = c("tbl_df", "tbl", "data.frame"
))

I would like to plot great circle routes between CommencingRegion to
LoadingRegion and then from LoadingRegion to DischargeRegion for every row.
Additionally, every row needs to be in a different color and the thickness
needs to be proportional to AvgTCE. The last 6 variables in the data above
are the coordinates in Lat Long for the commencing, loading and discharging
regions respectively. I am quite clueless on how to go about achieving
this. This is what I have tried and failed:

leaflet() %>%
  addTiles() %>%
  for(i in 1:6){
    addPolylines(data=gcIntermediate(c(ByRoute$CLon[i],ByRoute$CLat[i]),c(ByRoute$LLon[i],ByRoute$CLat[i]),n=100,addStartEnd
= T,sp=T))
  }

Regards
Dhiraj Khanna
Mob:09873263331

        [[alternative HTML version deleted]]

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

Re: A question about the splm package

Sun, 09/02/2018 - 14:19
On Sun, 2 Sep 2018, Danlin Yu wrote:

> Dear list:
>
> I hope this email finds you all well.
>
> I've been recently using the spml package to estimate my data sets for
> spatial panel analysis. During the process of applying the package, I made
> a few mistakes and realized that when I was supplying the weight matrix
> (through the listw object) to the spml/spgm routines, there is no check or
> guarantee that the order of the spatial objects as represented in the listw
> object is exactly the same as the order of the spatial objects in the data
> set as supplied by the argument data = (please let me know if I was wrong
> here).
Could you please provide a worked example with (built in?) data - such as
Produc with US states from the maps package? You'd have to work backwards,
using the maps and the data to create your input, then try to provoke the
problem.

Roger

>
> I made such a mistake the first time when I was using the spml/spgm
> routines, and found that when I used the pdata.frame routine to convert my
> panel data to plm agreeable format (I suspect even if I didn't do that, it
> will get converted within the routines), the order of the spatial object
> gets re-ordered based on their alphabetic order of the "name" item supplied
> to the "index" argument, but the listw was still in the order as it was
> created based on the original order of the map object (the
> SpatialPolygonDataFrame).
>
> I tried to make some work around, but I can not be 100% sure if what I did
> was right, so I am writing to ask for your advice.
>
> Here is what I did:
>
> #for a listw object, say w.listw, I changed it to a weight matrix using
> listw2mat:
>
> w.wmat <-listw2mat(w.listw)
>
> #I then assign the names of the spatial objects that correspond to each row
> and column to the weight matrix:
>
> colnames(w.wmat)<-colnames(spatialObject@data$Name)
> rownames(w.wmat)<-colnames(spatialObject@data$Name)
>
> #I then re-order the weight matrix to make sure the order of the spatial
> objects in the new weight matrix is ordered alphabetically:
>
> w.wmat <- w.wmat[order(rownames(w.wmat)),]
> w.wmat<- w.wmat[,order(colnames(w.wmat))]
>
> #And then I either supply this weight matrix to the spml/spgm routines or
> change it back to a listw object and supply it to the routines:
>
> w.listw<-mat2listw(w.wmat)
>
> After I've done that the outputs from the routines are different from if I
> didn't do it. But I am not entire sure if I did this correctly or maybe I
> am missing something.
>
> Thank you in advance.
>
> Best,
>
> Danlin Yu, Ph.D.
> Professor of GIS and Urban Geography
> Department of Earth & Environmental Studies
> Montclair State University
> Montclair, NJ, 07043
> Tel: 973-655-4313
> Fax: 973-655-4072
> Office: CELS 314
> Email: [hidden email]
> webpage: csam.montclair.edu/~yu
>
> [[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.
voice: +47 55 95 93 55; e-mail: [hidden email]
http://orcid.org/0000-0003-2392-6140
https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en

_______________________________________________
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

A question about the splm package

Sun, 09/02/2018 - 02:23
Dear list:

I hope this email finds you all well.

I've been recently using the spml package to estimate my data sets for
spatial panel analysis. During the process of applying the package, I made
a few mistakes and realized that when I was supplying the weight matrix
(through the listw object) to the spml/spgm routines, there is no check or
guarantee that the order of the spatial objects as represented in the listw
object is exactly the same as the order of the spatial objects in the data
set as supplied by the argument data = (please let me know if I was wrong
here).

I made such a mistake the first time when I was using the spml/spgm
routines, and found that when I used the pdata.frame routine to convert my
panel data to plm agreeable format (I suspect even if I didn't do that, it
will get converted within the routines), the order of the spatial object
gets re-ordered based on their alphabetic order of the "name" item supplied
to the "index" argument, but the listw was still in the order as it was
created based on the original order of the map object (the
SpatialPolygonDataFrame).

I tried to make some work around, but I can not be 100% sure if what I did
was right, so I am writing to ask for your advice.

Here is what I did:

#for a listw object, say w.listw, I changed it to a weight matrix using
listw2mat:

w.wmat <-listw2mat(w.listw)

#I then assign the names of the spatial objects that correspond to each row
and column to the weight matrix:

colnames(w.wmat)<-colnames(spatialObject@data$Name)
rownames(w.wmat)<-colnames(spatialObject@data$Name)

#I then re-order the weight matrix to make sure the order of the spatial
objects in the new weight matrix is ordered alphabetically:

w.wmat <- w.wmat[order(rownames(w.wmat)),]
w.wmat<- w.wmat[,order(colnames(w.wmat))]

#And then I either supply this weight matrix to the spml/spgm routines or
change it back to a listw object and supply it to the routines:

w.listw<-mat2listw(w.wmat)

After I've done that the outputs from the routines are different from if I
didn't do it. But I am not entire sure if I did this correctly or maybe I
am missing something.

Thank you in advance.

Best,

Danlin Yu, Ph.D.
Professor of GIS and Urban Geography
Department of Earth & Environmental Studies
Montclair State University
Montclair, NJ, 07043
Tel: 973-655-4313
Fax: 973-655-4072
Office: CELS 314
Email: [hidden email]
webpage: csam.montclair.edu/~yu

        [[alternative HTML version deleted]]

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

Re: Adding colour to polylines in Leaflet

Sat, 09/01/2018 - 09:36
Thank you Kent, that worked like a charm!
Regards

Dhiraj Khanna
Mob:09873263331


On Sat, Sep 1, 2018 at 7:59 PM Kent Johnson <[hidden email]> wrote:

> You have to include the points where the colors change in both polylines.
> Here is one way:
>
> x$lastColor = dplyr::lag(x$Color)
> map <-  leaflet(x)
> map <- addTiles(map)
> for( Color in
> levels(as.factor(x$Color))){
>   map <- addPolylines(map,lng=~lon,lat=~lat,data=x[x$Color==Color |
> x$lastColor==Color,], color=~Color) }
> map
>
> Kent
>
> On Sat, Sep 1, 2018 at 8:56 AM, Dhiraj Khanna <[hidden email]>
> wrote:
>
>> @Kent they are appearing as three separate lines. I am hoping to see them
>> joint with no gaps. The transition from row 4 to row 5 is where the speed
>> has changed from 2.1 knots to 3.4 knots. I am hoping to see another line
>> from row 4 to row 5 in red colour. Similarly for the other disjoint points.
>> Regards
>>
>> Dhiraj Khanna
>> Mob:09873263331
>>
>>
>> On Sat, Sep 1, 2018 at 6:17 PM Kent Johnson <[hidden email]> wrote:
>>
>>> Message: 5
>>>> Date: Sat, 1 Sep 2018 08:28:24 +0530
>>>> From: Dhiraj Khanna <[hidden email]>
>>>> To: [hidden email]
>>>> Subject: [R-sig-Geo] Adding colour to polylines in Leaflet
>>>> Message-ID:
>>>>         <
>>>> [hidden email]>
>>>> Content-Type: text/plain; charset="utf-8"
>>>>
>>>> I am working with shipping data where I get the dynamic parameters of a
>>>> ship like its position, speed, heading and rate of turn. I am then
>>>> trying
>>>> to plot this on a leaflet map and trying to colour the polylines based
>>>> on
>>>> the speed, but it always shows up in the same colour. Here’s some sample
>>>> data:
>>>>
>>>> <snip>
>>>> This is the code I have tried which doesn’t work:-
>>>>
>>>> map <-  leaflet(x) map <- addTiles(map) for( Color in
>>>> levels(as.factor(x$Color))){   map <- addPolylines(map,
>>>> lng=~lon,lat=~lat,data=x[x$Color==Color,], color=~Color) } map
>>>>
>>>> Regards
>>>> Dhiraj Khanna
>>>> Mob:09873263331
>>>
>>>
>>> What are you expecting to see? When I run your code I get a map with
>>> three lines, one red, one orange and one yellow.
>>>
>>> Kent
>>>
>>>
>
        [[alternative HTML version deleted]]

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

Re: Adding colour to polylines in Leaflet

Sat, 09/01/2018 - 09:29
You have to include the points where the colors change in both polylines.
Here is one way:

x$lastColor = dplyr::lag(x$Color)
map <-  leaflet(x)
map <- addTiles(map)
for( Color in
levels(as.factor(x$Color))){
  map <- addPolylines(map,lng=~lon,lat=~lat,data=x[x$Color==Color |
x$lastColor==Color,], color=~Color) }
map

Kent

On Sat, Sep 1, 2018 at 8:56 AM, Dhiraj Khanna <[hidden email]>
wrote:

> @Kent they are appearing as three separate lines. I am hoping to see them
> joint with no gaps. The transition from row 4 to row 5 is where the speed
> has changed from 2.1 knots to 3.4 knots. I am hoping to see another line
> from row 4 to row 5 in red colour. Similarly for the other disjoint points.
> Regards
>
> Dhiraj Khanna
> Mob:09873263331
>
>
> On Sat, Sep 1, 2018 at 6:17 PM Kent Johnson <[hidden email]> wrote:
>
>> Message: 5
>>> Date: Sat, 1 Sep 2018 08:28:24 +0530
>>> From: Dhiraj Khanna <[hidden email]>
>>> To: [hidden email]
>>> Subject: [R-sig-Geo] Adding colour to polylines in Leaflet
>>> Message-ID:
>>>         <CANHhK329-Y7hPJD9gSOs24mSqGkrjC481oQspNA
>>> [hidden email]>
>>> Content-Type: text/plain; charset="utf-8"
>>>
>>> I am working with shipping data where I get the dynamic parameters of a
>>> ship like its position, speed, heading and rate of turn. I am then trying
>>> to plot this on a leaflet map and trying to colour the polylines based on
>>> the speed, but it always shows up in the same colour. Here’s some sample
>>> data:
>>>
>>> <snip>
>>> This is the code I have tried which doesn’t work:-
>>>
>>> map <-  leaflet(x) map <- addTiles(map) for( Color in
>>> levels(as.factor(x$Color))){   map <- addPolylines(map,
>>> lng=~lon,lat=~lat,data=x[x$Color==Color,], color=~Color) } map
>>>
>>> Regards
>>> Dhiraj Khanna
>>> Mob:09873263331
>>
>>
>> What are you expecting to see? When I run your code I get a map with
>> three lines, one red, one orange and one yellow.
>>
>> Kent
>>
>>
        [[alternative HTML version deleted]]

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

Pages