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: 58 min 44 sec ago

Re: [FORGED] Modifying the length of a matrix variable

Sat, 03/30/2019 - 15:57

On 31/03/19 10:22 AM, [hidden email] wrote:

> Hi Rolf,
>
> My apologies - I meant "layers" as opposed to "length". The goal is to
> reduce the number of layers to 90 (from 95).
>
> dim (Model4) yields:
>
> 64   128   95
>
>
> You can see the 95 there. That is what I would like to reduce to 90, or
> isolate layer 1 to layer 90.
Please keep the list in the set of recipients.  I am not your private
consultant, and furthermore others on the list may be able to provide
better advice than I.  I have CC-ed this message to the list.

To keep only "layers" 1 through 90 you could do:

     Model4.chopped <- Model4[,,1:90]

As I said before, it really is time that you learned something about R
(e.g. by studying a tutorial).

cheers,

Rolf

--
Honorary Research Fellow
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

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

Re: [FORGED] Modifying the length of a matrix variable

Sat, 03/30/2019 - 15:12

On 31/03/19 3:56 AM, rain1290--- via R-sig-Geo wrote:

> Hello there, I am currently trying to modify a variable's length. It
> is called "Model4" and is a matrix. It currently has the length of
> 95, as per "length(Model4)". However, I would like to create a new
> Model4 (let's say "NewModel4"), in which it has a length of 90,
> instead of 95. Is there a way to do this? Thanks, and any assistance
> would be greatly appreciated! [[alternative HTML version deleted]]

This is a plain text mailing list.  Please *DO NOT* post in HTML.
(In general this scrambles your post and makes it incomprehensible.)

To get to your question:  What you ask makes little sense.  The "length"
of a matrix is the total number of entries --- nrow(<matrix>) *
ncol(<matrix>).  Changing the "length" of a matrix would either involve
changing the number of rows or the number of columns (or both).

Why do you want to do this?  What are you trying to accomplish?
What does dim(Model4) produce?

Don't you think it's time you got serious and learned a bit about R?
(There are many excellent introductory documents available online.)

cheers,

Rolf Turner

--
Honorary Research Fellow
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

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

Modifying the length of a matrix variable

Sat, 03/30/2019 - 08:56
Hello there,
I am currently trying to modify a variable's length. It is called "Model4" and is a matrix. It currently has the length of 95, as per "length(Model4)". However, I would like to create a new Model4 (let's say "NewModel4"), in which it has a length of 90, instead of 95.
Is there a way to do this? 
Thanks, and any assistance would be greatly appreciated!  
        [[alternative HTML version deleted]]

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

Re: Converting a variable's units from gigatons to teratons

Thu, 03/28/2019 - 10:03
ncvar_get() should return a data frame, so just

get2.teratons <- get2 / 1000

Even if it's a higher-dimensional array, that will work.

You could then write it back with ncvar_put(), subject to the data
type of that variable in the NetCDF file.

Sarah


On Thu, Mar 28, 2019 at 11:55 AM rain1290--- via R-sig-Geo
<[hidden email]> wrote:
>
> Hi there,
> I am currently working with a variable whose units are expressed in gigatons. However, I would like to convert all of these values in this variable to teratons. Effectively, I would have to somehow have R divide all values (90 values) within the variable by 1000.
> So far, I have read in the variable (called CanESM2) as follows:
> ncfname1 <- "cumulative_emissions_RCP45.nc"
> Model3 <- nc_open(ncfname1)
> get2 <- ncvar_get(Model3, "CanESM2")
> Is there a way to accomplish this conversion?
> Thanks, and any assistance would be greatly appreciated!
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo


--
Sarah Goslee (she/her)
http://www.numberwright.com

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

Converting a variable's units from gigatons to teratons

Thu, 03/28/2019 - 09:55
Hi there,
I am currently working with a variable whose units are expressed in gigatons. However, I would like to convert all of these values in this variable to teratons. Effectively, I would have to somehow have R divide all values (90 values) within the variable by 1000.
So far, I have read in the variable (called CanESM2) as follows:
ncfname1 <- "cumulative_emissions_RCP45.nc"
Model3 <- nc_open(ncfname1)
get2 <- ncvar_get(Model3, "CanESM2")
Is there a way to accomplish this conversion?
Thanks, and any assistance would be greatly appreciated!

        [[alternative HTML version deleted]]

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

select points out of a polygon

Tue, 03/26/2019 - 15:46
Dear list members

I have a spatial point data frame (spt.points) and a spatial polygon data
frame (spt.poly).

With spt.points[spt.poly,] I can select the points that overlap the polygon.

How can I get the points that do not overlap the polygon?

Thanks a lot.

All the best,

Antônio Olinto Ávila da Silva
São Paulo, Brasil

        [[alternative HTML version deleted]]

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

Re: Plotting x and y values using data from two separate netCDF files in R

Tue, 03/26/2019 - 15:35
Thanks, again. 
It's strange, as the variable "ncfname" is reading off the original file name "cumulative_emissions_1pctCO2.nc", and yet, it says that it cannot find the variable"cum_co2_emi-CanESM2 (and that is the correct variable name with no typos).  


-----Original Message-----
From: Michael Sumner <[hidden email]>
To: rain1290 <[hidden email]>
Cc: r-sig-geo <[hidden email]>
Sent: Tue, Mar 26, 2019 5:10 pm
Subject: Re: [R-sig-Geo] Plotting x and y values using data from two separate netCDF files in R

Use the file name as the first argument, and the variable name you want as varname = 
Raster doesn't work with output of nc_open
See ?brick
Good luck

On Wed, Mar 27, 2019, 08:05 <[hidden email]> wrote:

Hi Michael,
Thank you so much for your reply! 
I was just trying your suggestion, but when I run the following in R:

x<-raster::brick(ncfname, varname="cum_co2_emi-CanESM2")

I receive the following error:
Error in .varName(nc, varname, warn = warn) :
  varname: cum_co2_emi-CanESM2 does not exist in the file. Select one from:

I tried switching "ncfname" with "Model1", but I then receive this error:
Error in (function (classes, fdef, mtable)  :
  unable to find an inherited method for function ‘brick’ for signature ‘"ncdf4"’
Is there a reason for that?
Thanks, again,

-----Original Message-----
From: Michael Sumner <[hidden email]>
To: rain1290 <[hidden email]>
Cc: r-sig-geo <[hidden email]>
Sent: Tue, Mar 26, 2019 4:34 pm
Subject: Re: [R-sig-Geo] Plotting x and y values using data from two separate netCDF files in R

I would try for a single point: 
x <- raster::brick(ncfname, varname = "cum_co2_emi-CanESM2")y <- raster::brick(ncfname1, varname = "onedaymax")
pt <- cbind(30, -5)to_plot <- cbind(raster::extract(x, pt), raster::extract(y, pt))
plot(to_plot)
Is that close?  You might be better off using raster::as.data.frame(x, xy = TRUE, long = TRUE) if you want all locations at their actual centre. 
See if the times of the 3rd axis are valid (and the same) in getZ(x) and getZ(y). 
There's rarely a need to use ncdf4 directly, though that's important sometimes, more so for grids that raster's regular-affine referencing model doesn't support. 
cheers, Mike


On Wed, 27 Mar 2019 at 05:29 rain1290--- via R-sig-Geo <[hidden email]> wrote:

Hi there,
I am currently trying to plot precipitation data (y-axis values) with cumulative emissions data (x-axis) using R. Both of these data are found on two separate netCDF files that I have already read into R. Ultimately, What I would like to do is plot precipitation as a function of cumulative emissions for a selected location (as shown below in the following code). I have, so far, used the following code (with "#" to highlight each step):     library(raster)
    library(ncdf4)
    library(maps)
    library(maptools)
    library(rasterVis)
    library(ggplot2)
    library(rgdal)
    library(sp)    #Geting cumulative emissions data for x-axis       ncfname<-"cumulative_emissions_1pctCO2.nc"
    Model1<-nc_open(ncfname)
    print(Model1)
    get<-ncvar_get(Model1, "cum_co2_emi-CanESM2") #units of terratones of  
    carbon (TtC) for x-axis (140 values)
    print(get)
    Year<-ncvar_get(Model1, "time") #140 years
 #Getting Model data for extreme precipitation (units of millimeters/day) for y-axis       ncfname1<-"MaxPrecCCCMACanESM21pctCO2.nc"
    Model2<-nc_open(ncfname1)
    print(Model2)
    get1<-ncvar_get(Model2, "onedaymax") #units of millimeters/day
    print(get1)
    #Reading in latitude, longitude and time from this file:
        latitude<-ncvar_get(Model2, "lat") #64 degrees latitude
    longitude<-ncvar_get(Model2, "lon") #128 degrees longitude
    Year1<-ncvar_get(Model2, "Year") #140 years
    #Plotting attempt        randompointlon<-30 #selecting a longitude
    randompointlat<--5 #selecting a latitude
    Hope<-extract(r_brick,
    SpatialPoints(cbind(randompointlon,randompointlat)),method='simple')
    df<-data.frame(cumulativeemissions=seq(from=1, to=140, by=1),  
    Precipitation=t(Hope))
    ggplot(data=df, aes(x=get, y=Precipitation,
    group=1))+geom_line()+ggtitle("One-day maximum precipitation (mm/day)  
    for random location for CanESM2 1pctCO2 as a function of cumulative
    emissions")
print(Model1) yields the following (I read in variable #2 for now):
File cumulative_emissions_1pctCO2.nc (NC_FORMAT_NETCDF4):
14 variables (excluding dimension variables):
                float cum_co2_emi-BNU-ESM[time]   (Contiguous storage) 
            long_name: Cumulative carbon emissions for BNU-ESM
            units: Tt C
        float cum_co2_emi-CanESM2[time]   (Contiguous storage) 
            long_name: Cumulative carbon emissions for CanESM2
            units: Tt C
        float cum_co2_emi-CESM1-BGC[time]   (Contiguous storage) 
            long_name: Cumulative carbon emissions for CESM1-BGC
            units: Tt C
        float cum_co2_emi-HadGEM2-ES[time]   (Contiguous storage) 
            long_name: Cumulative carbon emissions for HadGEM2-ES
            units: Tt C
        float cum_co2_emi-inmcm4[time]   (Contiguous storage) 
            long_name: Cumulative carbon emissions for inmcm4
            units: Tt C
        float cum_co2_emi-IPSL-CM5A-LR[time]   (Contiguous storage) 
            long_name: Cumulative carbon emissions for IPSL-CM5A-LR
            units: Tt C
        float cum_co2_emi-IPSL-CM5A-MR[time]   (Contiguous storage) 
            long_name: Cumulative carbon emissions for IPSL-CM5A-MR
            units: Tt C
        float cum_co2_emi-IPSL-CM5B-LR[time]   (Contiguous storage) 
            long_name: Cumulative carbon emissions for IPSL-CM5B-LR
            units: Tt C
        float cum_co2_emi-MIROC-ESM[time]   (Contiguous storage) 
            long_name: Cumulative carbon emissions for MIROC-ESM
            units: Tt C
        float cum_co2_emi-MPI-ESM-LR[time]   (Contiguous storage) 
            long_name: Cumulative carbon emissions for MPI-ESM-LR
            units: Tt C
        float cum_co2_emi-MPI-ESM-MR[time]   (Contiguous storage) 
            long_name: Cumulative carbon emissions for MPI-ESM-MR
            units: Tt C
        float cum_co2_emi-NorESM1-ME[time]   (Contiguous storage) 
            long_name: Cumulative carbon emissions for NorESM1-ME
            units: Tt C
        float cum_co2_emi-GFDL-ESM2G[time]   (Contiguous storage) 
            long_name: Cumulative carbon emissions for GFDL-ESM2G
            units: Tt C
        float cum_co2_emi-GFDL-ESM2M[time]   (Contiguous storage) 
            long_name: Cumulative carbon emissions for GFDL-ESM2M
            units: Tt C     1 dimensions:
        time  Size:140
            units: years since 0-1-1 0:0:0
            long_name: time
            standard_name: time
            calender: noleap   4 global attributes:
        description: Cumulative carbon emissions for the 1pctCO2 scenario from the CMIP5 dataset.
        history: Created Fri Jul 21 14:50:39 2017
        source: CMIP5 archieve
       
print(Model2) yields the following:File MaxPrecCCCMACanESM21pctCO2.nc (NC_FORMAT_NETCDF4):     3 variables (excluding dimension variables):
        double onedaymax[lon,lat,time]   (Contiguous storage) 
            units: mm/day
        double fivedaymax[lon,lat,time]   (Contiguous storage) 
            units: mm/day
        short Year[time]   (Contiguous storage)       3 dimensions:
        time  Size:140
        lat  Size:64
            units: degree North
        lon  Size:128
            units: degree East      3 global attributes:
        description: Annual global maximum precipitation from the CanESM2 1pctCO2 scenario
        history: Created Mon Jun  4 11:24:02 2018
        contact: [hidden email]
So, in general, this is what I am trying to achieve, but I am not sure if what I am doing in the ggplot function is the right approach for this.
Any assistance with this would be greatly appreciated!
Thanks,
        [[alternative HTML version deleted]]

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

--
Dr. Michael Sumner
Software and Database Engineer
Australian Antarctic Division
203 Channel Highway
Kingston Tasmania 7050 Australia


--
Dr. Michael Sumner
Software and Database Engineer
Australian Antarctic Division
203 Channel Highway
Kingston Tasmania 7050 Australia


        [[alternative HTML version deleted]]

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

Re: Plotting x and y values using data from two separate netCDF files in R

Tue, 03/26/2019 - 15:09
Use the file name as the first argument, and the variable name you want as
varname =

Raster doesn't work with output of nc_open

See ?brick

Good luck

On Wed, Mar 27, 2019, 08:05 <[hidden email]> wrote:

> Hi Michael,
>
> Thank you so much for your reply!
>
> I was just trying your suggestion, but when I run the following in R:
>
>
> x<-raster::brick(ncfname, varname="cum_co2_emi-CanESM2")
>
> I receive the following error:
>
> Error in .varName(nc, varname, warn = warn) :
>   varname: cum_co2_emi-CanESM2 does not exist in the file. Select one from:
>
>
>
> I tried switching "ncfname" with "Model1", but I then receive this error:
>
> Error in (function (classes, fdef, mtable)  :
>   unable to find an inherited method for function ‘brick’ for signature ‘"ncdf4"’
>
>
> Is there a reason for that?
>
> Thanks, again,
>
> -----Original Message-----
> From: Michael Sumner <[hidden email]>
> To: rain1290 <[hidden email]>
> Cc: r-sig-geo <[hidden email]>
> Sent: Tue, Mar 26, 2019 4:34 pm
> Subject: Re: [R-sig-Geo] Plotting x and y values using data from two
> separate netCDF files in R
>
> I would try for a single point:
>
> x <- raster::brick(ncfname, varname = "cum_co2_emi-CanESM2")
> y <- raster::brick(ncfname1, varname = "onedaymax")
>
> pt <- cbind(30, -5)
> to_plot <- cbind(raster::extract(x, pt), raster::extract(y, pt))
>
> plot(to_plot)
>
> Is that close?  You might be better off using raster::as.data.frame(x, xy
> = TRUE, long = TRUE) if you want all locations at their actual centre.
>
> See if the times of the 3rd axis are valid (and the same) in getZ(x) and
> getZ(y).
>
> There's rarely a need to use ncdf4 directly, though that's important
> sometimes, more so for grids that raster's regular-affine referencing model
> doesn't support.
>
> cheers, Mike
>
>
>
> On Wed, 27 Mar 2019 at 05:29 rain1290--- via R-sig-Geo <
> [hidden email]> wrote:
>
> Hi there,
> I am currently trying to plot precipitation data (y-axis values) with
> cumulative emissions data (x-axis) using R. Both of these data are found on
> two separate netCDF files that I have already read into R. Ultimately, What
> I would like to do is plot precipitation as a function of cumulative
> emissions for a selected location (as shown below in the following code). I
> have, so far, used the following code (with "#" to highlight each step):
>   library(raster)
>     library(ncdf4)
>     library(maps)
>     library(maptools)
>     library(rasterVis)
>     library(ggplot2)
>     library(rgdal)
>     library(sp)    #Geting cumulative emissions data for x-axis
> ncfname<-"cumulative_emissions_1pctCO2.nc"
>     Model1<-nc_open(ncfname)
>     print(Model1)
>     get<-ncvar_get(Model1, "cum_co2_emi-CanESM2") #units of terratones
> of
>     carbon (TtC) for x-axis (140 values)
>     print(get)
>     Year<-ncvar_get(Model1, "time") #140 years
>  #Getting Model data for extreme precipitation (units of millimeters/day)
> for y-axis       ncfname1<-"MaxPrecCCCMACanESM21pctCO2.nc"
>     Model2<-nc_open(ncfname1)
>     print(Model2)
>     get1<-ncvar_get(Model2, "onedaymax") #units of millimeters/day
>     print(get1)
>     #Reading in latitude, longitude and time from this file:
>         latitude<-ncvar_get(Model2, "lat") #64 degrees latitude
>     longitude<-ncvar_get(Model2, "lon") #128 degrees longitude
>     Year1<-ncvar_get(Model2, "Year") #140 years
>     #Plotting attempt        randompointlon<-30 #selecting a longitude
>     randompointlat<--5 #selecting a latitude
>     Hope<-extract(r_brick,
>     SpatialPoints(cbind(randompointlon,randompointlat)),method='simple')
>     df<-data.frame(cumulativeemissions=seq(from=1, to=140, by=1),
>     Precipitation=t(Hope))
>     ggplot(data=df, aes(x=get, y=Precipitation,
>     group=1))+geom_line()+ggtitle("One-day maximum precipitation
> (mm/day)
>     for random location for CanESM2 1pctCO2 as a function of cumulative
>     emissions")
> print(Model1) yields the following (I read in variable #2 for now):
> File cumulative_emissions_1pctCO2.nc (NC_FORMAT_NETCDF4):
> 14 variables (excluding dimension variables):
>                 float cum_co2_emi-BNU-ESM[time]   (Contiguous storage)
>             long_name: Cumulative carbon emissions for BNU-ESM
>             units: Tt C
>         float cum_co2_emi-CanESM2[time]   (Contiguous storage)
>             long_name: Cumulative carbon emissions for CanESM2
>             units: Tt C
>         float cum_co2_emi-CESM1-BGC[time]   (Contiguous storage)
>             long_name: Cumulative carbon emissions for CESM1-BGC
>             units: Tt C
>         float cum_co2_emi-HadGEM2-ES[time]   (Contiguous storage)
>             long_name: Cumulative carbon emissions for HadGEM2-ES
>             units: Tt C
>         float cum_co2_emi-inmcm4[time]   (Contiguous storage)
>             long_name: Cumulative carbon emissions for inmcm4
>             units: Tt C
>         float cum_co2_emi-IPSL-CM5A-LR[time]   (Contiguous storage)
>             long_name: Cumulative carbon emissions for IPSL-CM5A-LR
>             units: Tt C
>         float cum_co2_emi-IPSL-CM5A-MR[time]   (Contiguous storage)
>             long_name: Cumulative carbon emissions for IPSL-CM5A-MR
>             units: Tt C
>         float cum_co2_emi-IPSL-CM5B-LR[time]   (Contiguous storage)
>             long_name: Cumulative carbon emissions for IPSL-CM5B-LR
>             units: Tt C
>         float cum_co2_emi-MIROC-ESM[time]   (Contiguous storage)
>             long_name: Cumulative carbon emissions for MIROC-ESM
>             units: Tt C
>         float cum_co2_emi-MPI-ESM-LR[time]   (Contiguous storage)
>             long_name: Cumulative carbon emissions for MPI-ESM-LR
>             units: Tt C
>         float cum_co2_emi-MPI-ESM-MR[time]   (Contiguous storage)
>             long_name: Cumulative carbon emissions for MPI-ESM-MR
>             units: Tt C
>         float cum_co2_emi-NorESM1-ME[time]   (Contiguous storage)
>             long_name: Cumulative carbon emissions for NorESM1-ME
>             units: Tt C
>         float cum_co2_emi-GFDL-ESM2G[time]   (Contiguous storage)
>             long_name: Cumulative carbon emissions for GFDL-ESM2G
>             units: Tt C
>         float cum_co2_emi-GFDL-ESM2M[time]   (Contiguous storage)
>             long_name: Cumulative carbon emissions for GFDL-ESM2M
>             units: Tt C     1 dimensions:
>         time  Size:140
>             units: years since 0-1-1 0:0:0
>             long_name: time
>             standard_name: time
>             calender: noleap   4 global attributes:
>         description: Cumulative carbon emissions for the 1pctCO2 scenario
> from the CMIP5 dataset.
>         history: Created Fri Jul 21 14:50:39 2017
>         source: CMIP5 archieve
>
> print(Model2) yields the following:File MaxPrecCCCMACanESM21pctCO2.nc
> (NC_FORMAT_NETCDF4):     3 variables (excluding dimension variables):
>         double onedaymax[lon,lat,time]   (Contiguous storage)
>             units: mm/day
>         double fivedaymax[lon,lat,time]   (Contiguous storage)
>             units: mm/day
>         short Year[time]   (Contiguous storage)       3 dimensions:
>         time  Size:140
>         lat  Size:64
>             units: degree North
>         lon  Size:128
>             units: degree East      3 global attributes:
>         description: Annual global maximum precipitation from the CanESM2
> 1pctCO2 scenario
>         history: Created Mon Jun  4 11:24:02 2018
>         contact: [hidden email]
> So, in general, this is what I am trying to achieve, but I am not sure if
> what I am doing in the ggplot function is the right approach for this.
> Any assistance with this would be greatly appreciated!
> Thanks,
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
> --
> Dr. Michael Sumner
> Software and Database Engineer
> Australian Antarctic Division
> 203 Channel Highway
> <https://maps.google.com/?q=203+Channel+Highway+Kingston+Tasmania+7050+Australia&entry=gmail&source=g>
> Kingston Tasmania 7050 Australia
> <https://maps.google.com/?q=203+Channel+Highway+Kingston+Tasmania+7050+Australia&entry=gmail&source=g>
>
> -- Dr. Michael Sumner
Software and Database Engineer
Australian Antarctic Division
203 Channel Highway
Kingston Tasmania 7050 Australia

        [[alternative HTML version deleted]]

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

Re: Plotting x and y values using data from two separate netCDF files in R

Tue, 03/26/2019 - 15:05
Hi Michael,
Thank you so much for your reply! 
I was just trying your suggestion, but when I run the following in R:

x<-raster::brick(ncfname, varname="cum_co2_emi-CanESM2")

I receive the following error:
Error in .varName(nc, varname, warn = warn) :
  varname: cum_co2_emi-CanESM2 does not exist in the file. Select one from:

I tried switching "ncfname" with "Model1", but I then receive this error:
Error in (function (classes, fdef, mtable)  :
  unable to find an inherited method for function ‘brick’ for signature ‘"ncdf4"’
Is there a reason for that?
Thanks, again,

-----Original Message-----
From: Michael Sumner <[hidden email]>
To: rain1290 <[hidden email]>
Cc: r-sig-geo <[hidden email]>
Sent: Tue, Mar 26, 2019 4:34 pm
Subject: Re: [R-sig-Geo] Plotting x and y values using data from two separate netCDF files in R

I would try for a single point: 
x <- raster::brick(ncfname, varname = "cum_co2_emi-CanESM2")y <- raster::brick(ncfname1, varname = "onedaymax")
pt <- cbind(30, -5)to_plot <- cbind(raster::extract(x, pt), raster::extract(y, pt))
plot(to_plot)
Is that close?  You might be better off using raster::as.data.frame(x, xy = TRUE, long = TRUE) if you want all locations at their actual centre. 
See if the times of the 3rd axis are valid (and the same) in getZ(x) and getZ(y). 
There's rarely a need to use ncdf4 directly, though that's important sometimes, more so for grids that raster's regular-affine referencing model doesn't support. 
cheers, Mike


On Wed, 27 Mar 2019 at 05:29 rain1290--- via R-sig-Geo <[hidden email]> wrote:

Hi there,
I am currently trying to plot precipitation data (y-axis values) with cumulative emissions data (x-axis) using R. Both of these data are found on two separate netCDF files that I have already read into R. Ultimately, What I would like to do is plot precipitation as a function of cumulative emissions for a selected location (as shown below in the following code). I have, so far, used the following code (with "#" to highlight each step):     library(raster)
    library(ncdf4)
    library(maps)
    library(maptools)
    library(rasterVis)
    library(ggplot2)
    library(rgdal)
    library(sp)    #Geting cumulative emissions data for x-axis       ncfname<-"cumulative_emissions_1pctCO2.nc"
    Model1<-nc_open(ncfname)
    print(Model1)
    get<-ncvar_get(Model1, "cum_co2_emi-CanESM2") #units of terratones of  
    carbon (TtC) for x-axis (140 values)
    print(get)
    Year<-ncvar_get(Model1, "time") #140 years
 #Getting Model data for extreme precipitation (units of millimeters/day) for y-axis       ncfname1<-"MaxPrecCCCMACanESM21pctCO2.nc"
    Model2<-nc_open(ncfname1)
    print(Model2)
    get1<-ncvar_get(Model2, "onedaymax") #units of millimeters/day
    print(get1)
    #Reading in latitude, longitude and time from this file:
        latitude<-ncvar_get(Model2, "lat") #64 degrees latitude
    longitude<-ncvar_get(Model2, "lon") #128 degrees longitude
    Year1<-ncvar_get(Model2, "Year") #140 years
    #Plotting attempt        randompointlon<-30 #selecting a longitude
    randompointlat<--5 #selecting a latitude
    Hope<-extract(r_brick,
    SpatialPoints(cbind(randompointlon,randompointlat)),method='simple')
    df<-data.frame(cumulativeemissions=seq(from=1, to=140, by=1),  
    Precipitation=t(Hope))
    ggplot(data=df, aes(x=get, y=Precipitation,
    group=1))+geom_line()+ggtitle("One-day maximum precipitation (mm/day)  
    for random location for CanESM2 1pctCO2 as a function of cumulative
    emissions")
print(Model1) yields the following (I read in variable #2 for now):
File cumulative_emissions_1pctCO2.nc (NC_FORMAT_NETCDF4):
14 variables (excluding dimension variables):
                float cum_co2_emi-BNU-ESM[time]   (Contiguous storage) 
            long_name: Cumulative carbon emissions for BNU-ESM
            units: Tt C
        float cum_co2_emi-CanESM2[time]   (Contiguous storage) 
            long_name: Cumulative carbon emissions for CanESM2
            units: Tt C
        float cum_co2_emi-CESM1-BGC[time]   (Contiguous storage) 
            long_name: Cumulative carbon emissions for CESM1-BGC
            units: Tt C
        float cum_co2_emi-HadGEM2-ES[time]   (Contiguous storage) 
            long_name: Cumulative carbon emissions for HadGEM2-ES
            units: Tt C
        float cum_co2_emi-inmcm4[time]   (Contiguous storage) 
            long_name: Cumulative carbon emissions for inmcm4
            units: Tt C
        float cum_co2_emi-IPSL-CM5A-LR[time]   (Contiguous storage) 
            long_name: Cumulative carbon emissions for IPSL-CM5A-LR
            units: Tt C
        float cum_co2_emi-IPSL-CM5A-MR[time]   (Contiguous storage) 
            long_name: Cumulative carbon emissions for IPSL-CM5A-MR
            units: Tt C
        float cum_co2_emi-IPSL-CM5B-LR[time]   (Contiguous storage) 
            long_name: Cumulative carbon emissions for IPSL-CM5B-LR
            units: Tt C
        float cum_co2_emi-MIROC-ESM[time]   (Contiguous storage) 
            long_name: Cumulative carbon emissions for MIROC-ESM
            units: Tt C
        float cum_co2_emi-MPI-ESM-LR[time]   (Contiguous storage) 
            long_name: Cumulative carbon emissions for MPI-ESM-LR
            units: Tt C
        float cum_co2_emi-MPI-ESM-MR[time]   (Contiguous storage) 
            long_name: Cumulative carbon emissions for MPI-ESM-MR
            units: Tt C
        float cum_co2_emi-NorESM1-ME[time]   (Contiguous storage) 
            long_name: Cumulative carbon emissions for NorESM1-ME
            units: Tt C
        float cum_co2_emi-GFDL-ESM2G[time]   (Contiguous storage) 
            long_name: Cumulative carbon emissions for GFDL-ESM2G
            units: Tt C
        float cum_co2_emi-GFDL-ESM2M[time]   (Contiguous storage) 
            long_name: Cumulative carbon emissions for GFDL-ESM2M
            units: Tt C     1 dimensions:
        time  Size:140
            units: years since 0-1-1 0:0:0
            long_name: time
            standard_name: time
            calender: noleap   4 global attributes:
        description: Cumulative carbon emissions for the 1pctCO2 scenario from the CMIP5 dataset.
        history: Created Fri Jul 21 14:50:39 2017
        source: CMIP5 archieve
       
print(Model2) yields the following:File MaxPrecCCCMACanESM21pctCO2.nc (NC_FORMAT_NETCDF4):     3 variables (excluding dimension variables):
        double onedaymax[lon,lat,time]   (Contiguous storage) 
            units: mm/day
        double fivedaymax[lon,lat,time]   (Contiguous storage) 
            units: mm/day
        short Year[time]   (Contiguous storage)       3 dimensions:
        time  Size:140
        lat  Size:64
            units: degree North
        lon  Size:128
            units: degree East      3 global attributes:
        description: Annual global maximum precipitation from the CanESM2 1pctCO2 scenario
        history: Created Mon Jun  4 11:24:02 2018
        contact: [hidden email]
So, in general, this is what I am trying to achieve, but I am not sure if what I am doing in the ggplot function is the right approach for this.
Any assistance with this would be greatly appreciated!
Thanks,
        [[alternative HTML version deleted]]

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

--
Dr. Michael Sumner
Software and Database Engineer
Australian Antarctic Division
203 Channel Highway
Kingston Tasmania 7050 Australia


        [[alternative HTML version deleted]]

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

Re: Convert map pdf in raster

Tue, 03/26/2019 - 14:48
Thanks a lot!

Michael Sumner <[hidden email]> escreveu no dia terça, 26/03/2019 à(s)
19:43:

> Try
>
>  r <- raster::brick(pdffile)
>
> #(requires rgdal with PDF driver)
>
> raster::plotRGB(r)
>
> Alternatively, try stars::read_stars
>
> HTH
>
> On Wed, Mar 27, 2019, 02:43 Lara Silva <[hidden email]> wrote:
>
>> Hello,
>>
>> Is it possible to convert a map im pdf to a raster?
>> Another question. I need to obtain a raster of land use and land cover of
>> Europe. Which site to choose?
>>
>> Thanks,
>>
>> Lara
>>
>>         [[alternative HTML version deleted]]
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> [hidden email]
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
> --
> Dr. Michael Sumner
> Software and Database Engineer
> Australian Antarctic Division
> 203 Channel Highway
> Kingston Tasmania 7050 Australia
>
>
        [[alternative HTML version deleted]]

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

Re: Convert map pdf in raster

Tue, 03/26/2019 - 14:43
Try

 r <- raster::brick(pdffile)

#(requires rgdal with PDF driver)

raster::plotRGB(r)

Alternatively, try stars::read_stars

HTH

On Wed, Mar 27, 2019, 02:43 Lara Silva <[hidden email]> wrote:

> Hello,
>
> Is it possible to convert a map im pdf to a raster?
> Another question. I need to obtain a raster of land use and land cover of
> Europe. Which site to choose?
>
> Thanks,
>
> Lara
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> --
Dr. Michael Sumner
Software and Database Engineer
Australian Antarctic Division
203 Channel Highway
Kingston Tasmania 7050 Australia

        [[alternative HTML version deleted]]

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

Re: Plotting x and y values using data from two separate netCDF files in R

Tue, 03/26/2019 - 14:33
I would try for a single point:

x <- raster::brick(ncfname, varname = "cum_co2_emi-CanESM2")
y <- raster::brick(ncfname1, varname = "onedaymax")

pt <- cbind(30, -5)
to_plot <- cbind(raster::extract(x, pt), raster::extract(y, pt))

plot(to_plot)

Is that close?  You might be better off using raster::as.data.frame(x, xy =
TRUE, long = TRUE) if you want all locations at their actual centre.

See if the times of the 3rd axis are valid (and the same) in getZ(x) and
getZ(y).

There's rarely a need to use ncdf4 directly, though that's important
sometimes, more so for grids that raster's regular-affine referencing model
doesn't support.

cheers, Mike



On Wed, 27 Mar 2019 at 05:29 rain1290--- via R-sig-Geo <
[hidden email]> wrote:

> Hi there,
> I am currently trying to plot precipitation data (y-axis values) with
> cumulative emissions data (x-axis) using R. Both of these data are found on
> two separate netCDF files that I have already read into R. Ultimately, What
> I would like to do is plot precipitation as a function of cumulative
> emissions for a selected location (as shown below in the following code). I
> have, so far, used the following code (with "#" to highlight each step):
>   library(raster)
>     library(ncdf4)
>     library(maps)
>     library(maptools)
>     library(rasterVis)
>     library(ggplot2)
>     library(rgdal)
>     library(sp)    #Geting cumulative emissions data for x-axis
> ncfname<-"cumulative_emissions_1pctCO2.nc"
>     Model1<-nc_open(ncfname)
>     print(Model1)
>     get<-ncvar_get(Model1, "cum_co2_emi-CanESM2") #units of terratones
> of
>     carbon (TtC) for x-axis (140 values)
>     print(get)
>     Year<-ncvar_get(Model1, "time") #140 years
>  #Getting Model data for extreme precipitation (units of millimeters/day)
> for y-axis       ncfname1<-"MaxPrecCCCMACanESM21pctCO2.nc"
>     Model2<-nc_open(ncfname1)
>     print(Model2)
>     get1<-ncvar_get(Model2, "onedaymax") #units of millimeters/day
>     print(get1)
>     #Reading in latitude, longitude and time from this file:
>         latitude<-ncvar_get(Model2, "lat") #64 degrees latitude
>     longitude<-ncvar_get(Model2, "lon") #128 degrees longitude
>     Year1<-ncvar_get(Model2, "Year") #140 years
>     #Plotting attempt        randompointlon<-30 #selecting a longitude
>     randompointlat<--5 #selecting a latitude
>     Hope<-extract(r_brick,
>     SpatialPoints(cbind(randompointlon,randompointlat)),method='simple')
>     df<-data.frame(cumulativeemissions=seq(from=1, to=140, by=1),
>     Precipitation=t(Hope))
>     ggplot(data=df, aes(x=get, y=Precipitation,
>     group=1))+geom_line()+ggtitle("One-day maximum precipitation
> (mm/day)
>     for random location for CanESM2 1pctCO2 as a function of cumulative
>     emissions")
> print(Model1) yields the following (I read in variable #2 for now):
> File cumulative_emissions_1pctCO2.nc (NC_FORMAT_NETCDF4):
> 14 variables (excluding dimension variables):
>                 float cum_co2_emi-BNU-ESM[time]   (Contiguous storage)
>             long_name: Cumulative carbon emissions for BNU-ESM
>             units: Tt C
>         float cum_co2_emi-CanESM2[time]   (Contiguous storage)
>             long_name: Cumulative carbon emissions for CanESM2
>             units: Tt C
>         float cum_co2_emi-CESM1-BGC[time]   (Contiguous storage)
>             long_name: Cumulative carbon emissions for CESM1-BGC
>             units: Tt C
>         float cum_co2_emi-HadGEM2-ES[time]   (Contiguous storage)
>             long_name: Cumulative carbon emissions for HadGEM2-ES
>             units: Tt C
>         float cum_co2_emi-inmcm4[time]   (Contiguous storage)
>             long_name: Cumulative carbon emissions for inmcm4
>             units: Tt C
>         float cum_co2_emi-IPSL-CM5A-LR[time]   (Contiguous storage)
>             long_name: Cumulative carbon emissions for IPSL-CM5A-LR
>             units: Tt C
>         float cum_co2_emi-IPSL-CM5A-MR[time]   (Contiguous storage)
>             long_name: Cumulative carbon emissions for IPSL-CM5A-MR
>             units: Tt C
>         float cum_co2_emi-IPSL-CM5B-LR[time]   (Contiguous storage)
>             long_name: Cumulative carbon emissions for IPSL-CM5B-LR
>             units: Tt C
>         float cum_co2_emi-MIROC-ESM[time]   (Contiguous storage)
>             long_name: Cumulative carbon emissions for MIROC-ESM
>             units: Tt C
>         float cum_co2_emi-MPI-ESM-LR[time]   (Contiguous storage)
>             long_name: Cumulative carbon emissions for MPI-ESM-LR
>             units: Tt C
>         float cum_co2_emi-MPI-ESM-MR[time]   (Contiguous storage)
>             long_name: Cumulative carbon emissions for MPI-ESM-MR
>             units: Tt C
>         float cum_co2_emi-NorESM1-ME[time]   (Contiguous storage)
>             long_name: Cumulative carbon emissions for NorESM1-ME
>             units: Tt C
>         float cum_co2_emi-GFDL-ESM2G[time]   (Contiguous storage)
>             long_name: Cumulative carbon emissions for GFDL-ESM2G
>             units: Tt C
>         float cum_co2_emi-GFDL-ESM2M[time]   (Contiguous storage)
>             long_name: Cumulative carbon emissions for GFDL-ESM2M
>             units: Tt C     1 dimensions:
>         time  Size:140
>             units: years since 0-1-1 0:0:0
>             long_name: time
>             standard_name: time
>             calender: noleap   4 global attributes:
>         description: Cumulative carbon emissions for the 1pctCO2 scenario
> from the CMIP5 dataset.
>         history: Created Fri Jul 21 14:50:39 2017
>         source: CMIP5 archieve
>
> print(Model2) yields the following:File MaxPrecCCCMACanESM21pctCO2.nc
> (NC_FORMAT_NETCDF4):     3 variables (excluding dimension variables):
>         double onedaymax[lon,lat,time]   (Contiguous storage)
>             units: mm/day
>         double fivedaymax[lon,lat,time]   (Contiguous storage)
>             units: mm/day
>         short Year[time]   (Contiguous storage)       3 dimensions:
>         time  Size:140
>         lat  Size:64
>             units: degree North
>         lon  Size:128
>             units: degree East      3 global attributes:
>         description: Annual global maximum precipitation from the CanESM2
> 1pctCO2 scenario
>         history: Created Mon Jun  4 11:24:02 2018
>         contact: [hidden email]
> So, in general, this is what I am trying to achieve, but I am not sure if
> what I am doing in the ggplot function is the right approach for this.
> Any assistance with this would be greatly appreciated!
> Thanks,
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> --
Dr. Michael Sumner
Software and Database Engineer
Australian Antarctic Division
203 Channel Highway
Kingston Tasmania 7050 Australia

        [[alternative HTML version deleted]]

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

Plotting x and y values using data from two separate netCDF files in R

Tue, 03/26/2019 - 12:29
Hi there,
I am currently trying to plot precipitation data (y-axis values) with cumulative emissions data (x-axis) using R. Both of these data are found on two separate netCDF files that I have already read into R. Ultimately, What I would like to do is plot precipitation as a function of cumulative emissions for a selected location (as shown below in the following code). I have, so far, used the following code (with "#" to highlight each step):     library(raster)
    library(ncdf4)
    library(maps)
    library(maptools)
    library(rasterVis)
    library(ggplot2)
    library(rgdal)
    library(sp)    #Geting cumulative emissions data for x-axis       ncfname<-"cumulative_emissions_1pctCO2.nc"
    Model1<-nc_open(ncfname)
    print(Model1)
    get<-ncvar_get(Model1, "cum_co2_emi-CanESM2") #units of terratones of  
    carbon (TtC) for x-axis (140 values)
    print(get)
    Year<-ncvar_get(Model1, "time") #140 years
 #Getting Model data for extreme precipitation (units of millimeters/day) for y-axis       ncfname1<-"MaxPrecCCCMACanESM21pctCO2.nc"
    Model2<-nc_open(ncfname1)
    print(Model2)
    get1<-ncvar_get(Model2, "onedaymax") #units of millimeters/day
    print(get1)
    #Reading in latitude, longitude and time from this file:
        latitude<-ncvar_get(Model2, "lat") #64 degrees latitude
    longitude<-ncvar_get(Model2, "lon") #128 degrees longitude
    Year1<-ncvar_get(Model2, "Year") #140 years
    #Plotting attempt        randompointlon<-30 #selecting a longitude
    randompointlat<--5 #selecting a latitude
    Hope<-extract(r_brick,
    SpatialPoints(cbind(randompointlon,randompointlat)),method='simple')
    df<-data.frame(cumulativeemissions=seq(from=1, to=140, by=1),  
    Precipitation=t(Hope))
    ggplot(data=df, aes(x=get, y=Precipitation,
    group=1))+geom_line()+ggtitle("One-day maximum precipitation (mm/day)  
    for random location for CanESM2 1pctCO2 as a function of cumulative
    emissions")
print(Model1) yields the following (I read in variable #2 for now):
File cumulative_emissions_1pctCO2.nc (NC_FORMAT_NETCDF4):
14 variables (excluding dimension variables):
                float cum_co2_emi-BNU-ESM[time]   (Contiguous storage) 
            long_name: Cumulative carbon emissions for BNU-ESM
            units: Tt C
        float cum_co2_emi-CanESM2[time]   (Contiguous storage) 
            long_name: Cumulative carbon emissions for CanESM2
            units: Tt C
        float cum_co2_emi-CESM1-BGC[time]   (Contiguous storage) 
            long_name: Cumulative carbon emissions for CESM1-BGC
            units: Tt C
        float cum_co2_emi-HadGEM2-ES[time]   (Contiguous storage) 
            long_name: Cumulative carbon emissions for HadGEM2-ES
            units: Tt C
        float cum_co2_emi-inmcm4[time]   (Contiguous storage) 
            long_name: Cumulative carbon emissions for inmcm4
            units: Tt C
        float cum_co2_emi-IPSL-CM5A-LR[time]   (Contiguous storage) 
            long_name: Cumulative carbon emissions for IPSL-CM5A-LR
            units: Tt C
        float cum_co2_emi-IPSL-CM5A-MR[time]   (Contiguous storage) 
            long_name: Cumulative carbon emissions for IPSL-CM5A-MR
            units: Tt C
        float cum_co2_emi-IPSL-CM5B-LR[time]   (Contiguous storage) 
            long_name: Cumulative carbon emissions for IPSL-CM5B-LR
            units: Tt C
        float cum_co2_emi-MIROC-ESM[time]   (Contiguous storage) 
            long_name: Cumulative carbon emissions for MIROC-ESM
            units: Tt C
        float cum_co2_emi-MPI-ESM-LR[time]   (Contiguous storage) 
            long_name: Cumulative carbon emissions for MPI-ESM-LR
            units: Tt C
        float cum_co2_emi-MPI-ESM-MR[time]   (Contiguous storage) 
            long_name: Cumulative carbon emissions for MPI-ESM-MR
            units: Tt C
        float cum_co2_emi-NorESM1-ME[time]   (Contiguous storage) 
            long_name: Cumulative carbon emissions for NorESM1-ME
            units: Tt C
        float cum_co2_emi-GFDL-ESM2G[time]   (Contiguous storage) 
            long_name: Cumulative carbon emissions for GFDL-ESM2G
            units: Tt C
        float cum_co2_emi-GFDL-ESM2M[time]   (Contiguous storage) 
            long_name: Cumulative carbon emissions for GFDL-ESM2M
            units: Tt C     1 dimensions:
        time  Size:140
            units: years since 0-1-1 0:0:0
            long_name: time
            standard_name: time
            calender: noleap   4 global attributes:
        description: Cumulative carbon emissions for the 1pctCO2 scenario from the CMIP5 dataset.
        history: Created Fri Jul 21 14:50:39 2017
        source: CMIP5 archieve
       
print(Model2) yields the following:File MaxPrecCCCMACanESM21pctCO2.nc (NC_FORMAT_NETCDF4):     3 variables (excluding dimension variables):
        double onedaymax[lon,lat,time]   (Contiguous storage) 
            units: mm/day
        double fivedaymax[lon,lat,time]   (Contiguous storage) 
            units: mm/day
        short Year[time]   (Contiguous storage)       3 dimensions:
        time  Size:140
        lat  Size:64
            units: degree North
        lon  Size:128
            units: degree East      3 global attributes:
        description: Annual global maximum precipitation from the CanESM2 1pctCO2 scenario
        history: Created Mon Jun  4 11:24:02 2018
        contact: [hidden email]
So, in general, this is what I am trying to achieve, but I am not sure if what I am doing in the ggplot function is the right approach for this.
Any assistance with this would be greatly appreciated!
Thanks,
        [[alternative HTML version deleted]]

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

Convert map pdf in raster

Tue, 03/26/2019 - 09:44
Hello,

Is it possible to convert a map im pdf to a raster?
Another question. I need to obtain a raster of land use and land cover of
Europe. Which site to choose?

Thanks,

Lara

        [[alternative HTML version deleted]]

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

Re: GWR Output Attributes

Tue, 03/26/2019 - 06:52
On Tue, 26 Mar 2019, Roger Bivand wrote:

> On Tue, 26 Mar 2019, James Garrett wrote:
>
>>  Dear R-Sig-Geo List,
>>
>>  I am hoping to verify the output variables from a gwr model (package
>>  spgwr). I've searched through the archives and haven't been able to find
>>  exactly what a few are, although I have a strong guess from the package
>>  description:
>>
>>  SDF a SpatialPointsDataFrame (may be gridded) or SpatialPolygonsDataFrame
>>  object (see package "sp") with *fit.points, weights, GWR coefficient
>>  estimates, Rsquared, and coefficient standard errors in its "data" slot.*
>
> There is no need to guess. Help pages have examples. Run:
>
> library(spgwr)
> example(gwr)
> str(col.gauss)
> str(col.gauss$SDF)
> names(col.gauss$SDF)
>
> to examine the contents of the objects of the first run. Note that the rest
> of the example script shows why GWR is unreliable.
I've just used pkgdown to commit the processed help pages of spgwr to
R-Forge:

http://rspatial.r-forge.r-project.org/spgwr/reference/gwr.html#examples

is the rendered version of running example(gwr) yourself, and is less
effective because you can't play with the output.

Roger

>
> Don't guess, don't google or SO, just use the examples in the help pages
> actively, for example changing the formula or argument values to see what the
> arguments do. Do use alternative implementations to check your assumptions,
> such as GWmodel. Do read vignettes: vignette("GWR").
>
> Hope this helps,
>
> Roger
>
>
>>
>>  Is this correct?
>>  sum_w = sum of the weights
>>  Intrc = X Intercept
>>  gtVI(F) = GWR coefficient estimates of the X intercept
>>  gwr_e = gwr residuals
>>  pred = Y prediction
>>  localR2 = local R2.
>>
>>  I apologize if this is rudimentary. Thanks so much in advance,
>>
>>  James
>>
>>
>
>
--
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]
https://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: GWR Output Attributes

Tue, 03/26/2019 - 05:46
On Tue, 26 Mar 2019, James Garrett wrote:

> Dear R-Sig-Geo List,
>
> I am hoping to verify the output variables from a gwr model (package
> spgwr). I've searched through the archives and haven't been able to find
> exactly what a few are, although I have a strong guess from the package
> description:
>
> SDF a SpatialPointsDataFrame (may be gridded) or SpatialPolygonsDataFrame
> object (see package "sp") with *fit.points, weights, GWR coefficient
> estimates, Rsquared, and coefficient standard errors in its "data" slot.*
There is no need to guess. Help pages have examples. Run:

library(spgwr)
example(gwr)
str(col.gauss)
str(col.gauss$SDF)
names(col.gauss$SDF)

to examine the contents of the objects of the first run. Note that the
rest of the example script shows why GWR is unreliable.

Don't guess, don't google or SO, just use the examples in the help pages
actively, for example changing the formula or argument values to see what
the arguments do. Do use alternative implementations to check your
assumptions, such as GWmodel. Do read vignettes: vignette("GWR").

Hope this helps,

Roger


>
> Is this correct?
> sum_w = sum of the weights
> Intrc = X Intercept
> gtVI(F) = GWR coefficient estimates of the X intercept
> gwr_e = gwr residuals
> pred = Y prediction
> localR2 = local R2.
>
> I apologize if this is rudimentary. Thanks so much in advance,
>
> James
>
>
--
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]
https://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

GWR Output Attributes

Mon, 03/25/2019 - 19:23
Dear R-Sig-Geo List,

I am hoping to verify the output variables from a gwr model (package
spgwr). I've searched through the archives and haven't been able to find
exactly what a few are, although I have a strong guess from the package
description:

 SDF a SpatialPointsDataFrame (may be gridded) or SpatialPolygonsDataFrame
object (see package "sp") with *fit.points, weights, GWR coefficient
estimates, Rsquared, and coefficient standard errors in its "data" slot.*

Is this correct?
sum_w = sum of the weights
Intrc = X Intercept
gtVI(F) = GWR coefficient estimates of the X intercept
gwr_e = gwr residuals
pred = Y prediction
localR2 = local R2.

I apologize if this is rudimentary. Thanks so much in advance,

James

--

*James Garrett*

Clemson University

Graduate Student, Forest Resources

School of Agricultural, Forest, and Environmental Sciences

Phone (334)-790-2483

Advisor: Dr. Skip Van Bloem

        [[alternative HTML version deleted]]

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

read error after mosaic_rasters

Mon, 03/25/2019 - 17:08
Hi,

I am using mosaic_rasters from gdalUtils to combine different raster files. More specifically, I am using the 12 tiles that cover Southern Africa from the well-known Hansen et al. (2013) forest map (1.1) that can be downloaded here: http://earthenginepartners.appspot.com/science-2013-global-forest/download_v1.1.html. I am using the tree cover, forest gain and forest loss data. All is working fine for the forest gain and forest loss files but I receive an error when combing the tree cover files (which are the largest).

Below you will find my code. Note that "tree_cover_files" is a vector that points towards the 12 tiles stored in a local folder. I am receiving the following error after some time:

Checking gdal_installation...
Scanning for GDAL installations...
Checking the gdalUtils_gdalPath option...
GDAL version 2.2.4
GDAL command being used: "C:\OSGeo4W64\bin\gdalbuildvrt.exe" -input_file_list "c:\Temp\RtmpkRd30l\file4687024480a.txt" "c:\Temp\RtmpkRd30l\file4684596162f.vrt"
Checking gdal_installation...
Scanning for GDAL installations...
Checking the gdalUtils_gdalPath option...
GDAL version 2.2.4
GDAL command being used: "C:\OSGeo4W64\bin\gdal_translate.exe" -of "GTiff" "c:\Temp\RtmpkRd30l\file4684596162f.vrt" "P:/globiom/Projects/ISWEL/data/forest/combined_tiles/tree_cover.tif"
Input file size is 120000, 1600000...10...20...30...40...
ERROR 1: TIFFFillStrip:Read error at scanline 39921; got 3204 bytes, expected 10047
ERROR 1: TIFFReadEncodedStrip() failed.
ERROR 1: P:/globiom/Projects/ISWEL/data/forest/tree_cover/Hansen_GFC2014_treecover2000_10S_030E.tif, band 1: IReadBlock failed at X offset 0, Y offset 39922
ERROR 1: GetBlockRef failed at X block offset 0, Y block offset 39922

I understand that this might be thread error, related to how the files are read and intermediate vrt file is constructed (https://github.com/mapnik/node-mapnik/issues/437 ) and could be solved by setting "VRT_SHARED_SOURCE" to 0. I tried to do this using setCPLConfigOption("VRT_SHARED_SOURCE", "0") in R but still receive the same error. Is this really the way to solve this or is the file perhaps corrupt (unlikely as this dataset is used by many people - I also downloaded them twice)? I hope somebody can give me advice on how to make this work.

Many thanks,
Michiel



# prepare and save template for mosaic
e <- extent(20, 40, -20, -10)
template <- raster(e)
proj4string(template) <- CRS("+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0") writeRaster(template, file = file.path(proj_path, "data/forest/combined_tiles/tree_cover.tif"), format="GTiff", overwrite = T)

# create mosaic
setCPLConfigOption("VRT_SHARED_SOURCE", "0") mosaic_rasters(gdalfile = tree_cover_files,
               dst_dataset = file.path(proj_path, "data/forest/combined_tiles/tree_cover.tif"), of="GTiff",
               verbose = T)
 


M. (Michiel) van Dijk, PhD
Research scholar | Ecosystems Services and Management (ESM) | International Institute for Applied Systems Analysis (IIASA) Senior researcher (out of office) | International Policy Division (IB) | Wageningen Economic Research

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

Re: R squared in lagsarlm

Thu, 03/21/2019 - 08:05
On Thu, 21 Mar 2019, Leonardo Matheus Servino wrote:

> When a linear regression is used, usually the degree of freedom, F-value,
> p-value are exposed, in text or in a table. In a lagsarlm, what parameters
> we should expose?
>

None of these make any sense in this case. This model is fitted by maximum
likelihood, so likelihood-based measures may be appropriate, but the model
is also non-linear in the spatial coefficient, so it is simply not like
OLS. However, you could represent OLS in its maximum likelihood form,
correcting the t-values not to subtract k. The provided measure is a
likelihood ratio test of the model fitted with and without the spatial
coefficient (equivalent to a test of the spatial coefficient). You can run
your own LR tests against other alternatives, and the Nagelkerke measure
is also likelihood-based. STSLS may provide other measures, but they are
not OLS-based either, being IV. Just because a supervisor or referee wants
the same measures as OLS, it doesn't mean they can get them. Certainly you
should avoid p-values as they give little guidance.

Roger

>
>
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
> Livre
> de vírus. www.avast.com
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>.
> <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>

--
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]
https://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: R squared in lagsarlm

Thu, 03/21/2019 - 07:52
When a linear regression is used, usually the degree of freedom, F-value,
p-value are exposed, in text or in a table. In a lagsarlm, what parameters
we should expose?



<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
Livre
de vírus. www.avast.com
<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>.
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

        [[alternative HTML version deleted]]

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

Pages