Re: [R] flow map lines between point pairs (latitude/longitude)

From: Richard and Barbara Males <rbmales_at_gmail.com>
Date: Wed, 02 Jul 2008 17:54:20 -0400

made my day, thanks, worked just fine with a little bit of tweaking (flipping x and y around, basically).

rapid response much appreciated

Dick

On Wed, Jul 2, 2008 at 5:25 PM, Ray Brownrigg <Ray.Brownrigg_at_mcs.vuw.ac.nz> wrote:
> Here's one solution, YMMV:
> library(maps)
> # Note, plot the map first to get the aspect ratio (or projection) right
> map("county", xlim=range(df2VisitTrips[, c(5, 7)]), ylim=range(df2VisitTrips[, c(4, 6)]),
> col=8)
> map("state", add=T)
> map.axes()
> for (i in 1:length(df2VisitTrips[, 1])) {
> lines(df2VisitTrips[i, c(5, 7)], df2VisitTrips[i, c(4, 6)], lwd=0.2 + df2VisitTrips[i,
> 3]/10, col=i+1)
> }
>
> Ray Brownrigg
>
> On Thu, 03 Jul 2008, Richard and Barbara Males wrote:
>> I have a dataset giving traffic between pairs of ports, and the
>> lat/lon of each port, roughly as follows:
>>
>> sample data as follows
>>
>> > df2VisitTrips[1:4,]
>>
>> Origin Destination NumberOfTrips OriginLatitude OriginLongitude
>> DestinationLatitude DestinationLongitude
>> 1 P1 P16 1 39.45965
>> -80.15633 40.76111 -79.54583
>> 2 P1 P3 1 39.45965
>> -80.15633 39.58861 -79.98222
>> 3 P102 P108 19 36.98210 -88.21597
>> 37.19667 -88.84389
>> 4 P102 P109 71 36.98210
>> -88.21597 37.09472 -89.13694
>>
>>
>> I am interested in plotting variable-width lines, based on
>> NumberOfTrips, between point pairs (OriginLongitude,OriginLatitude)
>> and (DestinationLongitude,DestinationLatititude), e.g. a flow map
>> between the ports. At some point, I may wish to add an underlay base
>> map (say counties in the US), but that is not critical at this time.
>>
>> There seem to be many packages in R that deal with spatial data (sp,
>> maps, PBSMapping, etc.), but it is unclear to me which one would work
>> best for this application.
>>
>> Any advice gratefully appreciated.
>>
>> R. Males
>> Cincinnati, Ohio, USA
>>
>> ______________________________________________
>> R-help_at_r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html and provide commented, minimal,
>> self-contained, reproducible code.
>
>
>



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Wed 02 Jul 2008 - 22:04:07 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 02 Jul 2008 - 23:31:22 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive