[R] flow map lines between point pairs (latitude/longitude)
Richard and Barbara Males
rbmales at gmail.com
Wed Jul 2 23:54:20 CEST 2008
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.
>
>
>
More information about the R-help
mailing list