Plotting Very Large lat-lon data in x-y axes graph

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

Plotting Very Large lat-lon data in x-y axes graph

Ogbos
Dear Contributors,

I have a data of the form:
Lat          Lon
30.1426 104.7854
30.5622 105.0837
30.0966 104.6213
29.9795 104.8430
39.2802 147.7295
30.2469 104.6543
26.4428 157.7293
29.4782 104.5590
32.3839 105.3293
26.4746 157.8411
25.1014 159.6959
25.1242 159.6558
30.1607 104.9100
31.4900 -71.8919
43.3655 -74.9994
30.0811 104.8462
29.0912 -85.5138
26.6204 -80.9342
31.5462 -71.9638
26.8619 97.3844
30.2534 104.6134
29.9311 -85.3434
26.1524 159.6806
26.5112 158.0233
26.5441 158.0565
27.8901 -105.8554
30.3175 104.7135
26.4822 157.6127
30.1887 104.5986
29.5058 104.5661
26.4010 157.5749
30.2281 104.7585
31.4556 110.5619
30.1700 104.5861
26.3911 157.4776
30.6493 104.9949
30.2209 104.6629
26.0488 97.3608
30.2142 104.8023
30.1806 104.8158
25.2107 160.1690
30.6708 104.9385
30.4152 104.7002
30.2446 104.7804
29.5760 -85.1535
26.4484 92.4312
26.3914 157.4189
26.3986 157.4421
30.4903 -88.2271
30.6727 104.8768
30.2518 104.6466
41.6979 -78.4136
33.7575 72.1089
26.8333 -80.9485
25.3103 124.0978
30.1742 104.7554
30.6345 104.9739
30.2075 104.7960
30.2226 104.7517
30.5948 105.0532.
The record is for lightning flashes in the continental U.S. and
surrounding waters within the latitudinal band between
258 and 458N.

I want to display the result in x-y co-ordinate plot. However, the
data is very large such that when plotted, everything just appeared
blurred.


Is there a way of using color codes to  indicate the regions of higher
or lower flash densities?

I can attach the plot I generated but I am not sure if the moderator
will allow it to go with this.

I will send it in a separate email if required.

Thank you so much for sparing your time.

Best
Ogbos

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Plotting Very Large lat-lon data in x-y axes graph

Bert Gunter-2
Yes, there are many ways to do this. Search rseek.org for "2d density
plots". Also check the CRAN "Spatial" task view. Also see the kde2d
function in the MASS package and especially the examples there that use the
image() function to plot densities.

Cheers,
Bert

Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Sun, Dec 9, 2018 at 7:50 AM Ogbos Okike <[hidden email]> wrote:

> Dear Contributors,
>
> I have a data of the form:
> Lat          Lon
> 30.1426 104.7854
> 30.5622 105.0837
> 30.0966 104.6213
> 29.9795 104.8430
> 39.2802 147.7295
> 30.2469 104.6543
> 26.4428 157.7293
> 29.4782 104.5590
> 32.3839 105.3293
> 26.4746 157.8411
> 25.1014 159.6959
> 25.1242 159.6558
> 30.1607 104.9100
> 31.4900 -71.8919
> 43.3655 -74.9994
> 30.0811 104.8462
> 29.0912 -85.5138
> 26.6204 -80.9342
> 31.5462 -71.9638
> 26.8619 97.3844
> 30.2534 104.6134
> 29.9311 -85.3434
> 26.1524 159.6806
> 26.5112 158.0233
> 26.5441 158.0565
> 27.8901 -105.8554
> 30.3175 104.7135
> 26.4822 157.6127
> 30.1887 104.5986
> 29.5058 104.5661
> 26.4010 157.5749
> 30.2281 104.7585
> 31.4556 110.5619
> 30.1700 104.5861
> 26.3911 157.4776
> 30.6493 104.9949
> 30.2209 104.6629
> 26.0488 97.3608
> 30.2142 104.8023
> 30.1806 104.8158
> 25.2107 160.1690
> 30.6708 104.9385
> 30.4152 104.7002
> 30.2446 104.7804
> 29.5760 -85.1535
> 26.4484 92.4312
> 26.3914 157.4189
> 26.3986 157.4421
> 30.4903 -88.2271
> 30.6727 104.8768
> 30.2518 104.6466
> 41.6979 -78.4136
> 33.7575 72.1089
> 26.8333 -80.9485
> 25.3103 124.0978
> 30.1742 104.7554
> 30.6345 104.9739
> 30.2075 104.7960
> 30.2226 104.7517
> 30.5948 105.0532.
> The record is for lightning flashes in the continental U.S. and
> surrounding waters within the latitudinal band between
> 258 and 458N.
>
> I want to display the result in x-y co-ordinate plot. However, the
> data is very large such that when plotted, everything just appeared
> blurred.
>
>
> Is there a way of using color codes to  indicate the regions of higher
> or lower flash densities?
>
> I can attach the plot I generated but I am not sure if the moderator
> will allow it to go with this.
>
> I will send it in a separate email if required.
>
> Thank you so much for sparing your time.
>
> Best
> Ogbos
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Plotting Very Large lat-lon data in x-y axes graph

Jim Lemon-4
In reply to this post by Ogbos
Hi Ogbos,
Here is a slight modification of a method I use to display trip
density on a map:

oolt<-read.table(text="Lat Lon
30.1426 104.7854
30.5622 105.0837
30.0966 104.6213
29.9795 104.8430
39.2802 147.7295
30.2469 104.6543
26.4428 157.7293
29.4782 104.5590
32.3839 105.3293
26.4746 157.8411
25.1014 159.6959
25.1242 159.6558
30.1607 104.9100
31.4900 -71.8919
43.3655 -74.9994
30.0811 104.8462
29.0912 -85.5138
26.6204 -80.9342
31.5462 -71.9638
26.8619 97.3844
30.2534 104.6134
29.9311 -85.3434
26.1524 159.6806
26.5112 158.0233
26.5441 158.0565
27.8901 -105.8554
30.3175 104.7135
26.4822 157.6127
30.1887 104.5986
29.5058 104.5661
26.4010 157.5749
30.2281 104.7585
31.4556 110.5619
30.1700 104.5861
26.3911 157.4776
30.6493 104.9949
30.2209 104.6629
26.0488 97.3608
30.2142 104.8023
30.1806 104.8158
25.2107 160.1690
30.6708 104.9385
30.4152 104.7002
30.2446 104.7804
29.5760 -85.1535
26.4484 92.4312
26.3914 157.4189
26.3986 157.4421
30.4903 -88.2271
30.6727 104.8768
30.2518 104.6466
41.6979 -78.4136
33.7575 72.1089
26.8333 -80.9485
25.3103 124.0978
30.1742 104.7554
30.6345 104.9739
30.2075 104.7960
30.2226 104.7517
30.5948 105.0532",
header=TRUE)
latlim<-c(20,45)
lonlim<-c(-90,160)
latbreaks<-seq(latlim[1],latlim[2],by=5)
lonbreaks<-seq(lonlim[1],lonlim[2],by=10)

mids<-function(x) {
 lenx<-length(x)
 return((x[1:(lenx-1)]+x[2:lenx])/2)
}
lonmids<-mids(lonbreaks)
latmids<-mids(latbreaks)
oolt$loncuts<-cut(oolt$Lon,lonbreaks)
oolt$latcuts<-cut(oolt$Lat,latbreaks)
counts<-table(oolt$latcuts,oolt$loncuts)
library(plotrix)
countcol<-color.scale(counts,extremes=c("blue","red"))
map("world",xlim=c(-90,160),ylim=c(20,45))
for(lon in 1:length(lonmids)) {
 for(lat in 1:length(latmids)) {
  if(counts[lat,lon] > 0)
   draw.circle(lonmids[lon],latmids[lat],radius=sqrt(counts[lat,lon]),
    border=countcol[lat,lon],col=countcol[lat,lon])
 }
}

If you have very large counts in some places you may need to adjust
the radius of the circles.

Jim
On Mon, Dec 10, 2018 at 2:50 AM Ogbos Okike <[hidden email]> wrote:

>
> Dear Contributors,
>
> I have a data of the form:
> Lat          Lon
> 30.1426 104.7854
> 30.5622 105.0837
> 30.0966 104.6213
> 29.9795 104.8430
> 39.2802 147.7295
> 30.2469 104.6543
> 26.4428 157.7293
> 29.4782 104.5590
> 32.3839 105.3293
> 26.4746 157.8411
> 25.1014 159.6959
> 25.1242 159.6558
> 30.1607 104.9100
> 31.4900 -71.8919
> 43.3655 -74.9994
> 30.0811 104.8462
> 29.0912 -85.5138
> 26.6204 -80.9342
> 31.5462 -71.9638
> 26.8619 97.3844
> 30.2534 104.6134
> 29.9311 -85.3434
> 26.1524 159.6806
> 26.5112 158.0233
> 26.5441 158.0565
> 27.8901 -105.8554
> 30.3175 104.7135
> 26.4822 157.6127
> 30.1887 104.5986
> 29.5058 104.5661
> 26.4010 157.5749
> 30.2281 104.7585
> 31.4556 110.5619
> 30.1700 104.5861
> 26.3911 157.4776
> 30.6493 104.9949
> 30.2209 104.6629
> 26.0488 97.3608
> 30.2142 104.8023
> 30.1806 104.8158
> 25.2107 160.1690
> 30.6708 104.9385
> 30.4152 104.7002
> 30.2446 104.7804
> 29.5760 -85.1535
> 26.4484 92.4312
> 26.3914 157.4189
> 26.3986 157.4421
> 30.4903 -88.2271
> 30.6727 104.8768
> 30.2518 104.6466
> 41.6979 -78.4136
> 33.7575 72.1089
> 26.8333 -80.9485
> 25.3103 124.0978
> 30.1742 104.7554
> 30.6345 104.9739
> 30.2075 104.7960
> 30.2226 104.7517
> 30.5948 105.0532.
> The record is for lightning flashes in the continental U.S. and
> surrounding waters within the latitudinal band between
> 258 and 458N.
>
> I want to display the result in x-y co-ordinate plot. However, the
> data is very large such that when plotted, everything just appeared
> blurred.
>
>
> Is there a way of using color codes to  indicate the regions of higher
> or lower flash densities?
>
> I can attach the plot I generated but I am not sure if the moderator
> will allow it to go with this.
>
> I will send it in a separate email if required.
>
> Thank you so much for sparing your time.
>
> Best
> Ogbos
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Plotting Very Large lat-lon data in x-y axes graph

Ogbos
Dear Jim,

I used a bit of my data in my attempt to follow the code.

I got the attached plot after some tweaks.

I would like to add horizontal color bar legend that could be used to
explain the number of lightning counts at different points on the
latitude band as plotted.

Thank you
Warm regards
Ogbos

On Sun, Dec 9, 2018 at 9:46 PM Jim Lemon <[hidden email]> wrote:

>
> Hi Ogbos,
> Here is a slight modification of a method I use to display trip
> density on a map:
>
> oolt<-read.table(text="Lat Lon
> 30.1426 104.7854
> 30.5622 105.0837
> 30.0966 104.6213
> 29.9795 104.8430
> 39.2802 147.7295
> 30.2469 104.6543
> 26.4428 157.7293
> 29.4782 104.5590
> 32.3839 105.3293
> 26.4746 157.8411
> 25.1014 159.6959
> 25.1242 159.6558
> 30.1607 104.9100
> 31.4900 -71.8919
> 43.3655 -74.9994
> 30.0811 104.8462
> 29.0912 -85.5138
> 26.6204 -80.9342
> 31.5462 -71.9638
> 26.8619 97.3844
> 30.2534 104.6134
> 29.9311 -85.3434
> 26.1524 159.6806
> 26.5112 158.0233
> 26.5441 158.0565
> 27.8901 -105.8554
> 30.3175 104.7135
> 26.4822 157.6127
> 30.1887 104.5986
> 29.5058 104.5661
> 26.4010 157.5749
> 30.2281 104.7585
> 31.4556 110.5619
> 30.1700 104.5861
> 26.3911 157.4776
> 30.6493 104.9949
> 30.2209 104.6629
> 26.0488 97.3608
> 30.2142 104.8023
> 30.1806 104.8158
> 25.2107 160.1690
> 30.6708 104.9385
> 30.4152 104.7002
> 30.2446 104.7804
> 29.5760 -85.1535
> 26.4484 92.4312
> 26.3914 157.4189
> 26.3986 157.4421
> 30.4903 -88.2271
> 30.6727 104.8768
> 30.2518 104.6466
> 41.6979 -78.4136
> 33.7575 72.1089
> 26.8333 -80.9485
> 25.3103 124.0978
> 30.1742 104.7554
> 30.6345 104.9739
> 30.2075 104.7960
> 30.2226 104.7517
> 30.5948 105.0532",
> header=TRUE)
> latlim<-c(20,45)
> lonlim<-c(-90,160)
> latbreaks<-seq(latlim[1],latlim[2],by=5)
> lonbreaks<-seq(lonlim[1],lonlim[2],by=10)
>
> mids<-function(x) {
>  lenx<-length(x)
>  return((x[1:(lenx-1)]+x[2:lenx])/2)
> }
> lonmids<-mids(lonbreaks)
> latmids<-mids(latbreaks)
> oolt$loncuts<-cut(oolt$Lon,lonbreaks)
> oolt$latcuts<-cut(oolt$Lat,latbreaks)
> counts<-table(oolt$latcuts,oolt$loncuts)
> library(plotrix)
> countcol<-color.scale(counts,extremes=c("blue","red"))
> map("world",xlim=c(-90,160),ylim=c(20,45))
> for(lon in 1:length(lonmids)) {
>  for(lat in 1:length(latmids)) {
>   if(counts[lat,lon] > 0)
>    draw.circle(lonmids[lon],latmids[lat],radius=sqrt(counts[lat,lon]),
>     border=countcol[lat,lon],col=countcol[lat,lon])
>  }
> }
>
> If you have very large counts in some places you may need to adjust
> the radius of the circles.
>
> Jim
> On Mon, Dec 10, 2018 at 2:50 AM Ogbos Okike <[hidden email]> wrote:
> >
> > Dear Contributors,
> >
> > I have a data of the form:
> > Lat          Lon
> > 30.1426 104.7854
> > 30.5622 105.0837
> > 30.0966 104.6213
> > 29.9795 104.8430
> > 39.2802 147.7295
> > 30.2469 104.6543
> > 26.4428 157.7293
> > 29.4782 104.5590
> > 32.3839 105.3293
> > 26.4746 157.8411
> > 25.1014 159.6959
> > 25.1242 159.6558
> > 30.1607 104.9100
> > 31.4900 -71.8919
> > 43.3655 -74.9994
> > 30.0811 104.8462
> > 29.0912 -85.5138
> > 26.6204 -80.9342
> > 31.5462 -71.9638
> > 26.8619 97.3844
> > 30.2534 104.6134
> > 29.9311 -85.3434
> > 26.1524 159.6806
> > 26.5112 158.0233
> > 26.5441 158.0565
> > 27.8901 -105.8554
> > 30.3175 104.7135
> > 26.4822 157.6127
> > 30.1887 104.5986
> > 29.5058 104.5661
> > 26.4010 157.5749
> > 30.2281 104.7585
> > 31.4556 110.5619
> > 30.1700 104.5861
> > 26.3911 157.4776
> > 30.6493 104.9949
> > 30.2209 104.6629
> > 26.0488 97.3608
> > 30.2142 104.8023
> > 30.1806 104.8158
> > 25.2107 160.1690
> > 30.6708 104.9385
> > 30.4152 104.7002
> > 30.2446 104.7804
> > 29.5760 -85.1535
> > 26.4484 92.4312
> > 26.3914 157.4189
> > 26.3986 157.4421
> > 30.4903 -88.2271
> > 30.6727 104.8768
> > 30.2518 104.6466
> > 41.6979 -78.4136
> > 33.7575 72.1089
> > 26.8333 -80.9485
> > 25.3103 124.0978
> > 30.1742 104.7554
> > 30.6345 104.9739
> > 30.2075 104.7960
> > 30.2226 104.7517
> > 30.5948 105.0532.
> > The record is for lightning flashes in the continental U.S. and
> > surrounding waters within the latitudinal band between
> > 258 and 458N.
> >
> > I want to display the result in x-y co-ordinate plot. However, the
> > data is very large such that when plotted, everything just appeared
> > blurred.
> >
> >
> > Is there a way of using color codes to  indicate the regions of higher
> > or lower flash densities?
> >
> > I can attach the plot I generated but I am not sure if the moderator
> > will allow it to go with this.
> >
> > I will send it in a separate email if required.
> >
> > Thank you so much for sparing your time.
> >
> > Best
> > Ogbos
> >
> > ______________________________________________
> > [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

test.png (71K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Plotting Very Large lat-lon data in x-y axes graph

Jim Lemon-4
Hi Ogbos,
I have been off the air for a couple of days. Look at the color.legend
function in the plotrix package.

Jim
On Tue, Dec 11, 2018 at 12:39 PM Ogbos Okike <[hidden email]> wrote:

>
> Dear Jim,
> I am still having trouble with the colour code. I await your help when
> you are less busy.
>
> Thank you.
> Best
> Ogbos
> On Mon, Dec 10, 2018 at 6:25 AM Ogbos Okike <[hidden email]> wrote:
> >
> > Dear Jim,
> >
> > I used a bit of my data in my attempt to follow the code.
> >
> > I got the attached plot after some tweaks.
> >
> > I would like to add horizontal color bar legend that could be used to
> > explain the number of lightning counts at different points on the
> > latitude band as plotted.
> >
> > Thank you
> > Warm regards
> > Ogbos
> >
> > On Sun, Dec 9, 2018 at 9:46 PM Jim Lemon <[hidden email]> wrote:
> > >
> > > Hi Ogbos,
> > > Here is a slight modification of a method I use to display trip
> > > density on a map:
> > >
> > > oolt<-read.table(text="Lat Lon
> > > 30.1426 104.7854
> > > 30.5622 105.0837
> > > 30.0966 104.6213
> > > 29.9795 104.8430
> > > 39.2802 147.7295
> > > 30.2469 104.6543
> > > 26.4428 157.7293
> > > 29.4782 104.5590
> > > 32.3839 105.3293
> > > 26.4746 157.8411
> > > 25.1014 159.6959
> > > 25.1242 159.6558
> > > 30.1607 104.9100
> > > 31.4900 -71.8919
> > > 43.3655 -74.9994
> > > 30.0811 104.8462
> > > 29.0912 -85.5138
> > > 26.6204 -80.9342
> > > 31.5462 -71.9638
> > > 26.8619 97.3844
> > > 30.2534 104.6134
> > > 29.9311 -85.3434
> > > 26.1524 159.6806
> > > 26.5112 158.0233
> > > 26.5441 158.0565
> > > 27.8901 -105.8554
> > > 30.3175 104.7135
> > > 26.4822 157.6127
> > > 30.1887 104.5986
> > > 29.5058 104.5661
> > > 26.4010 157.5749
> > > 30.2281 104.7585
> > > 31.4556 110.5619
> > > 30.1700 104.5861
> > > 26.3911 157.4776
> > > 30.6493 104.9949
> > > 30.2209 104.6629
> > > 26.0488 97.3608
> > > 30.2142 104.8023
> > > 30.1806 104.8158
> > > 25.2107 160.1690
> > > 30.6708 104.9385
> > > 30.4152 104.7002
> > > 30.2446 104.7804
> > > 29.5760 -85.1535
> > > 26.4484 92.4312
> > > 26.3914 157.4189
> > > 26.3986 157.4421
> > > 30.4903 -88.2271
> > > 30.6727 104.8768
> > > 30.2518 104.6466
> > > 41.6979 -78.4136
> > > 33.7575 72.1089
> > > 26.8333 -80.9485
> > > 25.3103 124.0978
> > > 30.1742 104.7554
> > > 30.6345 104.9739
> > > 30.2075 104.7960
> > > 30.2226 104.7517
> > > 30.5948 105.0532",
> > > header=TRUE)
> > > latlim<-c(20,45)
> > > lonlim<-c(-90,160)
> > > latbreaks<-seq(latlim[1],latlim[2],by=5)
> > > lonbreaks<-seq(lonlim[1],lonlim[2],by=10)
> > >
> > > mids<-function(x) {
> > >  lenx<-length(x)
> > >  return((x[1:(lenx-1)]+x[2:lenx])/2)
> > > }
> > > lonmids<-mids(lonbreaks)
> > > latmids<-mids(latbreaks)
> > > oolt$loncuts<-cut(oolt$Lon,lonbreaks)
> > > oolt$latcuts<-cut(oolt$Lat,latbreaks)
> > > counts<-table(oolt$latcuts,oolt$loncuts)
> > > library(plotrix)
> > > countcol<-color.scale(counts,extremes=c("blue","red"))
> > > map("world",xlim=c(-90,160),ylim=c(20,45))
> > > for(lon in 1:length(lonmids)) {
> > >  for(lat in 1:length(latmids)) {
> > >   if(counts[lat,lon] > 0)
> > >    draw.circle(lonmids[lon],latmids[lat],radius=sqrt(counts[lat,lon]),
> > >     border=countcol[lat,lon],col=countcol[lat,lon])
> > >  }
> > > }
> > >
> > > If you have very large counts in some places you may need to adjust
> > > the radius of the circles.
> > >
> > > Jim
> > > On Mon, Dec 10, 2018 at 2:50 AM Ogbos Okike <[hidden email]> wrote:
> > > >
> > > > Dear Contributors,
> > > >
> > > > I have a data of the form:
> > > > Lat          Lon
> > > > 30.1426 104.7854
> > > > 30.5622 105.0837
> > > > 30.0966 104.6213
> > > > 29.9795 104.8430
> > > > 39.2802 147.7295
> > > > 30.2469 104.6543
> > > > 26.4428 157.7293
> > > > 29.4782 104.5590
> > > > 32.3839 105.3293
> > > > 26.4746 157.8411
> > > > 25.1014 159.6959
> > > > 25.1242 159.6558
> > > > 30.1607 104.9100
> > > > 31.4900 -71.8919
> > > > 43.3655 -74.9994
> > > > 30.0811 104.8462
> > > > 29.0912 -85.5138
> > > > 26.6204 -80.9342
> > > > 31.5462 -71.9638
> > > > 26.8619 97.3844
> > > > 30.2534 104.6134
> > > > 29.9311 -85.3434
> > > > 26.1524 159.6806
> > > > 26.5112 158.0233
> > > > 26.5441 158.0565
> > > > 27.8901 -105.8554
> > > > 30.3175 104.7135
> > > > 26.4822 157.6127
> > > > 30.1887 104.5986
> > > > 29.5058 104.5661
> > > > 26.4010 157.5749
> > > > 30.2281 104.7585
> > > > 31.4556 110.5619
> > > > 30.1700 104.5861
> > > > 26.3911 157.4776
> > > > 30.6493 104.9949
> > > > 30.2209 104.6629
> > > > 26.0488 97.3608
> > > > 30.2142 104.8023
> > > > 30.1806 104.8158
> > > > 25.2107 160.1690
> > > > 30.6708 104.9385
> > > > 30.4152 104.7002
> > > > 30.2446 104.7804
> > > > 29.5760 -85.1535
> > > > 26.4484 92.4312
> > > > 26.3914 157.4189
> > > > 26.3986 157.4421
> > > > 30.4903 -88.2271
> > > > 30.6727 104.8768
> > > > 30.2518 104.6466
> > > > 41.6979 -78.4136
> > > > 33.7575 72.1089
> > > > 26.8333 -80.9485
> > > > 25.3103 124.0978
> > > > 30.1742 104.7554
> > > > 30.6345 104.9739
> > > > 30.2075 104.7960
> > > > 30.2226 104.7517
> > > > 30.5948 105.0532.
> > > > The record is for lightning flashes in the continental U.S. and
> > > > surrounding waters within the latitudinal band between
> > > > 258 and 458N.
> > > >
> > > > I want to display the result in x-y co-ordinate plot. However, the
> > > > data is very large such that when plotted, everything just appeared
> > > > blurred.
> > > >
> > > >
> > > > Is there a way of using color codes to  indicate the regions of higher
> > > > or lower flash densities?
> > > >
> > > > I can attach the plot I generated but I am not sure if the moderator
> > > > will allow it to go with this.
> > > >
> > > > I will send it in a separate email if required.
> > > >
> > > > Thank you so much for sparing your time.
> > > >
> > > > Best
> > > > Ogbos
> > > >
> > > > ______________________________________________
> > > > [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> > > > https://stat.ethz.ch/mailman/listinfo/r-help
> > > > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> > > > and provide commented, minimal, self-contained, reproducible code.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Plotting Very Large lat-lon data in x-y axes graph

Ogbos
Dear All,

Thank you for your advice.

I have looked at the plotrix package and with what I gathered, I
tinkered with the code below and obtain the attached graph:
oolt<-read.table("QUERY2",col.names=c("Lat","Lon"))
 latlim<-c(20,45)
lonlim<-c(-180,180)
latbreaks<-seq(latlim[1],latlim[2],by=5)
lonbreaks<-seq(lonlim[1],lonlim[2],by=10)

mids<-function(x) {
 lenx<-length(x)
 return((x[1:(lenx-1)]+x[2:lenx])/2)
}
lonmids<-mids(lonbreaks)
latmids<-mids(latbreaks)
oolt$loncuts<-cut(oolt$Lon,lonbreaks)
oolt$latcuts<-cut(oolt$Lat,latbreaks)
counts<-table(oolt$latcuts,oolt$loncuts)
png("test.png")
library(plotrix)
countcol<-color.scale(counts,extremes=c("blue","red"))
library(maps)
map("world",xlim=c(-180,180),ylim=c(20,45))
w = map("world")
for(lon in 1:length(lonmids)) {
 for(lat in 1:length(latmids)) {
  if(counts[lat,lon] > 0)
   draw.circle(lonmids[lon],latmids[lat],radius=sqrt(counts[lat,lon]),
    border=countcol[lat,lon],col=countcol[lat,lon])
 }
}
box()
axis(1)
axis(2)
 x<-seq(-180,180,30)
 y<-seq(-90,90,30)
nx = 12
 ny = 6
grid(nx,ny,col = "red",lty="dotted",lwd=par("lwd"),equilogs=TRUE)
testcol<-color.gradient(c(10,30),0,c(30,10),nslices=5)
color.legend(-180,-130,100,-150,countcol,testcol,gradient="x")

I now have the horizontal color legend.

But I have two major problems still.
(1) The black line on top of the color bar is meaningless and I want it go.
(2) I want the numerical values plotted to appear on the color bar
(see the color.legend.png attached please) such that it can be used to
interpret the map.

I would be most grateful for any further assistance.

Very best wishes
Ogbos
On Tue, Dec 11, 2018 at 11:14 AM Jim Lemon <[hidden email]> wrote:

>
> Hi Ogbos,
> I have been off the air for a couple of days. Look at the color.legend
> function in the plotrix package.
>
> Jim
> On Tue, Dec 11, 2018 at 12:39 PM Ogbos Okike <[hidden email]> wrote:
> >
> > Dear Jim,
> > I am still having trouble with the colour code. I await your help when
> > you are less busy.
> >
> > Thank you.
> > Best
> > Ogbos
> > On Mon, Dec 10, 2018 at 6:25 AM Ogbos Okike <[hidden email]> wrote:
> > >
> > > Dear Jim,
> > >
> > > I used a bit of my data in my attempt to follow the code.
> > >
> > > I got the attached plot after some tweaks.
> > >
> > > I would like to add horizontal color bar legend that could be used to
> > > explain the number of lightning counts at different points on the
> > > latitude band as plotted.
> > >
> > > Thank you
> > > Warm regards
> > > Ogbos
> > >
> > > On Sun, Dec 9, 2018 at 9:46 PM Jim Lemon <[hidden email]> wrote:
> > > >
> > > > Hi Ogbos,
> > > > Here is a slight modification of a method I use to display trip
> > > > density on a map:
> > > >
> > > > oolt<-read.table(text="Lat Lon
> > > > 30.1426 104.7854
> > > > 30.5622 105.0837
> > > > 30.0966 104.6213
> > > > 29.9795 104.8430
> > > > 39.2802 147.7295
> > > > 30.2469 104.6543
> > > > 26.4428 157.7293
> > > > 29.4782 104.5590
> > > > 32.3839 105.3293
> > > > 26.4746 157.8411
> > > > 25.1014 159.6959
> > > > 25.1242 159.6558
> > > > 30.1607 104.9100
> > > > 31.4900 -71.8919
> > > > 43.3655 -74.9994
> > > > 30.0811 104.8462
> > > > 29.0912 -85.5138
> > > > 26.6204 -80.9342
> > > > 31.5462 -71.9638
> > > > 26.8619 97.3844
> > > > 30.2534 104.6134
> > > > 29.9311 -85.3434
> > > > 26.1524 159.6806
> > > > 26.5112 158.0233
> > > > 26.5441 158.0565
> > > > 27.8901 -105.8554
> > > > 30.3175 104.7135
> > > > 26.4822 157.6127
> > > > 30.1887 104.5986
> > > > 29.5058 104.5661
> > > > 26.4010 157.5749
> > > > 30.2281 104.7585
> > > > 31.4556 110.5619
> > > > 30.1700 104.5861
> > > > 26.3911 157.4776
> > > > 30.6493 104.9949
> > > > 30.2209 104.6629
> > > > 26.0488 97.3608
> > > > 30.2142 104.8023
> > > > 30.1806 104.8158
> > > > 25.2107 160.1690
> > > > 30.6708 104.9385
> > > > 30.4152 104.7002
> > > > 30.2446 104.7804
> > > > 29.5760 -85.1535
> > > > 26.4484 92.4312
> > > > 26.3914 157.4189
> > > > 26.3986 157.4421
> > > > 30.4903 -88.2271
> > > > 30.6727 104.8768
> > > > 30.2518 104.6466
> > > > 41.6979 -78.4136
> > > > 33.7575 72.1089
> > > > 26.8333 -80.9485
> > > > 25.3103 124.0978
> > > > 30.1742 104.7554
> > > > 30.6345 104.9739
> > > > 30.2075 104.7960
> > > > 30.2226 104.7517
> > > > 30.5948 105.0532",
> > > > header=TRUE)
> > > > latlim<-c(20,45)
> > > > lonlim<-c(-90,160)
> > > > latbreaks<-seq(latlim[1],latlim[2],by=5)
> > > > lonbreaks<-seq(lonlim[1],lonlim[2],by=10)
> > > >
> > > > mids<-function(x) {
> > > >  lenx<-length(x)
> > > >  return((x[1:(lenx-1)]+x[2:lenx])/2)
> > > > }
> > > > lonmids<-mids(lonbreaks)
> > > > latmids<-mids(latbreaks)
> > > > oolt$loncuts<-cut(oolt$Lon,lonbreaks)
> > > > oolt$latcuts<-cut(oolt$Lat,latbreaks)
> > > > counts<-table(oolt$latcuts,oolt$loncuts)
> > > > library(plotrix)
> > > > countcol<-color.scale(counts,extremes=c("blue","red"))
> > > > map("world",xlim=c(-90,160),ylim=c(20,45))
> > > > for(lon in 1:length(lonmids)) {
> > > >  for(lat in 1:length(latmids)) {
> > > >   if(counts[lat,lon] > 0)
> > > >    draw.circle(lonmids[lon],latmids[lat],radius=sqrt(counts[lat,lon]),
> > > >     border=countcol[lat,lon],col=countcol[lat,lon])
> > > >  }
> > > > }
> > > >
> > > > If you have very large counts in some places you may need to adjust
> > > > the radius of the circles.
> > > >
> > > > Jim
> > > > On Mon, Dec 10, 2018 at 2:50 AM Ogbos Okike <[hidden email]> wrote:
> > > > >
> > > > > Dear Contributors,
> > > > >
> > > > > I have a data of the form:
> > > > > Lat          Lon
> > > > > 30.1426 104.7854
> > > > > 30.5622 105.0837
> > > > > 30.0966 104.6213
> > > > > 29.9795 104.8430
> > > > > 39.2802 147.7295
> > > > > 30.2469 104.6543
> > > > > 26.4428 157.7293
> > > > > 29.4782 104.5590
> > > > > 32.3839 105.3293
> > > > > 26.4746 157.8411
> > > > > 25.1014 159.6959
> > > > > 25.1242 159.6558
> > > > > 30.1607 104.9100
> > > > > 31.4900 -71.8919
> > > > > 43.3655 -74.9994
> > > > > 30.0811 104.8462
> > > > > 29.0912 -85.5138
> > > > > 26.6204 -80.9342
> > > > > 31.5462 -71.9638
> > > > > 26.8619 97.3844
> > > > > 30.2534 104.6134
> > > > > 29.9311 -85.3434
> > > > > 26.1524 159.6806
> > > > > 26.5112 158.0233
> > > > > 26.5441 158.0565
> > > > > 27.8901 -105.8554
> > > > > 30.3175 104.7135
> > > > > 26.4822 157.6127
> > > > > 30.1887 104.5986
> > > > > 29.5058 104.5661
> > > > > 26.4010 157.5749
> > > > > 30.2281 104.7585
> > > > > 31.4556 110.5619
> > > > > 30.1700 104.5861
> > > > > 26.3911 157.4776
> > > > > 30.6493 104.9949
> > > > > 30.2209 104.6629
> > > > > 26.0488 97.3608
> > > > > 30.2142 104.8023
> > > > > 30.1806 104.8158
> > > > > 25.2107 160.1690
> > > > > 30.6708 104.9385
> > > > > 30.4152 104.7002
> > > > > 30.2446 104.7804
> > > > > 29.5760 -85.1535
> > > > > 26.4484 92.4312
> > > > > 26.3914 157.4189
> > > > > 26.3986 157.4421
> > > > > 30.4903 -88.2271
> > > > > 30.6727 104.8768
> > > > > 30.2518 104.6466
> > > > > 41.6979 -78.4136
> > > > > 33.7575 72.1089
> > > > > 26.8333 -80.9485
> > > > > 25.3103 124.0978
> > > > > 30.1742 104.7554
> > > > > 30.6345 104.9739
> > > > > 30.2075 104.7960
> > > > > 30.2226 104.7517
> > > > > 30.5948 105.0532.
> > > > > The record is for lightning flashes in the continental U.S. and
> > > > > surrounding waters within the latitudinal band between
> > > > > 258 and 458N.
> > > > >
> > > > > I want to display the result in x-y co-ordinate plot. However, the
> > > > > data is very large such that when plotted, everything just appeared
> > > > > blurred.
> > > > >
> > > > >
> > > > > Is there a way of using color codes to  indicate the regions of higher
> > > > > or lower flash densities?
> > > > >
> > > > > I can attach the plot I generated but I am not sure if the moderator
> > > > > will allow it to go with this.
> > > > >
> > > > > I will send it in a separate email if required.
> > > > >
> > > > > Thank you so much for sparing your time.
> > > > >
> > > > > Best
> > > > > Ogbos
> > > > >
> > > > > ______________________________________________
> > > > > [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> > > > > https://stat.ethz.ch/mailman/listinfo/r-help
> > > > > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> > > > > and provide commented, minimal, self-contained, reproducible code.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

test.png (72K) Download Attachment
color.legend.png (15K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Plotting Very Large lat-lon data in x-y axes graph

Jim Lemon-4
Hi Ogbos,
Back on the air after a few days off. I don't have your data ("QUERY
2"), but I think this will fix your problem.

library(maps)
map("world")
box()
library(plotrix)
color.legend(-180,-150,100,-130,legend=c(0,25000,50000,75000,100000),
 rect.col=color.scale(1:5,extremes=c("blue","red")),gradient="x")

Notice that I have swapped the "yb" and "yt" values so that they are
in increasing order. If they are reversed, the numbers will appear
within the color bar. Also you don't need to call color.gradient, just
pass the output of a five increment color scale from blue to red (or
whatever you like) to the rect.col argument.

Jim

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Plotting Very Large lat-lon data in x-y axes graph: SOLVED

Ogbos
Dear Jim,
Good news to me!! Welcome.

I am fine. The code elegantly displayed the color.

I also tried to adjust the line:
draw.circle(lonmids[lon],latmids[lat],radius=sqrt(counts[lat,lon])/100,
    border=countcol[lat,lon],col=countcol[lat,lon]) in order to reduce
the radius of the circle in order to plot the whole data.

I am really really grateful. I will immediately include the result in
a draft manuscript to Astrophysical Journal.

With the warmest regards
Ogbos

On Thu, Dec 13, 2018 at 9:04 PM Jim Lemon <[hidden email]> wrote:

>
> Hi Ogbos,
> Back on the air after a few days off. I don't have your data ("QUERY
> 2"), but I think this will fix your problem.
>
> library(maps)
> map("world")
> box()
> library(plotrix)
> color.legend(-180,-150,100,-130,legend=c(0,25000,50000,75000,100000),
>  rect.col=color.scale(1:5,extremes=c("blue","red")),gradient="x")
>
> Notice that I have swapped the "yb" and "yt" values so that they are
> in increasing order. If they are reversed, the numbers will appear
> within the color bar. Also you don't need to call color.gradient, just
> pass the output of a five increment color scale from blue to red (or
> whatever you like) to the rect.col argument.
>
> Jim

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Plotting Very Large lat-lon data in x-y axes graph

Ogbos
In reply to this post by Jim Lemon-4
Dear Jim,
Attached is a plot generated by the code for one year lightning data.

Instead of lightning flashes happening randomly at all points over the
globe, there is a kind of constraint making lightning to be aligned
straight on the longitudes.

I suspect the problem is coming from seq function in the code:
latbreaks<-seq(latlim[1],latlim[2],by=2)
lonbreaks<-seq(lonlim[1],lonlim[2],by=10).

I tried to remove them but found it difficult.

Part of the data (see below) shows that lightning happens at all
latitudes and longitudes and as such, cannot be plotted to appear only
on straight lines:
0.8312   95.2156
 -3.3851  -65.3236
 -3.2696  -65.2364
 -3.2679  -65.2349
-17.6404  164.7025
 -4.8285  148.8214
  2.6477  -67.6568
 -0.2350  -73.4833
-16.8655   40.9587
  8.1179  -61.6474
 -0.2755   93.3401
-17.1733  119.9011
  1.1245  -69.7640
-20.0035 -149.3088
 -3.4200  177.8753
  3.0133  -67.5590
 15.4684  -21.9331
-17.6166  120.2656
-17.3888  165.9368
-17.6953  164.7335
 -1.8623  -74.0017
 -3.3562  -71.1195
-11.5775  130.1496
-11.5720  130.4004
 18.7159  -21.0251
 -9.3788  -75.0815
 -2.8341  -71.9095
 -2.8276  -71.9380
-19.0845  166.5715
  1.3692  -69.8615
  1.0989  -69.8881
  1.0351  -69.9390
  1.3306  -69.9484
 13.4238  -83.6240
-18.2490  165.4406
  2.8831  -67.6648
  3.0405  -67.4912
  1.2068  -70.0177
-34.6024  -67.2998
 -8.6378  -46.0881
-17.7834  119.7202
  2.5582  -69.4447
 -6.8894  -47.9581
-16.6939   40.7143
  1.4648  -69.7636
  4.5290  -62.5343
  4.6965  -62.6023
-18.9731  166.2414
 -3.6024  173.9586
 -3.4901  173.8333
 -3.8061 -176.4053
-16.7814  -53.0986
 -0.6284  -70.7341
 -3.1878  -71.8722
 -4.3205  176.7693
 -4.3616  176.8269
-16.8295  119.7462
  2.1829  -62.9190
-16.6656   42.0181
  3.5589  -61.7756
  1.3026  -69.9409
 33.3995   13.4344
  3.0125  -67.6869
  3.0155  -67.7028
 -7.3156  -48.0353
-17.5709  164.6291
 33.0699   14.3376
 -5.6291  -48.6772
 -2.8796  -71.8747
 -2.6448  -71.5548
 -3.0977  -71.5027
  1.1513  -69.8094
  1.1024  -69.8070
 -3.6739  -65.2433
 25.9860  -51.3312
 26.0156  -51.4377
 -6.1894  -56.5574
  3.2794   95.4703
 18.6850  -20.8606
  2.8957  -68.6864
  1.0930  -69.7733
  1.4467  -69.7631
-17.8441   27.0904
  1.4039  -69.9049
  0.9384  -69.8649
 -2.2356  170.8400
  2.7273  -67.6561
  5.2676  -62.7957
-16.9645  119.2204
 33.2544   13.6508
 -6.8735  -48.0914
-17.5725  120.1941
 10.8718  -59.0204
  1.9115  -62.8357
  2.4337   -4.8253
-17.2323  119.7706
 -7.4806  -47.9645
-13.0036  166.4029
-16.6861  -53.0932
-17.5506  164.3730
  2.2578  158.9620
 -2.9222  177.1345
  5.2906  -62.6111
  5.0903  -62.5855
  2.2920   91.7130
 -6.2985  -55.5143
  2.9048  -67.6558
  3.0313  -67.6569
 -1.5240  -71.0068
  1.4910  -69.3833
  3.0779  -67.7509
  2.8380  -67.7203
Thanks for more inputs.
Ogbos
On Thu, Dec 13, 2018 at 9:04 PM Jim Lemon <[hidden email]> wrote:

>
> Hi Ogbos,
> Back on the air after a few days off. I don't have your data ("QUERY
> 2"), but I think this will fix your problem.
>
> library(maps)
> map("world")
> box()
> library(plotrix)
> color.legend(-180,-150,100,-130,legend=c(0,25000,50000,75000,100000),
>  rect.col=color.scale(1:5,extremes=c("blue","red")),gradient="x")
>
> Notice that I have swapped the "yb" and "yt" values so that they are
> in increasing order. If they are reversed, the numbers will appear
> within the color bar. Also you don't need to call color.gradient, just
> pass the output of a five increment color scale from blue to red (or
> whatever you like) to the rect.col argument.
>
> Jim

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

testB2.png (143K) Download Attachment