how to plot gridded data

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

how to plot gridded data

lily li
Hi R users,

I have a question about plotting gridded data. I have the files separately,
but do not know how to combine them. For example, each txt file has daily
precipitation data at a specific grid cell, named pr_lat_lon.txt. How to
plot all txt files for one surface (which is rectangular in this case), or
how to combine the txt files together? Thanks.

        [[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: how to plot gridded data

PIKAL Petr
Hi

1. Read files/lines into R ?read.table, ?read.lines
2. Merge files according to your specification ?merge, ?rbind
3. Plot values by suitable command(s) ?plot, ?ggplot
4. If you want more specific answer, please post more specific question, preferably with concise and clear example.
5. Avoid posting in HTML

Cheers
Petr

> -----Original Message-----
> From: R-help <[hidden email]> On Behalf Of lily li
> Sent: Wednesday, September 12, 2018 8:55 AM
> To: R mailing list <[hidden email]>
> Subject: [R] how to plot gridded data
>
> Hi R users,
>
> I have a question about plotting gridded data. I have the files separately, but do
> not know how to combine them. For example, each txt file has daily
> precipitation data at a specific grid cell, named pr_lat_lon.txt. How to plot all
> txt files for one surface (which is rectangular in this case), or how to combine
> the txt files together? Thanks.
>
> [[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.
Osobní údaje: Informace o zpracování a ochraně osobních údajů obchodních partnerů PRECHEZA a.s. jsou zveřejněny na: https://www.precheza.cz/zasady-ochrany-osobnich-udaju/ | Information about processing and protection of business partner’s personal data are available on website: https://www.precheza.cz/en/personal-data-protection-principles/
Důvěrnost: Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a podléhají tomuto právně závaznému prohláąení o vyloučení odpovědnosti: https://www.precheza.cz/01-dovetek/ | This email and any documents attached to it may be confidential and are subject to the legally binding disclaimer: https://www.precheza.cz/en/01-disclaimer/

______________________________________________
[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: how to plot gridded data

lily li
Hi Petr,

I have merged the data using cbind. The dataset is like this:
DF
lat1_lon1  lat1_lon2  lat1_lon3  ...  lat2_lon1
  1.20           1.30          2.11      ...     1.28
  1.50           1.81          3.12      ...     2.34
  2.41           2.22          1.56      ...     2.50
  3.11           4.21          2.12      ...     3.21

The other file is a shapfile, which I can open using readOGR. Then it shows
a polygon according to geographical latitude and longitude in degrees. How
to overlay the values in DF onto the polygon? note that DF has the
coordinates for a rectangular box that includes the shapefile, but is
larger. I don't know how to do this. Thanks for your help.

On Wed, Sep 12, 2018 at 3:22 PM, PIKAL Petr <[hidden email]> wrote:

> Hi
>
> 1. Read files/lines into R ?read.table, ?read.lines
> 2. Merge files according to your specification ?merge, ?rbind
> 3. Plot values by suitable command(s) ?plot, ?ggplot
> 4. If you want more specific answer, please post more specific question,
> preferably with concise and clear example.
> 5. Avoid posting in HTML
>
> Cheers
> Petr
>
> > -----Original Message-----
> > From: R-help <[hidden email]> On Behalf Of lily li
> > Sent: Wednesday, September 12, 2018 8:55 AM
> > To: R mailing list <[hidden email]>
> > Subject: [R] how to plot gridded data
> >
> > Hi R users,
> >
> > I have a question about plotting gridded data. I have the files
> separately, but do
> > not know how to combine them. For example, each txt file has daily
> > precipitation data at a specific grid cell, named pr_lat_lon.txt. How to
> plot all
> > txt files for one surface (which is rectangular in this case), or how to
> combine
> > the txt files together? Thanks.
> >
> > [[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.
> Osobní údaje: Informace o zpracování a ochraně osobních údajů obchodních
> partnerů PRECHEZA a.s. jsou zveřejněny na: https://www.precheza.cz/
> zasady-ochrany-osobnich-udaju/ | Information about processing and
> protection of business partner’s personal data are available on website:
> https://www.precheza.cz/en/personal-data-protection-principles/
> Důvěrnost: Tento e-mail a jakékoliv k němu připojené dokumenty jsou
> důvěrné a podléhají tomuto právně závaznému prohláąení o vyloučení
> odpovědnosti: https://www.precheza.cz/01-dovetek/ | This email and any
> documents attached to it may be confidential and are subject to the legally
> binding disclaimer: https://www.precheza.cz/en/01-disclaimer/
>
>

        [[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: how to plot gridded data

lily li
I think it may be feasible to transform the dataset DF, so that the column
names lat_lon can be a surface, where the values locate at each surface.
But I don't know how to transform DF.

On Fri, Sep 14, 2018 at 10:02 AM, lily li <[hidden email]> wrote:

> Hi Petr,
>
> I have merged the data using cbind. The dataset is like this:
> DF
> lat1_lon1  lat1_lon2  lat1_lon3  ...  lat2_lon1
>   1.20           1.30          2.11      ...     1.28
>   1.50           1.81          3.12      ...     2.34
>   2.41           2.22          1.56      ...     2.50
>   3.11           4.21          2.12      ...     3.21
>
> The other file is a shapfile, which I can open using readOGR. Then it
> shows a polygon according to geographical latitude and longitude in
> degrees. How to overlay the values in DF onto the polygon? note that DF has
> the coordinates for a rectangular box that includes the shapefile, but is
> larger. I don't know how to do this. Thanks for your help.
>
> On Wed, Sep 12, 2018 at 3:22 PM, PIKAL Petr <[hidden email]>
> wrote:
>
>> Hi
>>
>> 1. Read files/lines into R ?read.table, ?read.lines
>> 2. Merge files according to your specification ?merge, ?rbind
>> 3. Plot values by suitable command(s) ?plot, ?ggplot
>> 4. If you want more specific answer, please post more specific question,
>> preferably with concise and clear example.
>> 5. Avoid posting in HTML
>>
>> Cheers
>> Petr
>>
>> > -----Original Message-----
>> > From: R-help <[hidden email]> On Behalf Of lily li
>> > Sent: Wednesday, September 12, 2018 8:55 AM
>> > To: R mailing list <[hidden email]>
>> > Subject: [R] how to plot gridded data
>> >
>> > Hi R users,
>> >
>> > I have a question about plotting gridded data. I have the files
>> separately, but do
>> > not know how to combine them. For example, each txt file has daily
>> > precipitation data at a specific grid cell, named pr_lat_lon.txt. How
>> to plot all
>> > txt files for one surface (which is rectangular in this case), or how
>> to combine
>> > the txt files together? Thanks.
>> >
>> > [[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/posti
>> ng-guide.html
>> > and provide commented, minimal, self-contained, reproducible code.
>> Osobní údaje: Informace o zpracování a ochraně osobních údajů obchodních
>> partnerů PRECHEZA a.s. jsou zveřejněny na: https://www.precheza.cz/zasady
>> -ochrany-osobnich-udaju/ | Information about processing and protection
>> of business partner’s personal data are available on website:
>> https://www.precheza.cz/en/personal-data-protection-principles/
>> Důvěrnost: Tento e-mail a jakékoliv k němu připojené dokumenty jsou
>> důvěrné a podléhají tomuto právně závaznému prohláąení o vyloučení
>> odpovědnosti: https://www.precheza.cz/01-dovetek/ | This email and any
>> documents attached to it may be confidential and are subject to the legally
>> binding disclaimer: https://www.precheza.cz/en/01-disclaimer/
>>
>>
>

        [[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: how to plot gridded data

R help mailing list-2
In reply to this post by lily li
Hi Lily:

I haven't used it to any extent to give you specifics,  but I strongly suggest you look at the package sf,  it is designed to do these sorts of things.  sf can read in the shapefile,  and it has features to covert the dataframe you describe to one of its objects,  and to combine objects.  There are even plotting functions I believe,  or if not there is a ggplot2::geom_sf()

HTH,

-Roy


> On Sep 13, 2018, at 7:02 PM, lily li <[hidden email]> wrote:
>
> Hi Petr,
>
> I have merged the data using cbind. The dataset is like this:
> DF
> lat1_lon1  lat1_lon2  lat1_lon3  ...  lat2_lon1
>  1.20           1.30          2.11      ...     1.28
>  1.50           1.81          3.12      ...     2.34
>  2.41           2.22          1.56      ...     2.50
>  3.11           4.21          2.12      ...     3.21
>
> The other file is a shapfile, which I can open using readOGR. Then it shows
> a polygon according to geographical latitude and longitude in degrees. How
> to overlay the values in DF onto the polygon? note that DF has the
> coordinates for a rectangular box that includes the shapefile, but is
> larger. I don't know how to do this. Thanks for your help.
>
> On Wed, Sep 12, 2018 at 3:22 PM, PIKAL Petr <[hidden email]> wrote:
>
>> Hi
>>
>> 1. Read files/lines into R ?read.table, ?read.lines
>> 2. Merge files according to your specification ?merge, ?rbind
>> 3. Plot values by suitable command(s) ?plot, ?ggplot
>> 4. If you want more specific answer, please post more specific question,
>> preferably with concise and clear example.
>> 5. Avoid posting in HTML
>>
>> Cheers
>> Petr
>>
>>> -----Original Message-----
>>> From: R-help <[hidden email]> On Behalf Of lily li
>>> Sent: Wednesday, September 12, 2018 8:55 AM
>>> To: R mailing list <[hidden email]>
>>> Subject: [R] how to plot gridded data
>>>
>>> Hi R users,
>>>
>>> I have a question about plotting gridded data. I have the files
>> separately, but do
>>> not know how to combine them. For example, each txt file has daily
>>> precipitation data at a specific grid cell, named pr_lat_lon.txt. How to
>> plot all
>>> txt files for one surface (which is rectangular in this case), or how to
>> combine
>>> the txt files together? Thanks.
>>>
>>> [[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.
>> Osobní údaje: Informace o zpracování a ochraně osobních údajů obchodních
>> partnerů PRECHEZA a.s. jsou zveřejněny na: https://www.precheza.cz/
>> zasady-ochrany-osobnich-udaju/ | Information about processing and
>> protection of business partner’s personal data are available on website:
>> https://www.precheza.cz/en/personal-data-protection-principles/
>> Důvěrnost: Tento e-mail a jakékoliv k němu připojené dokumenty jsou
>> důvěrné a podléhají tomuto právně závaznému prohláąení o vyloučení
>> odpovědnosti: https://www.precheza.cz/01-dovetek/ | This email and any
>> documents attached to it may be confidential and are subject to the legally
>> binding disclaimer: https://www.precheza.cz/en/01-disclaimer/
>>
>>
>
> [[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.

**********************
"The contents of this message do not reflect any position of the U.S. Government or NOAA."
**********************
Roy Mendelssohn
Supervisory Operations Research Analyst
NOAA/NMFS
Environmental Research Division
Southwest Fisheries Science Center
***Note new street address***
110 McAllister Way
Santa Cruz, CA 95060
Phone: (831)-420-3666
Fax: (831) 420-3980
e-mail: [hidden email] www: http://www.pfeg.noaa.gov/

"Old age and treachery will overcome youth and skill."
"From those who have been given much, much will be expected"
"the arc of the moral universe is long, but it bends toward justice" -MLK Jr.

______________________________________________
[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: how to plot gridded data

Bert Gunter-2
In reply to this post by lily li
You may wish to consider posting on r-sig-geo, where you may be more
likely to find expertise for this sort of thing.
-- 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 Thu, Sep 13, 2018 at 7:08 PM lily li <[hidden email]> wrote:

>
> Hi Petr,
>
> I have merged the data using cbind. The dataset is like this:
> DF
> lat1_lon1  lat1_lon2  lat1_lon3  ...  lat2_lon1
>   1.20           1.30          2.11      ...     1.28
>   1.50           1.81          3.12      ...     2.34
>   2.41           2.22          1.56      ...     2.50
>   3.11           4.21          2.12      ...     3.21
>
> The other file is a shapfile, which I can open using readOGR. Then it shows
> a polygon according to geographical latitude and longitude in degrees. How
> to overlay the values in DF onto the polygon? note that DF has the
> coordinates for a rectangular box that includes the shapefile, but is
> larger. I don't know how to do this. Thanks for your help.
>
> On Wed, Sep 12, 2018 at 3:22 PM, PIKAL Petr <[hidden email]> wrote:
>
> > Hi
> >
> > 1. Read files/lines into R ?read.table, ?read.lines
> > 2. Merge files according to your specification ?merge, ?rbind
> > 3. Plot values by suitable command(s) ?plot, ?ggplot
> > 4. If you want more specific answer, please post more specific question,
> > preferably with concise and clear example.
> > 5. Avoid posting in HTML
> >
> > Cheers
> > Petr
> >
> > > -----Original Message-----
> > > From: R-help <[hidden email]> On Behalf Of lily li
> > > Sent: Wednesday, September 12, 2018 8:55 AM
> > > To: R mailing list <[hidden email]>
> > > Subject: [R] how to plot gridded data
> > >
> > > Hi R users,
> > >
> > > I have a question about plotting gridded data. I have the files
> > separately, but do
> > > not know how to combine them. For example, each txt file has daily
> > > precipitation data at a specific grid cell, named pr_lat_lon.txt. How to
> > plot all
> > > txt files for one surface (which is rectangular in this case), or how to
> > combine
> > > the txt files together? Thanks.
> > >
> > > [[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.
> > Osobní údaje: Informace o zpracování a ochraně osobních údajů obchodních
> > partnerů PRECHEZA a.s. jsou zveřejněny na: https://www.precheza.cz/
> > zasady-ochrany-osobnich-udaju/ | Information about processing and
> > protection of business partner’s personal data are available on website:
> > https://www.precheza.cz/en/personal-data-protection-principles/
> > Důvěrnost: Tento e-mail a jakékoliv k němu připojené dokumenty jsou
> > důvěrné a podléhají tomuto právně závaznému prohláąení o vyloučení
> > odpovědnosti: https://www.precheza.cz/01-dovetek/ | This email and any
> > documents attached to it may be confidential and are subject to the legally
> > binding disclaimer: https://www.precheza.cz/en/01-disclaimer/
> >
> >
>
>         [[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.

______________________________________________
[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.