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: 2 hours 31 min ago

Re: Selecting a range of longitude and latitudes

Thu, 04/18/2019 - 20:51
Hi Ben (and everyone),

Ah, yes, you're right - using the suggestion that you specified, that error message disappeared! So, if I understand, this would take all of the grid cells within those specified longitude and latitude ranges (i.e. that entire area)? 
That said, when I try plotting this using the following:
get <- ncvar_get(Model1, "cum_co2_emi-CanESM2")   #for x-axis (140 values)
Model2 <- brick("MaxPrecCCCMACanESM21pctCO2.nc", var="onedaymax")    #for y-axis (140 values)

Hope2 <- extract(Model2, lonlat)

plot(get,Hope2, type="l",col="green", lwd="3", xlab="Cumulative emissions (TtC)", ylab="One-day maximum precipitation (mm/day)", main="CanESM2")
I receive this error:
Error in xy.coords(x, y, xlabel, ylabel, log) :
  'x' and 'y' lengths differ
*Note that I do not have this problem when specifying a "specific" longitude and latitude, rather than a range. Is there any reason for this?
Thanks, again
-----Original Message-----
From: Ben Tupper <[hidden email]>
To: rain1290 <[hidden email]>
Cc: r-sig-geo <[hidden email]>
Sent: Thu, Apr 18, 2019 9:26 pm
Subject: Re: [R-sig-Geo] Selecting a range of longitude and latitudes

Hi,
The example you give is different than the one listed in the error message.  In your example you bind two 14-element vectors into a matrix of two columns.
cbind(103:116, 3:16)
But in the error you show the first vector is only 8 elements long...
cbind(103:110, 3:16)
When R encounters an attempt to bind columns of unequal length it will try to "recycle" the shorter vector as long as it is a multiple of the longer. In this case of binding an 8-element vector and a 14-element vector it fails.  
Note that shortening up the first vector to 7 does work since 7 is a multiple of 14...
cbind(103:109, 3:16)      [,1] [,2] [1,]  103    3 [2,]  104    4 [3,]  105    5 [4,]  106    6 [5,]  107    7 [6,]  108    8 [7,]  109    9 [8,]  103   10 [9,]  104   11[10,]  105   12[11,]  106   13[12,]  107   14[13,]  108   15[14,]  109   16

Note how the sequence 103...109 appears twice in the first column.  Recycling is nice (and handy) until you get surprised by it.
Cheers,Ben

On Apr 18, 2019, at 8:37 PM, rain1290--- via R-sig-Geo <[hidden email]> wrote:
Hi there,
I am trying to specify a range of longitudes and latitudes. I tried this using the following:


lonlat <- cbind(103:116, 3:16)  #This would specify a range of longitudes and latitudes

However, I receive the following warning message:
Warning message:
In cbind(103:110, 3:16) :
  number of rows of result is not a multiple of vector length (arg 1)

When I specify the longitude and latitude of a specific location, though, it works just fine, like this:
lonlat <- cbind(103, 3)

Am I specifying the ranges of coordinates incorrectly? The warning message would suggest yes, but I do not understand why.
Thanks, and any help with this would be greatly appreciated!
~Trav.~
 [[alternative HTML version deleted]]

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


Ben Tupper
Bigelow Laboratory for Ocean Sciences
60 Bigelow Drive, P.O. Box 380
East Boothbay, Maine 04544
http://www.bigelow.org
Ecological Forecasting: https://eco.bigelow.org/





        [[alternative HTML version deleted]]

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

Re: Selecting a range of longitude and latitudes

Thu, 04/18/2019 - 20:26
Hi,

The example you give is different than the one listed in the error message.  In your example you bind two 14-element vectors into a matrix of two columns.

cbind(103:116, 3:16)

But in the error you show the first vector is only 8 elements long...

cbind(103:110, 3:16)

When R encounters an attempt to bind columns of unequal length it will try to "recycle" the shorter vector as long as it is a multiple of the longer. In this case of binding an 8-element vector and a 14-element vector it fails.  

Note that shortening up the first vector to 7 does work since 7 is a multiple of 14...

cbind(103:109, 3:16)
      [,1] [,2]
 [1,]  103    3
 [2,]  104    4
 [3,]  105    5
 [4,]  106    6
 [5,]  107    7
 [6,]  108    8
 [7,]  109    9
 [8,]  103   10
 [9,]  104   11
[10,]  105   12
[11,]  106   13
[12,]  107   14
[13,]  108   15
[14,]  109   16


Note how the sequence 103...109 appears twice in the first column.  Recycling is nice (and handy) until you get surprised by it.

Cheers,
Ben

> On Apr 18, 2019, at 8:37 PM, rain1290--- via R-sig-Geo <[hidden email]> wrote:
>
> Hi there,
> I am trying to specify a range of longitudes and latitudes. I tried this using the following:
>
>
> lonlat <- cbind(103:116, 3:16)  #This would specify a range of longitudes and latitudes
>
> However, I receive the following warning message:
> Warning message:
> In cbind(103:110, 3:16) :
>  number of rows of result is not a multiple of vector length (arg 1)
>
> When I specify the longitude and latitude of a specific location, though, it works just fine, like this:
> lonlat <- cbind(103, 3)
>
> Am I specifying the ranges of coordinates incorrectly? The warning message would suggest yes, but I do not understand why.
> Thanks, and any help with this would be greatly appreciated!
> ~Trav.~
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Ben Tupper
Bigelow Laboratory for Ocean Sciences
60 Bigelow Drive, P.O. Box 380
East Boothbay, Maine 04544
http://www.bigelow.org

Ecological Forecasting: https://eco.bigelow.org/






        [[alternative HTML version deleted]]

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

Re: Selecting a range of longitude and latitudes

Thu, 04/18/2019 - 20:24
It appears that you might have mistakenly typed cbind(103:110, 3:16)
instead of cbind(103:116, 3:16).  Regardless, the warning is telling you
that the vectors were of unequal lengths and there was some recycling.  You
can learn about recycling rule from searching "recycling rule in R" and
also from R's Introduction manual at
https://cran.r-project.org/doc/manuals/r-release/R-intro.html#The-recycling-rule
.

HTH,
Vijay

On Thu, Apr 18, 2019 at 8:38 PM rain1290--- via R-sig-Geo <
[hidden email]> wrote:

> Hi there,
> I am trying to specify a range of longitudes and latitudes. I tried this
> using the following:
>
>
> lonlat <- cbind(103:116, 3:16)  #This would specify a range of longitudes
> and latitudes
>
> However, I receive the following warning message:
> Warning message:
> In cbind(103:110, 3:16) :
>   number of rows of result is not a multiple of vector length (arg 1)
>
> When I specify the longitude and latitude of a specific location, though,
> it works just fine, like this:
> lonlat <- cbind(103, 3)
>
> Am I specifying the ranges of coordinates incorrectly? The warning message
> would suggest yes, but I do not understand why.
> Thanks, and any help with this would be greatly appreciated!
> ~Trav.~
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
        [[alternative HTML version deleted]]

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

Selecting a range of longitude and latitudes

Thu, 04/18/2019 - 19:37
Hi there,
I am trying to specify a range of longitudes and latitudes. I tried this using the following:


lonlat <- cbind(103:116, 3:16)  #This would specify a range of longitudes and latitudes

However, I receive the following warning message:
Warning message:
In cbind(103:110, 3:16) :
  number of rows of result is not a multiple of vector length (arg 1)

When I specify the longitude and latitude of a specific location, though, it works just fine, like this:
lonlat <- cbind(103, 3)

Am I specifying the ranges of coordinates incorrectly? The warning message would suggest yes, but I do not understand why.
Thanks, and any help with this would be greatly appreciated!
~Trav.~
        [[alternative HTML version deleted]]

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

Re: spreml function

Wed, 04/17/2019 - 08:33
On Thu, 11 Apr 2019, Federico Dell'Anna wrote:

> Dear,
> I have a problem with “spreml” function in R.
> I have a dataset of 26000 observation, like points.
> I have imported the shp file in R, and .gal file calculated previously in GEODA.
> When i run spreml, an error comes:
> Error in as.vector(x) : no method for coercing this S4 class to a vector
> below the function:
> mapsart <- spreml(fm, data = map, w = maplistw, errors="sr", lag=TRUE, method="BFGS”)

Unfortunately, this is not helpful, as we do not know what the objects
passed to spreml() are. What are their classes? Is data= of the form
expected by the function with balanced temporal and spatial indices?
Please provide an example reproducing the problem with a built-in data
set.

Roger

>
>
> Can you help me to solve this problem?
>
> Regards
>
> Federico
>
>
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> 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.
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: tpk files

Mon, 04/15/2019 - 10:13
Hi,

Finally, the full code that works
Thanks to everybody once again,

Cheers,
M.

# From Edzer Pebesma (thank you) - see also the alternative from Barry
using sqlite3
library(sf)
#open subset the file depth=1
system.time(r.d1 <- st_read("D:/EMU_Z_Opendata/EMU.gpkg", query = "select *
from EMU_Master where depth_lvl = 1"))

# Code chunks copied from below (adapted with the help of Barry Rowlingson):
require(dplyr)
dr <- r.d1 %>%
  dplyr::rename("x"=POINT_X,"y"=POINT_Y) %>%
  dplyr::mutate(NameEMUn = as.numeric(NameEMU)) %>%
  dplyr::select(x,y, NameEMUn) %>%
  st_set_geometry(NULL)

drz <- rasterFromXYZ(dr)
system.time(drzp <- rasterToPolygons(drz,dissolve=TRUE))
# spplot(drzp,"layer")

emu <- st_as_sf(drzp)
st_crs(emu)=4326
emu$NameEMU = levels(d$NameEMU)
plot(emu)
## Allright!!!
# Export as a shape file:
# write_sf(emu, "emu.shp")

        [[alternative HTML version deleted]]

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

Re: [R] Creating a mean line plot

Sun, 04/14/2019 - 09:58
Hi Bill,

For the x-axis variable, in this case, indeed, I used rowMeans(cbind(get2.teratons, get5.teratons)). This averaged each value between these two 1-dimensional variables (i.e. value#1 of "get2.teratons" was averaged with value#1 of "get5.teratons" - this was done for all 90 values). 
To obtain the means for the values of the y-axis variables, which are 3-dimensional, I simply took each variable and divided by 2, in this case. Thus: (variableA+variableB)/2. This took the mean of the variable for each grid cell for each layer (90 layers). So, for grid cell #1, doing this averaged all 90 values corresponding to the 90 layers between the two variables. For example, the values of layer 1 of variableA and layer 1 of variableB were averaged (and then layer 2 with layer 2, and then layer 3 with layer 3.....all the way to layer 90 with layer 90. This method simultaneously did this for all 8192 grid cells (128 lines of longitude and 64 lines of latitude). At the end, I obtained 90 averages for each grid cell. :)
~Trav.~
-----Original Message-----
From: William Michels <[hidden email]>
To: rain1290 <[hidden email]>
Cc: r-help <[hidden email]>; r-sig-geo <[hidden email]>
Sent: Sun, Apr 14, 2019 4:46 am
Subject: Re: [R] Creating a mean line plot

So you're saying rowMeans(cbind(matrix_a, matrix_b)) worked to obtain
your X-axis values?

Wild guess here, are you simply looking for:
colMeans(rbind(matrix_a, matrix_b)) to obtain your Y-axis values?

[Above assuming matrix_a and matrix_b have identical dimensions (nrow, ncol)].

--Bill

William Michels, Ph.D.


On Fri, Apr 12, 2019 at 11:09 AM rain1290--- via R-help






<[hidden email]> wrote:
>
> Hi Eric,
>
> Ah, I apologize, and thank you for your response!
> I just figured out a way to average my x-values, so at least that is solved. I will still include the data for the two variables (1-dimensional) of interest that I was trying to average, just to show what was done:
> get2.teratons #(90 values)
> get5.teratons #(90 values)
> Here is what get2.teratons looks like (same idea for get5.teratons):
>    >print(get2.teratons)
>    [1] 0.4558545 0.4651129 0.4747509 0.4848242 0.4950900 0.5056109 0.5159335
>    0.5262532 0.5372275 0.5481839 0.5586787 0.5694379 0.5802970
>    [14] 0.5909211 0.6015753 0.6124256 0.6237733 0.6353634 0.6467227 0.6582857
>    0.6702509 0.6817027 0.6935311 0.7060161 0.7182312 0.7301909
>    [27] 0.7422574 0.7544744 0.7665907 0.7786409 0.7907518 0.8032732 0.8158733
>    0.8284363 0.8413905 0.8545881 0.8674711 0.8797701 0.8927392
>    [40] 0.9059937 0.9189707 0.9317215 0.9438155 0.9558035 0.9673665 0.9784927
>    0.9900898 1.0020388 1.0132683 1.0240023 1.0347708 1.0456077
>    [53] 1.0570347 1.0682903 1.0793535 1.0901511 1.1001753 1.1101276 1.1199142
>    1.1293237 1.1384669 1.1470002 1.1547341 1.1622488 1.1697549
>    [66] 1.1777542 1.1857587 1.1930233 1.1999645 1.2067172 1.2132979 1.2199317
>    1.2265673 1.2328599 1.2390689 1.2446050 1.2495579 1.2546455
>    [79] 1.2599212 1.2648733 1.2700068 1.2753889 1.2807509 1.2856922 1.2905927
>    1.2953338 1.3000484 1.3045992 1.3091128 1.3144190
> The following worked in terms of averaging all of the elements of get2.teratons and get5.teratons:
> rowMeans(cbind(get2.teratons,get5.teratons))
> However, I am trying to do something similar for the values on my y-axis. So, for now, here are the two variables (3-dimensional) that I would like to average:
>    subset
>    subset5
> Using the print function for "subset" (same idea for subset5):    >print(subset)
>    class      : RasterStack
>    dimensions  : 64, 128, 8192, 90  (nrow, ncol, ncell, nlayers)
>    resolution  : 2.8125, 2.789327  (x, y)
>    extent      : -181.4062, 178.5938, -89.25846, 89.25846  (xmin, xmax, ymin,
>    ymax)
>    coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0
>    names      : X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14,
>    X15, ...    >dim(subset)
>    [1]  64 128  90>dim(subset5)
>    [1]  64 128  90
> I tried `mean(subset,subset5)`, which works, BUT it combines the 90 layers into 1 layer. I want keep the number of layers at 90, but simply average each of the grid cell values of "subset" and "subset5" for each layer. So, for instance, I want to average the values of each grid cell of layer 1 of "subset" with the values of each grid cell of layer 1 of "subset5", and then average those values of layer 2 of "subset" with those values of layer 2 of "subset5"......all the way to layer 90. That way, I have 90 averages across all grid cells.
> Here is what the data looks like for "subset":
> >dput(head(subset,5))
>    structure(c(11.5447145886719, 11.2479725852609, 10.0223480723798,
>    11.4909216295928, 12.5930442474782, 15.0295264553279, 14.6107862703502,
>    13.3623332250863, 10.4473929153755, 13.262210553512, 13.3166334126145,
>    13.7211008928716, 10.594900790602, 11.7217378690839, 10.8397546224296,
>    14.2727348953485, 13.6185416020453, 12.7485566306859, 11.7246472276747,
>    10.6815265025944, 13.1605062168092, 12.9131189547479, 12.6493454910815,
>    11.6938022430986, 11.4522186107934, 8.84930260945112, 11.5785481408238,
>    12.9859233275056, 13.6702361516654, 11.863912967965, 11.6624090820551,
>    12.1465771459043, 12.9789240192622, 13.5916746687144, 15.0383287109435,
>    7.89674604311585, 8.14079332631081, 7.05628590658307, 6.99759456329048,
>    8.06435288395733, 8.00622920505702, 7.35754533670843, 6.57949370797724,
>    6.26998774241656, 6.10911303665489, 10.1576759945601, 9.83650996349752,
>    10.6277788057923, 10.3647025069222, 9.38627037685364, 28.411143925041,
>    27.3436004295945, 25.7670222781599, 24.1854049265385, 22.7183715440333,
>    10.8529561199248, 11.1584928352386, 11.4545458462089, 11.7570801638067,
>    11.6314635146409, 13.7268429156393, 12.4547378160059, 12.8433785866946,
>    10.282119596377, 9.66278391424567, 6.39572446234524, 8.4569685626775,
>    12.253624945879, 12.4784250743687, 13.6823802720755, 8.65540341474116,
>    8.34308553021401, 8.30261853989214, 7.9798299819231, 7.96007991302758,
>    13.3976918645203, 15.2056947816163, 15.3097502421588, 18.0296610575169,
>    17.918016621843, 14.121591579169, 14.3091559410095, 14.7470911033452,
>    15.414851764217, 15.8059203531593, 22.9126498103142, 21.5608592145145,
>    19.7303873486817, 17.5689237657934, 15.4688697773963, 10.2526041911915,
>    10.4463449679315, 9.85705149360001, 9.5394266070798, 9.17961853556335,
>    14.064371259883, 12.626935634762, 12.1540617663413, 10.9235350973904,
>    9.32216013316065, 12.3676003888249, 12.9718807060272, 14.5685050170869,
>    13.8497828040272, 14.0683455392718, 8.09576804749668, 8.54510050266981,
>    8.02388715092093, 8.6679536383599, 9.38348234631121, 11.6279292851686,
>    11.5998465567827, 11.6469369269907, 11.6286710835993, 10.8152111526579,
>    17.4072104506195, 18.9169261604548, 19.5168524980545, 19.0377978142351,
>    19.5594304706901, 9.74474258255213, 10.2144323755056, 10.9722976572812,
>    11.5369332488626, 12.0274581480771, 14.007618650794, 14.0536692459136,
>    14.4861201290041, 14.133819937706, 13.045089924708, 19.9330265633762,
>    20.3158976510167, 21.4452845044434, 19.9475897010416, 20.3566399868578,
>    15.703826257959, 14.8260951507837, 14.6203982178122, 14.0476305037737,
>    13.2086589932442, 6.5044054761529, 6.51829722337425, 6.59741191193461,
>    6.57343484926969, 7.07112564705312, 8.42645864468068, 9.15604883339256,
>    10.8542435802519, 8.57339131180197, 7.89698304142803, 10.6029914226383,
>    9.90388663485646, 8.46301421988755, 12.9162973724306, 9.06370310112834,
>    9.92726711556315, 11.5754703059793, 8.74886247329414, 8.99941809475422,
>    9.90840594749898, 11.1468604300171, 11.1322306562215, 10.49438144546,
>    9.50155213940889, 8.31737467087805, 5.76932597905397, 6.14411209244281,
>    7.39980584476143, 8.47632132936269, 8.00714262295514, 8.64454926922917,
>    7.79559868387878, 7.14818593114614, 7.42282171268016, 9.04718739911914,
>    12.0141573250294, 11.0411503817886, 11.7892528418452, 11.2668004352599,
>    10.5345542309806, 14.2355003859848, 12.4114783946425, 13.1144292186946,
>    14.3049817532301, 14.7282858844846, 9.90791183430701, 10.4058899218217,
>    12.0624131988734, 13.2521220948547, 13.9345653355122, 12.5256763771176,
>    12.3285478446633, 11.9927407242358, 11.6441268939525, 11.6448875516653,
>    30.5602320469916, 30.6964941322803, 27.3358505219221, 27.5474566966295,
>    24.3847575969994, 15.1250814087689, 15.0272130500525, 14.9795342702419,
>    14.2658210825175, 13.437497522682, 10.7001833617687, 10.0823557935655,
>    10.1298170629889, 9.99525294173509, 10.6919908896089, 9.04134479351342,
>    9.57930330187082, 9.58402880933136, 8.82056106347591, 9.06912200152874,
>    11.0435656271875, 12.827942892909, 14.6962288767099, 15.984565531835,
>    16.3673574104905, 17.7882182411849, 17.1887206379324, 16.4347139652818,
>    15.4833788517863, 14.3649869598448, 10.0324214436114, 10.9937381464988,
>    10.7803415972739, 10.64134365879, 10.3700830601156, 10.7242427766323,
>    10.1225153775886, 9.59254063200206, 9.67734202276915, 9.9705743137747,
>    6.15209711249918, 7.6417050557211, 9.55170588567853, 12.123644258827,
>    14.6793850231916, 13.8236853294075, 14.3564789090306, 13.6828002054244,
>    13.0476749036461, 12.3909330926836, 12.5938401091844, 12.5098232645541,
>    12.4792913440615, 10.5595408938825, 10.0890464382246, 9.20089432038367,
>    8.92592284362763, 8.59467086847872, 9.42603517323732, 10.0353622343391,
>    11.7311725392938, 12.4379832297564, 12.9343897104263, 12.9055073484778,
>    10.8944955747575, 13.6480727232993, 13.5285727679729, 13.1794585380703,
>    12.8222310449928, 12.3997843824327, 12.7413347829133, 14.3273916095495,
>    17.3931313678622, 18.2263168506324, 18.5841742437333, 6.59096706658602,
>    6.43405092414469, 6.25825286842883, 6.41100551001728, 6.47397979628295,
>    10.5375754879788, 11.7441980168223, 12.6210678834468, 13.6038213036954,
>    14.3639346119016, 14.6688716020435, 14.1826340463012, 15.2044224087149,
>    15.5630568042397, 15.0458208750933, 10.0154311163351, 9.7418615128845,
>    11.8866622913629, 10.4000290855765, 9.74880487192422, 12.071524746716,
>    11.5644979756325, 11.0723461490124, 10.6282578315586, 10.2157085202634,
>    14.5142644643784, 12.1188929770142, 12.3748247511685, 12.4087903182954,
>    11.9534945581108, 9.04913682024926, 10.3765605948865, 11.6044067312032,
>    11.8693192955106, 11.4852412138134, 9.60276927798986, 8.47671863157302,
>    6.53922976925969, 6.61022553686053, 6.93009907845408, 13.2296028546989,
>    13.0423339549452, 13.0597360432148, 12.6910961698741, 12.4157820828259,
>    10.1926731644198, 8.71818219311535, 7.08254557102919, 8.77621911931783,
>    10.0059285527095, 12.931788386777, 12.2630294412374, 11.4822425879538,
>    10.4378029704094, 9.7940765786916, 13.0133786704391, 11.9061049539596,
>    12.0638377033174, 12.3013137839735, 12.9490484017879, 13.2149957120419,
>    13.1087802350521, 12.6286820042878, 12.2278920840472, 11.8682594038546,
>    10.9492189250886, 12.2341319918633, 12.9464382771403, 12.5120461452752,
>    12.5263502821326, 12.6686599105597, 12.7322974149138, 12.1948833111674,
>    12.1215357910842, 11.9392029941082, 15.2677292469889, 16.3731585256755,
>    17.8960581310093, 18.6334447469562, 19.5818214677274, 8.80653981585056,
>    9.830889897421, 9.35642933472991, 8.49255602806807, 9.19627505354583,
>    9.56638909410685, 10.4608207242563, 11.0053240321577, 12.0839668437839,
>    12.6748947892338, 10.9087632503361, 11.0474556684494, 9.86553691327572,
>    11.7183218244463, 12.5948534812778, 9.51134513597935, 7.67265690956265,
>    8.47005187533796, 8.948102616705, 9.48919930960983, 8.92916852608323,
>    9.19180226046592, 9.93818349670619, 10.3347131051123, 9.19244724791497,
>    16.0914938896894, 16.6821955237538, 17.9938221350312, 19.0754321403801,
>    19.048942392692, 8.59134346246719, 8.39548541698605, 8.17942153662443,
>    8.02843223791569, 8.9953287737444, 7.97593365423381, 7.71139136049896,
>    7.85907462704927, 8.38070099707693, 9.28482818417251, 11.3056178670377,
>    11.601750086993, 11.2711317837238, 10.8186058234423, 10.7581429649144,
>    15.6826636288315, 16.9076268095523, 15.4331855010241, 15.1698420289904,
>    14.4226460717618, 11.3487603608519, 10.932231741026, 10.3945284616202,
>    9.96728525497019, 9.48596934322268, 10.508708213456, 10.0394641282037,
>    10.5090778553858, 10.1252990076318, 9.86525025218725, 21.985590364784,
>    22.3454732447863, 22.693102620542, 22.8635905310512, 23.2176823541522,
>    18.6908649746329, 16.1407203879207, 14.8633007425815, 13.0084274802357,
>    10.3990704054013, 6.98735397309065, 6.87530469149351, 8.9313744334504,
>    7.93048026971519, 8.05362006649375, 7.19595712143928, 6.09859018586576,
>    7.31170470826328, 8.58990701381117, 8.4448722191155, 10.6643167790025,
>    10.839969618246, 10.5106293456629, 10.4457534151152, 11.2185546196997,
>    12.6707960385829, 12.9902018699795, 12.9533659201115, 12.501154281199,
>    12.3501065187156, 25.9615670889616, 28.099115844816, 30.2258117124438,
>    32.2391155175865, 34.1092220507562, 13.0570391658694, 14.2825467512012,
>    11.1714780796319, 9.62660552468151, 13.1034480873495, 12.0462608523667,
>    12.1476030908525, 12.087664520368, 12.486698012799, 12.6554797869176,
>    12.9096878226846, 13.7426960282028, 15.2569429948926, 17.1046711038798,
>    17.0782153028995, 8.75586932525039, 8.82860643323511, 8.69223182089627,
>    9.15108947083354, 9.4462743261829, 8.55356580577791, 8.69411900639534,
>    8.9102350641042, 9.00506707839668, 8.75238287262619, 12.8364848904312,
>    14.6456281654537, 13.9498212374747, 14.5683591719717, 14.3893217202276,
>    15.1805742178112, 16.7262759525329, 17.7521643228829, 18.5243777465075,
>    18.8792126253247, 7.70680792629719, 7.47225251980126, 7.72799758706242,
>    7.68415729980916, 7.50800217501819, 9.68811193015426, 10.5253741610795,
>    10.922572016716, 10.9020531177521, 10.406608460471, 22.1927281469107,
>    21.7946967110038, 22.5350291468203, 22.0015277154744, 23.2784972526133,
>    25.1319196075201, 24.1645314730704, 23.0207713320851, 14.8746414575726,
>    12.5255933962762, 19.3960575386882, 19.3368871696293, 19.8454126249999,
>    19.8410699609667, 19.8172997217625, 12.1799279004335, 11.8857935070992,
>    11.4909932948649, 11.3612791523337, 10.8840802218765, 11.1973982769996,
>    11.6429010406137, 11.2867686431855, 11.5507948212326, 11.7122428491712,
>    13.8513946440071, 14.9497504346073, 14.425096521154, 13.2822252810001,
>    12.4311964027584, 18.864199379459, 17.5528808031231, 17.7616731729358,
>    17.1655979007483, 16.6251927148551, 29.3679255992174, 28.4771841019392,
>    27.9151875525713, 26.65377818048, 25.2528126351535, 10.6545137241483,
>    10.91169398278, 11.0310669522732, 11.1646522767842, 11.2674177624285,
>    13.7821182142943, 14.1553220339119, 15.0969068985432, 15.9642276819795,
>    16.6291657369584, 9.4556876225397, 9.84383365139365, 11.0380863770843,
>    10.6556000187993, 11.1149505246431, 8.38961955159903, 9.4479993218556,
>    10.1951210992411, 10.6412279885262, 10.8386783860624, 8.28430177643895,
>    8.50012865848839, 8.0173090333119, 8.15484160557389, 8.07647814508528,
>    10.3200965328142, 10.4913098970428, 10.3476996067911, 10.6061836704612,
>    12.1657092589885, 10.3872286621481, 9.38602960668504, 9.82730537652969,
>    9.79454554617405, 9.12395850755274, 12.1763132046908, 12.7074157353491,
>    12.6221365761012, 13.4234247263521, 15.5103187076747, 9.88674920517951,
>    9.41792191006243, 8.58000149019063, 7.98727499786764, 7.34257609583437,
>    13.8378750532866, 14.5356948953122, 14.5302697084844, 14.6059796679765,
>    14.1489790286869, 14.9558734148741, 15.146628767252, 15.4630133416504,
>    15.5585858970881, 15.4571908526123, 11.8359496816993, 11.2020426895469,
>    11.4698356948793, 11.8119870778173, 13.0321650300175, 17.7426278125495,
>    18.6734465416521, 18.8405636698008, 18.8715255819261, 18.9619445241988,
>    8.8628712343052, 8.674994437024, 9.01558804325759, 9.04601749498397,
>    8.85597188025713, 7.58305897470564, 7.92995095252991, 8.35649385116994,
>    9.23873609863222, 9.14969765581191, 12.9726023878902, 12.2728526126593,
>    13.0261426325887, 12.6654123421758, 11.5908016450703, 13.0077322013676,
>    12.6599280629307, 11.9994106236845, 10.1917257998139, 9.89739338401705,
>    10.7914459425956, 11.8336362764239, 11.7934257723391, 11.2242249771953,
>    11.4056261256337, 7.95377462636679, 7.26088020019233, 7.43080170359462,
>    7.50569254159927, 7.62218066956848, 11.2671461887658, 10.8180299866945,
>    9.43983325269073, 9.29652785416692, 10.826626047492, 14.3595944624394,
>    13.2217460777611, 12.7365244086832, 12.05212357454, 12.3027219437063,
>    13.1963438820094, 12.8045422956347, 13.7076315935701, 14.145736489445,
>    14.4983648322523, 14.3930621445179, 13.7241447810084, 13.0053710192442,
>    12.2289746068418, 11.4307265728712, 22.3180065862834, 17.3237380106002,
>    12.7182623371482, 13.0704908631742, 15.2839343994856, 11.1243085004389,
>    10.2472041500732, 10.5197993572801, 11.790946405381, 10.6045705731958,
>    15.1506495662034, 17.2426456119865, 18.0581725202501, 17.5418430939317,
>    16.011631116271, 16.6771751828492, 14.9888406973332, 14.0024574939162,
>    12.2754199896008, 10.462130815722, 14.700809167698, 14.7662508767098,
>    14.6368321962655, 13.8920741155744, 13.6426123324782, 7.52487180288881,
>    6.8714844295755, 7.11258086375892, 7.18187426682562, 7.26737848017365,
>    8.01721725147218, 9.51534896157682, 9.49199174065143, 9.66430208645761,
>    9.95999739971012, 12.6632636412978, 12.3405989259481, 12.1739520225674,
>    11.8746338412166, 11.4930238109082, 17.375064175576, 16.5855303872377,
>    14.6908791270107, 12.4465051107109, 10.6631374452263, 9.17110545560718,
>    8.15483720507473, 8.49230268504471, 9.13922635372728, 9.57141006365418,
>    16.033780714497, 17.3399481922388, 16.4341507013887, 15.3515323530883,
>    14.7840439807624, 18.8009101431817, 19.3318882025778, 20.5749990418553,
>    21.8101386912167, 21.9960610382259, 18.0659588892013, 17.8131891880184,
>    17.4943805672228, 17.3403216060251, 16.8955769855529, 12.620489532128,
>    12.2214950155467, 11.8860110174865, 11.3811555784196, 10.8314753975719,
>    13.4036011062562, 11.5633060690016, 11.6371187847108, 12.5311543699354,
>    13.4179203305393, 8.22134572081268, 7.50831649638712, 7.27005901280791,
>    7.60287002194673, 7.99200239125639, 7.90263516828418, 8.68863912764937,
>    10.4649641085416, 14.8291767574847, 13.2854715920985, 14.6683146245778,
>    15.3950218576938, 16.1753460299224, 18.3709637727588, 18.7799926847219,
>    9.85975402873009, 11.3263857085258, 14.0980262774974, 14.9891349021345,
>    15.565140126273, 17.7682626061141, 17.6397152245045, 18.1632375810295,
>    18.5020068660378, 18.6178280040622, 13.9469483401626, 13.3572864811867,
>    13.7237298768014, 15.0745737366378, 13.0753238685429, 7.80682750046253,
>    8.02811540197581, 8.54396957438439, 8.93615526147187, 9.23284823074937,
>    11.9208830874413, 11.34336409159, 9.64633170515299, 9.77506830822676,
>    9.60444209631532, 13.3866403251886, 13.6259520426393, 11.5198655985296,
>    10.6700826901942, 9.85463059041649, 16.529045579955, 14.2629016656429,
>    12.7639583777636, 13.6573225725442, 15.0617569684982, 9.50025964993984,
>    9.68771148473024, 9.27095026709139, 9.30016769561917, 9.69172285404056,
>    7.99956496339291, 7.4167326791212, 7.22712711431086, 8.56165643781424,
>    9.04990502167493, 16.1096038296819, 15.6424694694579, 16.1224633455276,
>    15.2468092739582, 15.2601830195636, 14.6924834232777, 15.2172856964171,
>    15.6576700508595, 15.8558295574039, 15.6930990982801, 10.0672576809302,
>    10.4989007581025, 10.7346505858004, 10.9321122989058, 10.1002658251673,
>    7.57602006196976, 8.28179977834225, 9.00425424333662, 8.75011347234249,
>    9.78429929818958, 8.22318575810641, 7.62580542359501, 7.52632019575685,
>    7.3945076437667, 8.00606575794518, 9.82791453134269, 10.3108039358631,
>    10.8194808941334, 11.0586643684655, 12.7866649534553, 16.4375944063067,
>    16.122004436329, 15.8343450631946, 15.183718688786, 14.59901179187,
>    13.086870778352, 13.8396339956671, 13.0286106839776, 12.6303931698203,
>    11.8594408035278, 12.4039673712105, 9.90002802573144, 9.60356576833874,
>    11.081666406244, 11.0487984493375, 15.9987502265722, 14.9749074596912,
>    13.8462209142745, 12.3910789377987, 11.7417626548558, 10.7962236274034,
>    11.77659323439, 11.0980827827007, 10.4603781597689, 10.4605271480978,
>    12.797769298777, 11.2864379771054, 9.58062659483403, 9.57864196971059,
>    9.7400170750916, 15.1035780552775, 15.3101249132305, 15.6179285142571,
>    14.4825984723866, 11.6881796624511, 11.791490809992, 11.2104086671025,
>    8.8539243908599, 8.34417999722064, 8.39954141993076, 9.41099112387747,
>    8.93235134426504, 9.60718737915158, 9.41101815551519, 9.83936337288469,
>    13.6638214811683, 14.4527215976268, 14.7365185897797, 13.2517122197896,
>    11.0009524505585, 9.60110148880631, 8.54964307509363, 8.75000974629074,
>    8.88564947526902, 7.84255138132721, 11.6202082950622, 12.075385870412,
>    12.8382677212358, 14.9491381365806, 20.0978868640959, 8.93126882147044,
>    9.09663643687963, 9.05409744009376, 8.98246862925589, 8.80278556142002,
>    8.68155935313553, 8.91096869017929, 7.71334832534194, 9.87222944386303,
>    11.2759735900909, 17.2249065712094, 17.9082475136966, 17.6210721954703,
>    16.7172310408205, 16.2506423424929, 12.9267014097422, 14.7103695664555,
>    19.504395313561, 22.4196153692901, 22.2453631460667, 8.23867111466825,
>    8.10000761412084, 7.8771845670417, 7.56322089582682, 7.14911003597081,
>    9.50618146453053, 8.6958515457809, 7.36113237217069, 6.79777669720352,
>    6.69330381788313), .Dim = c(10L, 90L), .Dimnames = list(NULL,
>    c("X1", "X2", "X3", "X4", "X5", "X6", "X7", "X8", "X9", "X10",
>    "X11", "X12", "X13", "X14", "X15", "X16", "X17", "X18", "X19",
>    "X20", "X21", "X22", "X23", "X24", "X25", "X26", "X27", "X28",
>    "X29", "X30", "X31", "X32", "X33", "X34", "X35", "X36", "X37",
>    "X38", "X39", "X40", "X41", "X42", "X43", "X44", "X45", "X46",
>    "X47", "X48", "X49", "X50", "X51", "X52", "X53", "X54", "X55",
>    "X56", "X57", "X58", "X59", "X60", "X61", "X62", "X63", "X64",
>    "X65", "X66", "X67", "X68", "X69", "X70", "X71", "X72", "X73",
>    "X74", "X75", "X76", "X77", "X78", "X79", "X80", "X81", "X82",
>    "X83", "X84", "X85", "X86", "X87", "X88", "X89", "X90")))
>
> Is there any way to compute the means in this way? I just tried this, but I received the following error:
> result <- rowMeans(cbind(c(subset), c(subset5)));dim(result) <- dim(subset);colnames(result) <- colnames(subset)
>
> Error in rowMeans(cbind(c(subset), c(subset5))) : 'x' must be numeric
>
> Thanks,
> -----Original Message-----
> From: Eric Berger <[hidden email]>
> To: rain1290 <[hidden email]>
> Cc: r-sig-geo <[hidden email]>; R mailing list <[hidden email]>
> Sent: Fri, Apr 12, 2019 11:47 am
> Subject: Re: [R] Creating a mean line plot
>
> I don't have your data. Are the x-values the same in both plots?Does this example cover the situation?
> f1 <- function(x) { x^3 - 2 }f2 <- function(x) { 2 - x^2 }
> xV <- seq(from=0,to=2,length=50)y1 <- f1(xV)y2 <- f2(xV)y3 <- .5*(y1+y2)plot(x=xV,y=y1,col="blue",lwd=2,type='l',xlab="x",ylab="y")lines(x=xV,y=y2,col="green",lwd=2)lines(x=xV,y=y3,col="red",lwd=2)legend("topleft",legend=c("y1","y2","mean"),col=c("blue","green","red"),lwd=rep(2,3))
>
>
> On Fri, Apr 12, 2019 at 5:34 PM rain1290--- via R-help <[hidden email]> wrote:
>
> Hi there,
> I am trying to create a mean line plot that shows the mean of a series of separate line plots that correspond to two climate models. Let's first try getting the mean of two line plots. To create the separate line plots, here is what I did to set up the x and y axis variables:
>
> ####Getting cumulative emissions data for x-axis: 1-dimensional ####
>
> #For CanESM model#
>
> ncfname <- "cumulative_emissions_1pctCO2.nc"
> Model1 <- nc_open(ncfname)
> get <- ncvar_get(Model1, "cum_co2_emi-CanESM2")    #units of terratones of carbon (TtC) for x-axis (140 values)
> #For IPSL LR Model#
> #Getting cumulative emissions data for x-axis IPSL LR 1pctCO2 IPSL <- ncvar_get(Model1, "cum_co2_emi-IPSL-CM5A-LR")    #units of terratones of carbon (TtC) for x-axis (140 values)
>
> ############################################################################################################
>
> #####Getting precipitation data for y-axis - these are 3-dimensional####
>
> #For CanESM2 model#
> Model2 <- brick("MaxPrecCCCMACanESM21pctCO2.nc", var="onedaymax")
>
>
> #For IPSL LR Model#
> Model10 <- brick("MaxPrecIPSLIPSL-CM5A-LR1pctCO2.nc", var="onedaymax")
> #############################################################################################################
> To create plots for a specific location:
> lonlat <- cbind(103,3)          #specifies a specific longitude and latitude
> Hope2 <- extract(Model2,lonlat)      #CanESM2
> Hope6 <- extract(Model10,lonlat)  #start IPSL CM5A LR
> plot(get,Hope2, type="l",col="green", lwd="3", xlab="Cumulative CO2 emissions (TtC)", ylab="One-day maximum precipitation (mm/day)", main="One-day maximum precipitation for random location for 1pctCO2 scenario")
> lines(IPSL, Hope6, type="l", lwd="3", col="green")
> #############################################################################################################
> So, the idea would be to create a plot that shows the mean of these two plots. Given what I showed above, how should I go about creating the mean of these two green line plots? Would you have to get the mean of the x-values, and then obtain the mean of the y-values, and then plot these?
> Thanks, and any help would be greatly appreciated!
>        [[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.
>
>
>        [[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.         [[alternative HTML version deleted]]

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

Re: tpk files

Fri, 04/12/2019 - 12:33
On Fri, Apr 12, 2019 at 6:16 PM Marta Rufino <[hidden email]>
wrote:

> Hi,
>
> Now, the next issue will be how to transform the huge world wide sf points
> (that are actually 32 classes) into a 'multipolygons' sf. Maybe I should do
> a new post with a reproducible example for this new challenge, if I don't
> manage (tried st_cast to LINESTRING and POLYGON and rasterToPolygons but no
> luck).
>
>
 You might be able to polygonize the raster version of the data using
rasterToPolygons (it returns sp class polygons but they can be converted).

...yup - starting with the raster I constructed previously:

takes a couple of minutes....

> rdpoly = rasterToPolygons(rdraster,dissolve=TRUE)
Loading required namespace: rgeos
> rdpoly
class       : SpatialPolygonsDataFrame
features    : 32
extent      : -180, 180, -78.5, 90  (xmin, xmax, ymin, ymax)
coord. ref. : NA
variables   : 1
names       : layer
min values  :     1
max values  :    32
> plot(rdpoly)
> spplot(rdpoly,"layer")

and you'll have to run it yourself to see the results!

 Feel free to share my SQL scripts and other bits of code.

Barry



> So, thank you once again,
> Good weekend,
> Cheers,
> M.
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
        [[alternative HTML version deleted]]

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

Re: tpk files

Fri, 04/12/2019 - 12:16
Hi,

Thank you all very much!
This list is amazing.

Barry proposed a way to do it using "SQLite3" (which I did not knew) and
then kindly send me the top layer as a cvs file. After, it is ok to open it
directly, either as a raster or sf (points). I managed that alright.
If anyone else is interested, please send me an email I can forward his
code (with his permission, of course).
Edzer, I will try that on Monday with a pc with available space, although
my smaller experiences already gave error working in the Mac.

Once I manage, I will add it to the rpub file after (
https://rpubs.com/MRufino/485396).

Now, the next issue will be how to transform the huge world wide sf points
(that are actually 32 classes) into a 'multipolygons' sf. Maybe I should do
a new post with a reproducible example for this new challenge, if I don't
manage (tried st_cast to LINESTRING and POLYGON and rasterToPolygons but no
luck).

So, thank you once again,
Good weekend,
Cheers,
M.

        [[alternative HTML version deleted]]

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

Re: [R] Creating a mean line plot

Fri, 04/12/2019 - 11:39
Hi Eric,

Ah, I apologize, and thank you for your response! 
I just figured out a way to average my x-values, so at least that is solved. I will still include the data for the two variables (1-dimensional) of interest that I was trying to average, just to show what was done:
get2.teratons #(90 values)
get5.teratons #(90 values)
Here is what get2.teratons looks like (same idea for get5.teratons):
    >print(get2.teratons)
    [1] 0.4558545 0.4651129 0.4747509 0.4848242 0.4950900 0.5056109 0.5159335 
    0.5262532 0.5372275 0.5481839 0.5586787 0.5694379 0.5802970
    [14] 0.5909211 0.6015753 0.6124256 0.6237733 0.6353634 0.6467227 0.6582857
    0.6702509 0.6817027 0.6935311 0.7060161 0.7182312 0.7301909
    [27] 0.7422574 0.7544744 0.7665907 0.7786409 0.7907518 0.8032732 0.8158733
    0.8284363 0.8413905 0.8545881 0.8674711 0.8797701 0.8927392
    [40] 0.9059937 0.9189707 0.9317215 0.9438155 0.9558035 0.9673665 0.9784927
    0.9900898 1.0020388 1.0132683 1.0240023 1.0347708 1.0456077
    [53] 1.0570347 1.0682903 1.0793535 1.0901511 1.1001753 1.1101276 1.1199142
    1.1293237 1.1384669 1.1470002 1.1547341 1.1622488 1.1697549
    [66] 1.1777542 1.1857587 1.1930233 1.1999645 1.2067172 1.2132979 1.2199317  
    1.2265673 1.2328599 1.2390689 1.2446050 1.2495579 1.2546455
    [79] 1.2599212 1.2648733 1.2700068 1.2753889 1.2807509 1.2856922 1.2905927
    1.2953338 1.3000484 1.3045992 1.3091128 1.3144190 
The following worked in terms of averaging all of the elements of get2.teratons and get5.teratons:
rowMeans(cbind(get2.teratons,get5.teratons))
However, I am trying to do something similar for the values on my y-axis. So, for now, here are the two variables (3-dimensional) that I would like to average:
    subset 
    subset5
Using the print function for "subset" (same idea for subset5):    >print(subset)
    class       : RasterStack
    dimensions  : 64, 128, 8192, 90  (nrow, ncol, ncell, nlayers)
    resolution  : 2.8125, 2.789327  (x, y)
    extent      : -181.4062, 178.5938, -89.25846, 89.25846  (xmin, xmax, ymin, 
    ymax)
    coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0
    names       : X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14, 
    X15, ...     >dim(subset)
    [1]  64 128  90>dim(subset5)
    [1]  64 128  90
I tried `mean(subset,subset5)`, which works, BUT it combines the 90 layers into 1 layer. I want keep the number of layers at 90, but simply average each of the grid cell values of "subset" and "subset5" for each layer. So, for instance, I want to average the values of each grid cell of layer 1 of "subset" with the values of each grid cell of layer 1 of "subset5", and then average those values of layer 2 of "subset" with those values of layer 2 of "subset5"......all the way to layer 90. That way, I have 90 averages across all grid cells.
Here is what the data looks like for "subset":
>dput(head(subset,5))
    structure(c(11.5447145886719, 11.2479725852609, 10.0223480723798,
    11.4909216295928, 12.5930442474782, 15.0295264553279, 14.6107862703502,
    13.3623332250863, 10.4473929153755, 13.262210553512, 13.3166334126145,
    13.7211008928716, 10.594900790602, 11.7217378690839, 10.8397546224296,
    14.2727348953485, 13.6185416020453, 12.7485566306859, 11.7246472276747,
    10.6815265025944, 13.1605062168092, 12.9131189547479, 12.6493454910815,
    11.6938022430986, 11.4522186107934, 8.84930260945112, 11.5785481408238,
    12.9859233275056, 13.6702361516654, 11.863912967965, 11.6624090820551,
    12.1465771459043, 12.9789240192622, 13.5916746687144, 15.0383287109435,
    7.89674604311585, 8.14079332631081, 7.05628590658307, 6.99759456329048,
    8.06435288395733, 8.00622920505702, 7.35754533670843, 6.57949370797724,
    6.26998774241656, 6.10911303665489, 10.1576759945601, 9.83650996349752,
    10.6277788057923, 10.3647025069222, 9.38627037685364, 28.411143925041,
    27.3436004295945, 25.7670222781599, 24.1854049265385, 22.7183715440333,
    10.8529561199248, 11.1584928352386, 11.4545458462089, 11.7570801638067,
    11.6314635146409, 13.7268429156393, 12.4547378160059, 12.8433785866946,
    10.282119596377, 9.66278391424567, 6.39572446234524, 8.4569685626775,
    12.253624945879, 12.4784250743687, 13.6823802720755, 8.65540341474116,
    8.34308553021401, 8.30261853989214, 7.9798299819231, 7.96007991302758,
    13.3976918645203, 15.2056947816163, 15.3097502421588, 18.0296610575169,
    17.918016621843, 14.121591579169, 14.3091559410095, 14.7470911033452,
    15.414851764217, 15.8059203531593, 22.9126498103142, 21.5608592145145,
    19.7303873486817, 17.5689237657934, 15.4688697773963, 10.2526041911915,
    10.4463449679315, 9.85705149360001, 9.5394266070798, 9.17961853556335,
    14.064371259883, 12.626935634762, 12.1540617663413, 10.9235350973904,
    9.32216013316065, 12.3676003888249, 12.9718807060272, 14.5685050170869,
    13.8497828040272, 14.0683455392718, 8.09576804749668, 8.54510050266981,
    8.02388715092093, 8.6679536383599, 9.38348234631121, 11.6279292851686,
    11.5998465567827, 11.6469369269907, 11.6286710835993, 10.8152111526579,
    17.4072104506195, 18.9169261604548, 19.5168524980545, 19.0377978142351,
    19.5594304706901, 9.74474258255213, 10.2144323755056, 10.9722976572812,
    11.5369332488626, 12.0274581480771, 14.007618650794, 14.0536692459136,
    14.4861201290041, 14.133819937706, 13.045089924708, 19.9330265633762,
    20.3158976510167, 21.4452845044434, 19.9475897010416, 20.3566399868578,
    15.703826257959, 14.8260951507837, 14.6203982178122, 14.0476305037737,
    13.2086589932442, 6.5044054761529, 6.51829722337425, 6.59741191193461,
    6.57343484926969, 7.07112564705312, 8.42645864468068, 9.15604883339256,
    10.8542435802519, 8.57339131180197, 7.89698304142803, 10.6029914226383,
    9.90388663485646, 8.46301421988755, 12.9162973724306, 9.06370310112834,
    9.92726711556315, 11.5754703059793, 8.74886247329414, 8.99941809475422,
    9.90840594749898, 11.1468604300171, 11.1322306562215, 10.49438144546,
    9.50155213940889, 8.31737467087805, 5.76932597905397, 6.14411209244281,
    7.39980584476143, 8.47632132936269, 8.00714262295514, 8.64454926922917,
    7.79559868387878, 7.14818593114614, 7.42282171268016, 9.04718739911914,
    12.0141573250294, 11.0411503817886, 11.7892528418452, 11.2668004352599,
    10.5345542309806, 14.2355003859848, 12.4114783946425, 13.1144292186946,
    14.3049817532301, 14.7282858844846, 9.90791183430701, 10.4058899218217,
    12.0624131988734, 13.2521220948547, 13.9345653355122, 12.5256763771176,
    12.3285478446633, 11.9927407242358, 11.6441268939525, 11.6448875516653,
    30.5602320469916, 30.6964941322803, 27.3358505219221, 27.5474566966295,
    24.3847575969994, 15.1250814087689, 15.0272130500525, 14.9795342702419,
    14.2658210825175, 13.437497522682, 10.7001833617687, 10.0823557935655,
    10.1298170629889, 9.99525294173509, 10.6919908896089, 9.04134479351342,
    9.57930330187082, 9.58402880933136, 8.82056106347591, 9.06912200152874,
    11.0435656271875, 12.827942892909, 14.6962288767099, 15.984565531835,
    16.3673574104905, 17.7882182411849, 17.1887206379324, 16.4347139652818,
    15.4833788517863, 14.3649869598448, 10.0324214436114, 10.9937381464988,
    10.7803415972739, 10.64134365879, 10.3700830601156, 10.7242427766323,
    10.1225153775886, 9.59254063200206, 9.67734202276915, 9.9705743137747,
    6.15209711249918, 7.6417050557211, 9.55170588567853, 12.123644258827,
    14.6793850231916, 13.8236853294075, 14.3564789090306, 13.6828002054244,
    13.0476749036461, 12.3909330926836, 12.5938401091844, 12.5098232645541,
    12.4792913440615, 10.5595408938825, 10.0890464382246, 9.20089432038367,
    8.92592284362763, 8.59467086847872, 9.42603517323732, 10.0353622343391,
    11.7311725392938, 12.4379832297564, 12.9343897104263, 12.9055073484778,
    10.8944955747575, 13.6480727232993, 13.5285727679729, 13.1794585380703,
    12.8222310449928, 12.3997843824327, 12.7413347829133, 14.3273916095495,
    17.3931313678622, 18.2263168506324, 18.5841742437333, 6.59096706658602,
    6.43405092414469, 6.25825286842883, 6.41100551001728, 6.47397979628295,
    10.5375754879788, 11.7441980168223, 12.6210678834468, 13.6038213036954,
    14.3639346119016, 14.6688716020435, 14.1826340463012, 15.2044224087149,
    15.5630568042397, 15.0458208750933, 10.0154311163351, 9.7418615128845,
    11.8866622913629, 10.4000290855765, 9.74880487192422, 12.071524746716,
    11.5644979756325, 11.0723461490124, 10.6282578315586, 10.2157085202634,
    14.5142644643784, 12.1188929770142, 12.3748247511685, 12.4087903182954,
    11.9534945581108, 9.04913682024926, 10.3765605948865, 11.6044067312032,
    11.8693192955106, 11.4852412138134, 9.60276927798986, 8.47671863157302,
    6.53922976925969, 6.61022553686053, 6.93009907845408, 13.2296028546989,
    13.0423339549452, 13.0597360432148, 12.6910961698741, 12.4157820828259,
    10.1926731644198, 8.71818219311535, 7.08254557102919, 8.77621911931783,
    10.0059285527095, 12.931788386777, 12.2630294412374, 11.4822425879538,
    10.4378029704094, 9.7940765786916, 13.0133786704391, 11.9061049539596,
    12.0638377033174, 12.3013137839735, 12.9490484017879, 13.2149957120419,
    13.1087802350521, 12.6286820042878, 12.2278920840472, 11.8682594038546,
    10.9492189250886, 12.2341319918633, 12.9464382771403, 12.5120461452752,
    12.5263502821326, 12.6686599105597, 12.7322974149138, 12.1948833111674,
    12.1215357910842, 11.9392029941082, 15.2677292469889, 16.3731585256755,
    17.8960581310093, 18.6334447469562, 19.5818214677274, 8.80653981585056,
    9.830889897421, 9.35642933472991, 8.49255602806807, 9.19627505354583,
    9.56638909410685, 10.4608207242563, 11.0053240321577, 12.0839668437839,
    12.6748947892338, 10.9087632503361, 11.0474556684494, 9.86553691327572,
    11.7183218244463, 12.5948534812778, 9.51134513597935, 7.67265690956265,
    8.47005187533796, 8.948102616705, 9.48919930960983, 8.92916852608323,
    9.19180226046592, 9.93818349670619, 10.3347131051123, 9.19244724791497,
    16.0914938896894, 16.6821955237538, 17.9938221350312, 19.0754321403801,
    19.048942392692, 8.59134346246719, 8.39548541698605, 8.17942153662443,
    8.02843223791569, 8.9953287737444, 7.97593365423381, 7.71139136049896,
    7.85907462704927, 8.38070099707693, 9.28482818417251, 11.3056178670377,
    11.601750086993, 11.2711317837238, 10.8186058234423, 10.7581429649144,
    15.6826636288315, 16.9076268095523, 15.4331855010241, 15.1698420289904,
    14.4226460717618, 11.3487603608519, 10.932231741026, 10.3945284616202,
    9.96728525497019, 9.48596934322268, 10.508708213456, 10.0394641282037,
    10.5090778553858, 10.1252990076318, 9.86525025218725, 21.985590364784,
    22.3454732447863, 22.693102620542, 22.8635905310512, 23.2176823541522,
    18.6908649746329, 16.1407203879207, 14.8633007425815, 13.0084274802357,
    10.3990704054013, 6.98735397309065, 6.87530469149351, 8.9313744334504,
    7.93048026971519, 8.05362006649375, 7.19595712143928, 6.09859018586576,
    7.31170470826328, 8.58990701381117, 8.4448722191155, 10.6643167790025,
    10.839969618246, 10.5106293456629, 10.4457534151152, 11.2185546196997,
    12.6707960385829, 12.9902018699795, 12.9533659201115, 12.501154281199,
    12.3501065187156, 25.9615670889616, 28.099115844816, 30.2258117124438,
    32.2391155175865, 34.1092220507562, 13.0570391658694, 14.2825467512012,
    11.1714780796319, 9.62660552468151, 13.1034480873495, 12.0462608523667,
    12.1476030908525, 12.087664520368, 12.486698012799, 12.6554797869176,
    12.9096878226846, 13.7426960282028, 15.2569429948926, 17.1046711038798,
    17.0782153028995, 8.75586932525039, 8.82860643323511, 8.69223182089627,
    9.15108947083354, 9.4462743261829, 8.55356580577791, 8.69411900639534,
    8.9102350641042, 9.00506707839668, 8.75238287262619, 12.8364848904312,
    14.6456281654537, 13.9498212374747, 14.5683591719717, 14.3893217202276,
    15.1805742178112, 16.7262759525329, 17.7521643228829, 18.5243777465075,
    18.8792126253247, 7.70680792629719, 7.47225251980126, 7.72799758706242,
    7.68415729980916, 7.50800217501819, 9.68811193015426, 10.5253741610795,
    10.922572016716, 10.9020531177521, 10.406608460471, 22.1927281469107,
    21.7946967110038, 22.5350291468203, 22.0015277154744, 23.2784972526133,
    25.1319196075201, 24.1645314730704, 23.0207713320851, 14.8746414575726,
    12.5255933962762, 19.3960575386882, 19.3368871696293, 19.8454126249999,
    19.8410699609667, 19.8172997217625, 12.1799279004335, 11.8857935070992,
    11.4909932948649, 11.3612791523337, 10.8840802218765, 11.1973982769996,
    11.6429010406137, 11.2867686431855, 11.5507948212326, 11.7122428491712,
    13.8513946440071, 14.9497504346073, 14.425096521154, 13.2822252810001,
    12.4311964027584, 18.864199379459, 17.5528808031231, 17.7616731729358,
    17.1655979007483, 16.6251927148551, 29.3679255992174, 28.4771841019392,
    27.9151875525713, 26.65377818048, 25.2528126351535, 10.6545137241483,
    10.91169398278, 11.0310669522732, 11.1646522767842, 11.2674177624285,
    13.7821182142943, 14.1553220339119, 15.0969068985432, 15.9642276819795,
    16.6291657369584, 9.4556876225397, 9.84383365139365, 11.0380863770843,
    10.6556000187993, 11.1149505246431, 8.38961955159903, 9.4479993218556,
    10.1951210992411, 10.6412279885262, 10.8386783860624, 8.28430177643895,
    8.50012865848839, 8.0173090333119, 8.15484160557389, 8.07647814508528,
    10.3200965328142, 10.4913098970428, 10.3476996067911, 10.6061836704612,
    12.1657092589885, 10.3872286621481, 9.38602960668504, 9.82730537652969,
    9.79454554617405, 9.12395850755274, 12.1763132046908, 12.7074157353491,
    12.6221365761012, 13.4234247263521, 15.5103187076747, 9.88674920517951,
    9.41792191006243, 8.58000149019063, 7.98727499786764, 7.34257609583437,
    13.8378750532866, 14.5356948953122, 14.5302697084844, 14.6059796679765,
    14.1489790286869, 14.9558734148741, 15.146628767252, 15.4630133416504,
    15.5585858970881, 15.4571908526123, 11.8359496816993, 11.2020426895469,
    11.4698356948793, 11.8119870778173, 13.0321650300175, 17.7426278125495,
    18.6734465416521, 18.8405636698008, 18.8715255819261, 18.9619445241988,
    8.8628712343052, 8.674994437024, 9.01558804325759, 9.04601749498397,
    8.85597188025713, 7.58305897470564, 7.92995095252991, 8.35649385116994,
    9.23873609863222, 9.14969765581191, 12.9726023878902, 12.2728526126593,
    13.0261426325887, 12.6654123421758, 11.5908016450703, 13.0077322013676,
    12.6599280629307, 11.9994106236845, 10.1917257998139, 9.89739338401705,
    10.7914459425956, 11.8336362764239, 11.7934257723391, 11.2242249771953,
    11.4056261256337, 7.95377462636679, 7.26088020019233, 7.43080170359462,
    7.50569254159927, 7.62218066956848, 11.2671461887658, 10.8180299866945,
    9.43983325269073, 9.29652785416692, 10.826626047492, 14.3595944624394,
    13.2217460777611, 12.7365244086832, 12.05212357454, 12.3027219437063,
    13.1963438820094, 12.8045422956347, 13.7076315935701, 14.145736489445,
    14.4983648322523, 14.3930621445179, 13.7241447810084, 13.0053710192442,
    12.2289746068418, 11.4307265728712, 22.3180065862834, 17.3237380106002,
    12.7182623371482, 13.0704908631742, 15.2839343994856, 11.1243085004389,
    10.2472041500732, 10.5197993572801, 11.790946405381, 10.6045705731958,
    15.1506495662034, 17.2426456119865, 18.0581725202501, 17.5418430939317,
    16.011631116271, 16.6771751828492, 14.9888406973332, 14.0024574939162,
    12.2754199896008, 10.462130815722, 14.700809167698, 14.7662508767098,
    14.6368321962655, 13.8920741155744, 13.6426123324782, 7.52487180288881,
    6.8714844295755, 7.11258086375892, 7.18187426682562, 7.26737848017365,
    8.01721725147218, 9.51534896157682, 9.49199174065143, 9.66430208645761,
    9.95999739971012, 12.6632636412978, 12.3405989259481, 12.1739520225674,
    11.8746338412166, 11.4930238109082, 17.375064175576, 16.5855303872377,
    14.6908791270107, 12.4465051107109, 10.6631374452263, 9.17110545560718,
    8.15483720507473, 8.49230268504471, 9.13922635372728, 9.57141006365418,
    16.033780714497, 17.3399481922388, 16.4341507013887, 15.3515323530883,
    14.7840439807624, 18.8009101431817, 19.3318882025778, 20.5749990418553,
    21.8101386912167, 21.9960610382259, 18.0659588892013, 17.8131891880184,
    17.4943805672228, 17.3403216060251, 16.8955769855529, 12.620489532128,
    12.2214950155467, 11.8860110174865, 11.3811555784196, 10.8314753975719,
    13.4036011062562, 11.5633060690016, 11.6371187847108, 12.5311543699354,
    13.4179203305393, 8.22134572081268, 7.50831649638712, 7.27005901280791,
    7.60287002194673, 7.99200239125639, 7.90263516828418, 8.68863912764937,
    10.4649641085416, 14.8291767574847, 13.2854715920985, 14.6683146245778,
    15.3950218576938, 16.1753460299224, 18.3709637727588, 18.7799926847219,
    9.85975402873009, 11.3263857085258, 14.0980262774974, 14.9891349021345,
    15.565140126273, 17.7682626061141, 17.6397152245045, 18.1632375810295,
    18.5020068660378, 18.6178280040622, 13.9469483401626, 13.3572864811867,
    13.7237298768014, 15.0745737366378, 13.0753238685429, 7.80682750046253,
    8.02811540197581, 8.54396957438439, 8.93615526147187, 9.23284823074937,
    11.9208830874413, 11.34336409159, 9.64633170515299, 9.77506830822676,
    9.60444209631532, 13.3866403251886, 13.6259520426393, 11.5198655985296,
    10.6700826901942, 9.85463059041649, 16.529045579955, 14.2629016656429,
    12.7639583777636, 13.6573225725442, 15.0617569684982, 9.50025964993984,
    9.68771148473024, 9.27095026709139, 9.30016769561917, 9.69172285404056,
    7.99956496339291, 7.4167326791212, 7.22712711431086, 8.56165643781424,
    9.04990502167493, 16.1096038296819, 15.6424694694579, 16.1224633455276,
    15.2468092739582, 15.2601830195636, 14.6924834232777, 15.2172856964171,
    15.6576700508595, 15.8558295574039, 15.6930990982801, 10.0672576809302,
    10.4989007581025, 10.7346505858004, 10.9321122989058, 10.1002658251673,
    7.57602006196976, 8.28179977834225, 9.00425424333662, 8.75011347234249,
    9.78429929818958, 8.22318575810641, 7.62580542359501, 7.52632019575685,
    7.3945076437667, 8.00606575794518, 9.82791453134269, 10.3108039358631,
    10.8194808941334, 11.0586643684655, 12.7866649534553, 16.4375944063067,
    16.122004436329, 15.8343450631946, 15.183718688786, 14.59901179187,
    13.086870778352, 13.8396339956671, 13.0286106839776, 12.6303931698203,
    11.8594408035278, 12.4039673712105, 9.90002802573144, 9.60356576833874,
    11.081666406244, 11.0487984493375, 15.9987502265722, 14.9749074596912,
    13.8462209142745, 12.3910789377987, 11.7417626548558, 10.7962236274034,
    11.77659323439, 11.0980827827007, 10.4603781597689, 10.4605271480978,
    12.797769298777, 11.2864379771054, 9.58062659483403, 9.57864196971059,
    9.7400170750916, 15.1035780552775, 15.3101249132305, 15.6179285142571,
    14.4825984723866, 11.6881796624511, 11.791490809992, 11.2104086671025,
    8.8539243908599, 8.34417999722064, 8.39954141993076, 9.41099112387747,
    8.93235134426504, 9.60718737915158, 9.41101815551519, 9.83936337288469,
    13.6638214811683, 14.4527215976268, 14.7365185897797, 13.2517122197896,
    11.0009524505585, 9.60110148880631, 8.54964307509363, 8.75000974629074,
    8.88564947526902, 7.84255138132721, 11.6202082950622, 12.075385870412,
    12.8382677212358, 14.9491381365806, 20.0978868640959, 8.93126882147044,
    9.09663643687963, 9.05409744009376, 8.98246862925589, 8.80278556142002,
    8.68155935313553, 8.91096869017929, 7.71334832534194, 9.87222944386303,
    11.2759735900909, 17.2249065712094, 17.9082475136966, 17.6210721954703,
    16.7172310408205, 16.2506423424929, 12.9267014097422, 14.7103695664555,
    19.504395313561, 22.4196153692901, 22.2453631460667, 8.23867111466825,
    8.10000761412084, 7.8771845670417, 7.56322089582682, 7.14911003597081,
    9.50618146453053, 8.6958515457809, 7.36113237217069, 6.79777669720352,
    6.69330381788313), .Dim = c(10L, 90L), .Dimnames = list(NULL,
    c("X1", "X2", "X3", "X4", "X5", "X6", "X7", "X8", "X9", "X10",
    "X11", "X12", "X13", "X14", "X15", "X16", "X17", "X18", "X19",
    "X20", "X21", "X22", "X23", "X24", "X25", "X26", "X27", "X28",
    "X29", "X30", "X31", "X32", "X33", "X34", "X35", "X36", "X37",
    "X38", "X39", "X40", "X41", "X42", "X43", "X44", "X45", "X46",
    "X47", "X48", "X49", "X50", "X51", "X52", "X53", "X54", "X55",
    "X56", "X57", "X58", "X59", "X60", "X61", "X62", "X63", "X64",
    "X65", "X66", "X67", "X68", "X69", "X70", "X71", "X72", "X73",
    "X74", "X75", "X76", "X77", "X78", "X79", "X80", "X81", "X82",
    "X83", "X84", "X85", "X86", "X87", "X88", "X89", "X90")))

Is there any way to compute the means in this way? I just tried this, but I received the following error:
result <- rowMeans(cbind(c(subset), c(subset5)));dim(result) <- dim(subset);colnames(result) <- colnames(subset)

Error in rowMeans(cbind(c(subset), c(subset5))) : 'x' must be numeric

Thanks,
-----Original Message-----
From: Eric Berger <[hidden email]>
To: rain1290 <[hidden email]>
Cc: r-sig-geo <[hidden email]>; R mailing list <[hidden email]>
Sent: Fri, Apr 12, 2019 11:47 am
Subject: Re: [R] Creating a mean line plot

I don't have your data. Are the x-values the same in both plots?Does this example cover the situation?
f1 <- function(x) { x^3 - 2 }f2 <- function(x) { 2 - x^2 }
xV <- seq(from=0,to=2,length=50)y1 <- f1(xV)y2 <- f2(xV)y3 <- .5*(y1+y2)plot(x=xV,y=y1,col="blue",lwd=2,type='l',xlab="x",ylab="y")lines(x=xV,y=y2,col="green",lwd=2)lines(x=xV,y=y3,col="red",lwd=2)legend("topleft",legend=c("y1","y2","mean"),col=c("blue","green","red"),lwd=rep(2,3))
       

On Fri, Apr 12, 2019 at 5:34 PM rain1290--- via R-help <[hidden email]> wrote:

Hi there,
I am trying to create a mean line plot that shows the mean of a series of separate line plots that correspond to two climate models. Let's first try getting the mean of two line plots. To create the separate line plots, here is what I did to set up the x and y axis variables:

####Getting cumulative emissions data for x-axis: 1-dimensional ####

#For CanESM model#

ncfname <- "cumulative_emissions_1pctCO2.nc"
Model1 <- nc_open(ncfname)
get <- ncvar_get(Model1, "cum_co2_emi-CanESM2")     #units of terratones of carbon (TtC) for x-axis (140 values)
#For IPSL LR Model#
#Getting cumulative emissions data for x-axis IPSL LR 1pctCO2 IPSL <- ncvar_get(Model1, "cum_co2_emi-IPSL-CM5A-LR")     #units of terratones of carbon (TtC) for x-axis (140 values)

############################################################################################################

#####Getting precipitation data for y-axis - these are 3-dimensional####

#For CanESM2 model#
Model2 <- brick("MaxPrecCCCMACanESM21pctCO2.nc", var="onedaymax")


#For IPSL LR Model#
Model10 <- brick("MaxPrecIPSLIPSL-CM5A-LR1pctCO2.nc", var="onedaymax")
#############################################################################################################
To create plots for a specific location:
lonlat <- cbind(103,3)          #specifies a specific longitude and latitude
Hope2 <- extract(Model2,lonlat)      #CanESM2
Hope6 <- extract(Model10,lonlat)   #start IPSL CM5A LR
plot(get,Hope2, type="l",col="green", lwd="3", xlab="Cumulative CO2 emissions (TtC)", ylab="One-day maximum precipitation (mm/day)", main="One-day maximum precipitation for random location for 1pctCO2 scenario")
lines(IPSL, Hope6, type="l", lwd="3", col="green")
#############################################################################################################
So, the idea would be to create a plot that shows the mean of these two plots. Given what I showed above, how should I go about creating the mean of these two green line plots? Would you have to get the mean of the x-values, and then obtain the mean of the y-values, and then plot these?
Thanks, and any help would be greatly appreciated!
        [[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.


        [[alternative HTML version deleted]]

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

Re: "g.list" in rgrass7 returns an integer and not a char. vector

Fri, 04/12/2019 - 08:23
Thanks a lot !

Le ven. 12 avr. 2019 à 15:05, Micha Silver <[hidden email]> a écrit :

>
> On 12/04/2019 15:15, Mathieu Rajerison wrote:
>
> Hi List,
>
> I try to get the list of rasters which are in my working environment but
> the result of execGRASS("g.list") is an integer, not a character vector
>
> Why is that ?
>
>
> execGRASS("g.list", type="raster", pattern="global*") %>% class()
>
> global_glob_rad_day1
> global_glob_rad_day2
> global_glob_rad_day3
> [1] "integer"
>
> How to get a list of my rasters as a character ?
>
>
> Adding intern=TRUE to the execGRASS command works for me:
>
>
> > execGRASS("g.list", type="rast", pattern="meron*", intern=TRUE) %>% class
> [1] "character"
>
>
> --
> Micha Silver
> Ben Gurion Univ.
> Sde Boker, Remote Sensing Lab
> cell: +972-523-665918
>
>
        [[alternative HTML version deleted]]

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

Re: "g.list" in rgrass7 returns an integer and not a char. vector

Fri, 04/12/2019 - 08:04

On 12/04/2019 15:15, Mathieu Rajerison wrote:
Hi List, I try to get the list of rasters which are in my working environment but the result of execGRASS("g.list") is an integer, not a character vector Why is that ? execGRASS("g.list", type="raster", pattern="global*") %>% class() global_glob_rad_day1 global_glob_rad_day2 global_glob_rad_day3 [1] "integer" How to get a list of my rasters as a character ?


Adding intern=TRUE to the execGRASS command works for me:


> execGRASS("g.list", type="rast", pattern="meron*", intern=TRUE) %>% class
[1] "character"


-- Micha Silver Ben Gurion Univ. Sde Boker, Remote Sensing Lab cell: +972-523-665918
_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

"g.list" in rgrass7 returns an integer and not a char. vector

Fri, 04/12/2019 - 07:15
Hi List,

I try to get the list of rasters which are in my working environment but
the result of execGRASS("g.list") is an integer, not a character vector

Why is that ?

> execGRASS("g.list", type="raster", pattern="global*") %>% class()
global_glob_rad_day1
global_glob_rad_day2
global_glob_rad_day3
[1] "integer"

How to get a list of my rasters as a character ?

Thaks in advance for any guidance,

Mathieu

here is my sessionInfo() :
> sessionInfo()
R version 3.5.1 (2018-07-02)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=French_France.1252  LC_CTYPE=French_France.1252
LC_MONETARY=French_France.1252 LC_NUMERIC=C
[5] LC_TIME=French_France.1252

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
 [1] bindrcpp_0.2.2     rgrass7_0.1-12     XML_3.98-1.16
gdalUtils_2.0.1.14 forcats_0.3.0      stringr_1.3.1      dplyr_0.7.6
 [8] purrr_0.2.5        readr_1.1.1        tidyr_0.8.1        tibble_1.4.2
     ggplot2_3.0.0      tidyverse_1.2.1    raster_2.6-7
[15] sp_1.3-1           sf_0.6-3

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.17      lubridate_1.7.4   lattice_0.20-35   class_7.3-14
  assertthat_0.2.0  psych_1.8.4       foreach_1.4.4
 [8] R6_2.2.2          cellranger_1.1.0  plyr_1.8.4        e1071_1.6-8
 httr_1.3.1        pillar_1.2.3      rlang_0.2.1
[15] lazyeval_0.2.1    readxl_1.1.0      rstudioapi_0.7    R.utils_2.6.0
 R.oo_1.22.0       rgdal_1.3-3       foreign_0.8-70
[22] munsell_0.5.0     broom_0.4.5       compiler_3.5.1    modelr_0.1.2
  pkgconfig_2.0.1   mnormt_1.5-5      tidyselect_0.2.4
[29] codetools_0.2-15  crayon_1.3.4      withr_2.1.2
 R.methodsS3_1.7.1 grid_3.5.1        nlme_3.1-137      spData_0.2.9.0
[36] jsonlite_1.5      gtable_0.2.0      DBI_1.0.0         magrittr_1.5
  units_0.6-0       scales_0.5.0      cli_1.0.0
[43] stringi_1.1.7     reshape2_1.4.3    xml2_1.2.0
iterators_1.0.10  tools_3.5.1       glue_1.2.0        hms_0.4.2
[50] parallel_3.5.1    yaml_2.1.19       colorspace_1.3-2  classInt_0.2-3
  rvest_0.3.2       bindr_0.1.1       haven_1.1.2

        [[alternative HTML version deleted]]

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

Re: tpk files

Fri, 04/12/2019 - 03:13
Thanks; not sure this is what is intended, but it seemed to work:

> library(sf)
Linking to GEOS 3.7.0, GDAL 2.4.0, PROJ 5.2.0
> r = st_read("EMU.gpkg", query =
    "select * from EMU_Master where depth_lvl = 1")
Reading layer `EMU_Master' from data source
`/home/edzer/Downloads/EMU.gpkg' using driver `GPKG'
Simple feature collection with 677109 features and 33 fields
geometry type:  POINT
dimension:      XYZ
bbox:           xmin: -179.875 ymin: -78.375 xmax: 179.875 ymax: 89.875
epsg (SRID):    4326
proj4string:    +proj=longlat +datum=WGS84 +no_defs
> object.size(r)
438817848 bytes


On 4/12/19 12:48 AM, Barry Rowlingson wrote:
> QGIS could "read" it pretty smartly, only loading in the bits in the
> current view extent, and doing the loading in a separate thread so the
> GUI was still active.
>
> Marta has told me that she only needs the surface layer points - the X Y
> and Z coordinates are duplicated as attributes so I think a selection of
> Z=0 (or something) might make a small enough subset to read into R
> directly. This might be doable via the `query` option of `st_read`, or
> failing that a "select" in SQLite3 and dumping the results to a CSV
> file. There seems to be hundreds of data points at each location so
> taking the surface points only could thin it out considerably. It may
> still take some time but if its a one-off...
>
> Barry
>
>
> On Thu, Apr 11, 2019 at 9:57 PM Edzer Pebesma
> <[hidden email] <mailto:[hidden email]>>
> wrote:
>
>     It's a 30 Gb 3D point file:
>
>     $ ogrinfo EMU.gpkg
>     INFO: Open of `EMU.gpkg'
>           using driver `GPKG' successful.
>     1: EMU_Master (3D Point)
>
>     @Shaun: homebrew seems to be supported neither by apple, nor by CRAN, so
>     you are a bit on your own there. Have you tried the CRAN binary packages
>     using GDAL?
>
>     In any case, the windows binary does (should) support gpkg, see
>     https://github.com/rwinlib/gdal2
>
>     Trying to read this file into R with sf::st_read will require a lot of
>     RAM, or some strategy to read in parts only.
>
>     On 4/11/19 5:52 PM, Shaun Walbridge wrote:
>     > I think the issue is, most GDAL installations don't have the
>     Geopackage raster driver [1] installed by default, which lists
>     "Needs libsqlite3 (and any or all of PNG, JPEG, WEBP drivers)" for
>     it to be available. At least on my Homebrew installation of GDAL,
>     this driver wasn't built out of the box. If you rebuild GDAL with
>     this additional driver, or find a prebuilt binary which has it, it
>     should be able to open. A simple test is if `gdalinfo EMU.gpkg`
>     returns information about the dataset outside of R.
>     >
>     > 1.
>     https://urldefense.proofpoint.com/v2/url?u=https-3A__www.gdal.org_drv-5Fgeopackage-5Fraster.html&d=DwIGaQ&c=n6-cguzQvX_tUIrZOS_4Og&r=fCPRb7QX-vd5bnO9gIJHCiX852SVUtyYX--xtCKtpfk&m=p5ULiF5de1gKZBP-IzWbMO9Pe5LFzv9uaZ5VJYnWw1Y&s=d6xaKGlN0jpd8mBdjKXAhzst7N3Bgo43BvJlLnDSngk&e=
>     >
>     > On 4/11/19, 11:41 AM, "Barry Rowlingson" <[hidden email]
>     <mailto:[hidden email]>> wrote:
>     >
>     >     What did you try? The instructions at the top say:
>     >     
>     >     "Download 3.3GB tile package and rename extension from .tpk to
>     .zip.
>     >     Extract to get EMU.gpkg"
>     >     
>     >     If that's a valid GeoPackage then `sf` should be able to read
>     it. Not sure
>     >     what might be in the geopackage though, "tile package" sounds
>     like rasters,
>     >     but GeoPackages are generally vector...
>     >     
>     >     I'll try in five minutes when all 3.3Gb have downloaded....
>     >     
>     >     On Thu, Apr 11, 2019 at 3:37 PM Marta Rufino
>     <[hidden email] <mailto:[hidden email]>>
>     >     wrote:
>     >     
>     >     > Hi,
>     >     >
>     >     > I would like to open (and use) a 'tpk' file from arcgis in r.
>     >     > For example:
>     >     >
>     >     >
>     https://esri.maps.arcgis.com/home/item.html?id=24885cd6bd9544f5a8e15d0bf40f67d6
>     >     >
>     >     > I tried raster and sf package, but no luck.
>     >     >
>     >     > Any ideia if we can do this in r?
>     >     >
>     >     > Thank you very much in advance,
>     >     >
>     >     > Best wishes,
>     >     > M.
>     >     >
>     >     >         [[alternative HTML version deleted]]
>     >     >
>     >     > _______________________________________________
>     >     > R-sig-Geo mailing list
>     >     > [hidden email] <mailto:[hidden email]>
>     >     >
>     https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_r-2Dsig-2Dgeo&d=DwICAg&c=n6-cguzQvX_tUIrZOS_4Og&r=YFaRLkcUCdDkLrpTbNOUV9J1CwYBCTMwgm5tdQkRSm4&m=nytIIxO936Ls0xrd3zZkBd1WNjQB3DwlOK88GErq19M&s=uahwJjXmsZFnUVQXvkICr3EfAbNjOuaXl6iwziIexTM&e=
>     >     >
>     >     
>     >       [[alternative HTML version deleted]]
>     >     
>     >     _______________________________________________
>     >     R-sig-Geo mailing list
>     >     [hidden email] <mailto:[hidden email]>
>     >   
>      https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_r-2Dsig-2Dgeo&d=DwICAg&c=n6-cguzQvX_tUIrZOS_4Og&r=YFaRLkcUCdDkLrpTbNOUV9J1CwYBCTMwgm5tdQkRSm4&m=nytIIxO936Ls0xrd3zZkBd1WNjQB3DwlOK88GErq19M&s=uahwJjXmsZFnUVQXvkICr3EfAbNjOuaXl6iwziIexTM&e=
>     >     
>     >
>     >
>     > _______________________________________________
>     > R-sig-Geo mailing list
>     > [hidden email] <mailto:[hidden email]>
>     > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>     >
>
>     --
>     Edzer Pebesma
>     Institute for Geoinformatics
>     Heisenbergstrasse 2, 48151 Muenster, Germany
>     Phone: +49 251 8333081
>     _______________________________________________
>     R-sig-Geo mailing list
>     [hidden email] <mailto:[hidden email]>
>     https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> --
Edzer Pebesma
Institute for Geoinformatics
Heisenbergstrasse 2, 48151 Muenster, Germany
Phone: +49 251 8333081

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

pEpkey.asc (2K) Download Attachment

Re: tpk files

Thu, 04/11/2019 - 17:48
QGIS could "read" it pretty smartly, only loading in the bits in the
current view extent, and doing the loading in a separate thread so the GUI
was still active.

Marta has told me that she only needs the surface layer points - the X Y
and Z coordinates are duplicated as attributes so I think a selection of
Z=0 (or something) might make a small enough subset to read into R
directly. This might be doable via the `query` option of `st_read`, or
failing that a "select" in SQLite3 and dumping the results to a CSV file.
There seems to be hundreds of data points at each location so taking the
surface points only could thin it out considerably. It may still take some
time but if its a one-off...

Barry


On Thu, Apr 11, 2019 at 9:57 PM Edzer Pebesma <[hidden email]>
wrote:

> It's a 30 Gb 3D point file:
>
> $ ogrinfo EMU.gpkg
> INFO: Open of `EMU.gpkg'
>       using driver `GPKG' successful.
> 1: EMU_Master (3D Point)
>
> @Shaun: homebrew seems to be supported neither by apple, nor by CRAN, so
> you are a bit on your own there. Have you tried the CRAN binary packages
> using GDAL?
>
> In any case, the windows binary does (should) support gpkg, see
> https://github.com/rwinlib/gdal2
>
> Trying to read this file into R with sf::st_read will require a lot of
> RAM, or some strategy to read in parts only.
>
> On 4/11/19 5:52 PM, Shaun Walbridge wrote:
> > I think the issue is, most GDAL installations don't have the Geopackage
> raster driver [1] installed by default, which lists "Needs libsqlite3 (and
> any or all of PNG, JPEG, WEBP drivers)" for it to be available. At least on
> my Homebrew installation of GDAL, this driver wasn't built out of the box.
> If you rebuild GDAL with this additional driver, or find a prebuilt binary
> which has it, it should be able to open. A simple test is if `gdalinfo
> EMU.gpkg` returns information about the dataset outside of R.
> >
> > 1.
> https://urldefense.proofpoint.com/v2/url?u=https-3A__www.gdal.org_drv-5Fgeopackage-5Fraster.html&d=DwIGaQ&c=n6-cguzQvX_tUIrZOS_4Og&r=fCPRb7QX-vd5bnO9gIJHCiX852SVUtyYX--xtCKtpfk&m=p5ULiF5de1gKZBP-IzWbMO9Pe5LFzv9uaZ5VJYnWw1Y&s=d6xaKGlN0jpd8mBdjKXAhzst7N3Bgo43BvJlLnDSngk&e=
> >
> > On 4/11/19, 11:41 AM, "Barry Rowlingson" <[hidden email]>
> wrote:
> >
> >     What did you try? The instructions at the top say:
> >
> >     "Download 3.3GB tile package and rename extension from .tpk to .zip.
> >     Extract to get EMU.gpkg"
> >
> >     If that's a valid GeoPackage then `sf` should be able to read it.
> Not sure
> >     what might be in the geopackage though, "tile package" sounds like
> rasters,
> >     but GeoPackages are generally vector...
> >
> >     I'll try in five minutes when all 3.3Gb have downloaded....
> >
> >     On Thu, Apr 11, 2019 at 3:37 PM Marta Rufino <
> [hidden email]>
> >     wrote:
> >
> >     > Hi,
> >     >
> >     > I would like to open (and use) a 'tpk' file from arcgis in r.
> >     > For example:
> >     >
> >     >
> https://esri.maps.arcgis.com/home/item.html?id=24885cd6bd9544f5a8e15d0bf40f67d6
> >     >
> >     > I tried raster and sf package, but no luck.
> >     >
> >     > Any ideia if we can do this in r?
> >     >
> >     > Thank you very much in advance,
> >     >
> >     > Best wishes,
> >     > M.
> >     >
> >     >         [[alternative HTML version deleted]]
> >     >
> >     > _______________________________________________
> >     > R-sig-Geo mailing list
> >     > [hidden email]
> >     >
> https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_r-2Dsig-2Dgeo&d=DwICAg&c=n6-cguzQvX_tUIrZOS_4Og&r=YFaRLkcUCdDkLrpTbNOUV9J1CwYBCTMwgm5tdQkRSm4&m=nytIIxO936Ls0xrd3zZkBd1WNjQB3DwlOK88GErq19M&s=uahwJjXmsZFnUVQXvkICr3EfAbNjOuaXl6iwziIexTM&e=
> >     >
> >
> >       [[alternative HTML version deleted]]
> >
> >     _______________________________________________
> >     R-sig-Geo mailing list
> >     [hidden email]
> >
> https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_r-2Dsig-2Dgeo&d=DwICAg&c=n6-cguzQvX_tUIrZOS_4Og&r=YFaRLkcUCdDkLrpTbNOUV9J1CwYBCTMwgm5tdQkRSm4&m=nytIIxO936Ls0xrd3zZkBd1WNjQB3DwlOK88GErq19M&s=uahwJjXmsZFnUVQXvkICr3EfAbNjOuaXl6iwziIexTM&e=
> >
> >
> >
> > _______________________________________________
> > R-sig-Geo mailing list
> > [hidden email]
> > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> >
>
> --
> Edzer Pebesma
> Institute for Geoinformatics
> Heisenbergstrasse 2, 48151 Muenster, Germany
> Phone: +49 251 8333081
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
        [[alternative HTML version deleted]]

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

Creating a mean line plot

Thu, 04/11/2019 - 16:57
Hi there,
I am trying to create a mean line plot that shows the mean of a series of separate line plots that correspond to two climate models. Let's first try getting the mean of two line plots. To create the separate line plots, here is what I did to set up the x and y axis variables:

####Getting cumulative emissions data for x-axis: 1-dimensional ####

#For CanESM model#

ncfname <- "cumulative_emissions_1pctCO2.nc"
Model1 <- nc_open(ncfname)
get <- ncvar_get(Model1, "cum_co2_emi-CanESM2")     #units of terratones of carbon (TtC) for x-axis (140 values)
#For IPSL LR Model#
#Getting cumulative emissions data for x-axis IPSL LR 1pctCO2 IPSL <- ncvar_get(Model1, "cum_co2_emi-IPSL-CM5A-LR")     #units of terratones of carbon (TtC) for x-axis (140 values)

############################################################################################################

#####Getting precipitation data for y-axis - these are 3-dimensional####

#For CanESM2 model#
Model2 <- brick("MaxPrecCCCMACanESM21pctCO2.nc", var="onedaymax")


#For IPSL LR Model#
Model10 <- brick("MaxPrecIPSLIPSL-CM5A-LR1pctCO2.nc", var="onedaymax")
#############################################################################################################
To create plots for a specific location:
lonlat <- cbind(103,3)          #specifies a specific longitude and latitude
Hope2 <- extract(Model2,lonlat)      #CanESM2
Hope6 <- extract(Model10,lonlat)   #start IPSL CM5A LR
plot(get,Hope2, type="l",col="green", lwd="3", xlab="Cumulative CO2 emissions (TtC)", ylab="One-day maximum precipitation (mm/day)", main="One-day maximum precipitation for random location for 1pctCO2 scenario")
lines(IPSL, Hope6, type="l", lwd="3", col="green")
#############################################################################################################
So, the idea would be to create a plot that shows the mean of these two plots. Given what I showed above, how should I go about creating the mean of these two green line plots? Would you have to get the mean of the x-values, and then obtain the mean of the y-values, and then plot these?
Thanks, and any help 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: tpk files

Thu, 04/11/2019 - 15:56
It's a 30 Gb 3D point file:

$ ogrinfo EMU.gpkg
INFO: Open of `EMU.gpkg'
      using driver `GPKG' successful.
1: EMU_Master (3D Point)

@Shaun: homebrew seems to be supported neither by apple, nor by CRAN, so
you are a bit on your own there. Have you tried the CRAN binary packages
using GDAL?

In any case, the windows binary does (should) support gpkg, see
https://github.com/rwinlib/gdal2

Trying to read this file into R with sf::st_read will require a lot of
RAM, or some strategy to read in parts only.

On 4/11/19 5:52 PM, Shaun Walbridge wrote:
> I think the issue is, most GDAL installations don't have the Geopackage raster driver [1] installed by default, which lists "Needs libsqlite3 (and any or all of PNG, JPEG, WEBP drivers)" for it to be available. At least on my Homebrew installation of GDAL, this driver wasn't built out of the box. If you rebuild GDAL with this additional driver, or find a prebuilt binary which has it, it should be able to open. A simple test is if `gdalinfo EMU.gpkg` returns information about the dataset outside of R.
>
> 1. https://urldefense.proofpoint.com/v2/url?u=https-3A__www.gdal.org_drv-5Fgeopackage-5Fraster.html&d=DwIGaQ&c=n6-cguzQvX_tUIrZOS_4Og&r=fCPRb7QX-vd5bnO9gIJHCiX852SVUtyYX--xtCKtpfk&m=p5ULiF5de1gKZBP-IzWbMO9Pe5LFzv9uaZ5VJYnWw1Y&s=d6xaKGlN0jpd8mBdjKXAhzst7N3Bgo43BvJlLnDSngk&e=
>
> On 4/11/19, 11:41 AM, "Barry Rowlingson" <[hidden email]> wrote:
>
>     What did you try? The instructions at the top say:
>    
>     "Download 3.3GB tile package and rename extension from .tpk to .zip.
>     Extract to get EMU.gpkg"
>    
>     If that's a valid GeoPackage then `sf` should be able to read it. Not sure
>     what might be in the geopackage though, "tile package" sounds like rasters,
>     but GeoPackages are generally vector...
>    
>     I'll try in five minutes when all 3.3Gb have downloaded....
>    
>     On Thu, Apr 11, 2019 at 3:37 PM Marta Rufino <[hidden email]>
>     wrote:
>    
>     > Hi,
>     >
>     > I would like to open (and use) a 'tpk' file from arcgis in r.
>     > For example:
>     >
>     > https://esri.maps.arcgis.com/home/item.html?id=24885cd6bd9544f5a8e15d0bf40f67d6
>     >
>     > I tried raster and sf package, but no luck.
>     >
>     > Any ideia if we can do this in r?
>     >
>     > Thank you very much in advance,
>     >
>     > Best wishes,
>     > M.
>     >
>     >         [[alternative HTML version deleted]]
>     >
>     > _______________________________________________
>     > R-sig-Geo mailing list
>     > [hidden email]
>     > https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_r-2Dsig-2Dgeo&d=DwICAg&c=n6-cguzQvX_tUIrZOS_4Og&r=YFaRLkcUCdDkLrpTbNOUV9J1CwYBCTMwgm5tdQkRSm4&m=nytIIxO936Ls0xrd3zZkBd1WNjQB3DwlOK88GErq19M&s=uahwJjXmsZFnUVQXvkICr3EfAbNjOuaXl6iwziIexTM&e=
>     >
>    
>     [[alternative HTML version deleted]]
>    
>     _______________________________________________
>     R-sig-Geo mailing list
>     [hidden email]
>     https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_r-2Dsig-2Dgeo&d=DwICAg&c=n6-cguzQvX_tUIrZOS_4Og&r=YFaRLkcUCdDkLrpTbNOUV9J1CwYBCTMwgm5tdQkRSm4&m=nytIIxO936Ls0xrd3zZkBd1WNjQB3DwlOK88GErq19M&s=uahwJjXmsZFnUVQXvkICr3EfAbNjOuaXl6iwziIexTM&e=
>    
>
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> --
Edzer Pebesma
Institute for Geoinformatics
Heisenbergstrasse 2, 48151 Muenster, Germany
Phone: +49 251 8333081

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

pEpkey.asc (2K) Download Attachment

Re: tpk files

Thu, 04/11/2019 - 11:44
Briefly, could you use the proxy interface in stars and subset without reading the whole object? I'm not able to check now, but if the data are raster layers, perhaps temporal, stars may be helpful.

Roger

Roger Bivand
Norwegian School of Economics
Bergen, Norway



Fra: Marta Rufino
Sendt: torsdag 11. april, 17.58
Emne: Re: [R-sig-Geo] tpk files
Til: Barry Rowlingson
Kopi: r-sig-geo


Hi Barry, Thank you so much for your quik reply! Yep, I tried that... after downloading, changing the name and decompressing (it becomes 27GB), then I was not able to read it with r. I will try again then. Cheers, M. PS: now, it is giving me an error: Error in CPL_read_ogr(dsn, layer, query, as.character(options), quiet, : std::bad_alloc In addition: Warning message: In CPL_read_ogr(dsn, layer, query, as.character(options), quiet, : GDAL Error 1: In GetNextRawFeature(): sqlite3_step() : disk I/O error > Barry Rowlingson escreveu no dia quinta, 11/04/2019 à(s) 16:39: > What did you try? The instructions at the top say: > > "Download 3.3GB tile package and rename extension from .tpk to .zip. > Extract to get EMU.gpkg" > > If that's a valid GeoPackage then `sf` should be able to read it. Not sure > what might be in the geopackage though, "tile package" sounds like rasters, > but GeoPackages are generally vector... > > I'll try in five minutes when all 3.3Gb have downloaded.... > > Barry > > > > > On Thu, Apr 11, 2019 at 3:37 PM Marta Rufino > wrote: > >> Hi, >> >> I would like to open (and use) a 'tpk' file from arcgis in r. >> For example: >> >> https://esri.maps.arcgis.com/home/item.html?id=24885cd6bd9544f5a8e15d0bf40f67d6 >> >> I tried raster and sf package, but no luck. >> >> Any ideia if we can do this in r? >> >> Thank you very much in advance, >> >> Best wishes, >> M. >> >> [[alternative HTML version deleted]] >> >> _______________________________________________ >> R-sig-Geo mailing list >> [hidden email] >> https://stat.ethz.ch/mailman/listinfo/r-sig-geo >> > -- Marta M. Rufino (auxiliary researcher) *____________________________________________________*MARE - Marine and Environmental Sciences Centre Faculty of Sciences, University of Lisbon Campo Grande, 1749-016 Lisboa, Portugal Tel: + 351 21 750 00 00, extension: 22576 [[alternative HTML version deleted]] _______________________________________________ R-sig-Geo mailing list [hidden email] https://stat.ethz.ch/mailman/listinfo/r-sig-geo


        [[alternative HTML version deleted]]

_______________________________________________
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: tpk files

Thu, 04/11/2019 - 10:57
Hi Barry,

Thank you so much for your quik reply!
Yep, I tried that... after downloading, changing the name and decompressing
(it becomes 27GB), then I was not able to read it with r.
I will try again then.

Cheers,
M.

PS: now, it is giving me an error:

Error in CPL_read_ogr(dsn, layer, query, as.character(options), quiet,  :
  std::bad_alloc
In addition: Warning message:
In CPL_read_ogr(dsn, layer, query, as.character(options), quiet,  :
  GDAL Error 1: In GetNextRawFeature(): sqlite3_step() : disk I/O error
>

Barry Rowlingson <[hidden email]> escreveu no dia quinta,
11/04/2019 à(s) 16:39:

> What did you try? The instructions at the top say:
>
> "Download 3.3GB tile package and rename extension from .tpk to .zip.
> Extract to get EMU.gpkg"
>
> If that's a valid GeoPackage then `sf` should be able to read it. Not sure
> what might be in the geopackage though, "tile package" sounds like rasters,
> but GeoPackages are generally vector...
>
> I'll try in five minutes when all 3.3Gb have downloaded....
>
> Barry
>
>
>
>
> On Thu, Apr 11, 2019 at 3:37 PM Marta Rufino <[hidden email]>
> wrote:
>
>> Hi,
>>
>> I would like to open (and use) a 'tpk' file from arcgis in r.
>> For example:
>>
>> https://esri.maps.arcgis.com/home/item.html?id=24885cd6bd9544f5a8e15d0bf40f67d6
>>
>> I tried raster and sf package, but no luck.
>>
>> Any ideia if we can do this in r?
>>
>> Thank you very much in advance,
>>
>> Best wishes,
>> M.
>>
>>         [[alternative HTML version deleted]]
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> [hidden email]
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
>
--
Marta M. Rufino (auxiliary researcher)

*____________________________________________________*MARE - Marine and
Environmental Sciences Centre
Faculty of Sciences, University of Lisbon
Campo Grande, 1749-016 Lisboa,
Portugal
Tel: + 351 21 750 00 00, extension: 22576

        [[alternative HTML version deleted]]

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

Re: tpk files

Thu, 04/11/2019 - 10:52
I think the issue is, most GDAL installations don't have the Geopackage raster driver [1] installed by default, which lists "Needs libsqlite3 (and any or all of PNG, JPEG, WEBP drivers)" for it to be available. At least on my Homebrew installation of GDAL, this driver wasn't built out of the box. If you rebuild GDAL with this additional driver, or find a prebuilt binary which has it, it should be able to open. A simple test is if `gdalinfo EMU.gpkg` returns information about the dataset outside of R.

1. https://urldefense.proofpoint.com/v2/url?u=https-3A__www.gdal.org_drv-5Fgeopackage-5Fraster.html&d=DwIGaQ&c=n6-cguzQvX_tUIrZOS_4Og&r=fCPRb7QX-vd5bnO9gIJHCiX852SVUtyYX--xtCKtpfk&m=p5ULiF5de1gKZBP-IzWbMO9Pe5LFzv9uaZ5VJYnWw1Y&s=d6xaKGlN0jpd8mBdjKXAhzst7N3Bgo43BvJlLnDSngk&e=

On 4/11/19, 11:41 AM, "Barry Rowlingson" <[hidden email]> wrote:

    What did you try? The instructions at the top say:
   
    "Download 3.3GB tile package and rename extension from .tpk to .zip.
    Extract to get EMU.gpkg"
   
    If that's a valid GeoPackage then `sf` should be able to read it. Not sure
    what might be in the geopackage though, "tile package" sounds like rasters,
    but GeoPackages are generally vector...
   
    I'll try in five minutes when all 3.3Gb have downloaded....
   
    On Thu, Apr 11, 2019 at 3:37 PM Marta Rufino <[hidden email]>
    wrote:
   
    > Hi,
    >
    > I would like to open (and use) a 'tpk' file from arcgis in r.
    > For example:
    >
    > https://esri.maps.arcgis.com/home/item.html?id=24885cd6bd9544f5a8e15d0bf40f67d6
    >
    > I tried raster and sf package, but no luck.
    >
    > Any ideia if we can do this in r?
    >
    > Thank you very much in advance,
    >
    > Best wishes,
    > M.
    >
    >         [[alternative HTML version deleted]]
    >
    > _______________________________________________
    > R-sig-Geo mailing list
    > [hidden email]
    > https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_r-2Dsig-2Dgeo&d=DwICAg&c=n6-cguzQvX_tUIrZOS_4Og&r=YFaRLkcUCdDkLrpTbNOUV9J1CwYBCTMwgm5tdQkRSm4&m=nytIIxO936Ls0xrd3zZkBd1WNjQB3DwlOK88GErq19M&s=uahwJjXmsZFnUVQXvkICr3EfAbNjOuaXl6iwziIexTM&e=
    >
   
    [[alternative HTML version deleted]]
   
    _______________________________________________
    R-sig-Geo mailing list
    [hidden email]
    https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_r-2Dsig-2Dgeo&d=DwICAg&c=n6-cguzQvX_tUIrZOS_4Og&r=YFaRLkcUCdDkLrpTbNOUV9J1CwYBCTMwgm5tdQkRSm4&m=nytIIxO936Ls0xrd3zZkBd1WNjQB3DwlOK88GErq19M&s=uahwJjXmsZFnUVQXvkICr3EfAbNjOuaXl6iwziIexTM&e=
   


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

Pages