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: 40 min 39 sec ago

Re: converting raster to netcdf .nc with keeping CRS information

Tue, 02/12/2019 - 08:19
Thanks Ben for your suggestion.

Adding *prj = TRUE *argument caused this error:
           Error in ncdf4::ncvar_def(varname, varunit, list(xdim, ydim),
NAvalue(x),  :
           unused argument (prj = T)

Ahmed

On Tue, Feb 12, 2019 at 3:13 PM Ben Tupper <[hidden email]> wrote:

> Hi,
>
> Have you tried using the 'prj' argument to writeRaster?  I don't know that
> it will be the solution, but according to ...
>
>
> https://www.rdocumentation.org/packages/raster/versions/2.8-19/topics/writeRaster
>
> It is documented among the '...' arguments.  Setting prj = TRUE will cause
> the crs to be written to the file.
>
> Cheers,
> Ben
>
> On Feb 12, 2019, at 8:34 AM, Ahmed El-Gabbas <[hidden email]> wrote:
>
> Hello all,
>
> I am having a problem while converting a raster object as NetCDF (.nc)
> file, with keeping the CRS information in the output file.
> Here is a reproducible code:
>
> require(raster)
> require(ncdf4)
> CurrTemp <- tempfile()
> download.file(url = "https://seaice.uni-bremen.de/data/amsre/asi_daygrid_swath/s6250/2003/feb/Antarctic/asi-s6250-20030214-v5.hdf", destfile = CurrTemp, mode = "wb", quiet = T)
> r <- raster(CurrTemp)
> r <- flip(r,2)
> extent(r) <- c(-3950000, 3950000, -3950000, 4350000)
> crs(r) <- "+proj=stere +lat_0=-90 +lat_ts=-70 +lon_0=0 +k=1 +x_0=0 +y_0=0 +a=6378273 +b=6356889.449 +units=m +no_defs"
> r# class       : RasterLayer # dimensions  : 1328, 1264, 1678592  (nrow, ncol, ncell)# resolution  : 6250, 6250  (x, y)# extent      : -3950000, 3950000, -3950000, 4350000  (xmin, xmax, ymin, ymax)# coord. ref. : +proj=stere +lat_0=-90 +lat_ts=-70 +lon_0=0 +k=1 +x_0=0 +y_0=0 +a=6378273 +b=6356889.449 +units=m +no_defs # data source : in memory# names       : layer # values      : 0, 100  (min, max)
>
> So far the raster object reads well, with CRS information included.
> However, when I try to save it as .nc file, R prints "coord. ref. : NA",
> and the produced file does not contain the CRS information.
>
> writeRaster(r, filename = "O:/Ahmed/r001.nc", varname="IceConc",
>             overwrite=TRUE, format="CDF",
>             xname="Longitude", yname="Latitude")# class       : RasterLayer # dimensions  : 1328, 1264, 1678592  (nrow, ncol, ncell)# resolution  : 6250, 6250  (x, y)# extent      : -3950000, 3950000, -3950000, 4350000  (xmin, xmax, ymin, ymax)# coord. ref. : NA # data source : O:/Ahmed/r001.nc # names       : IceConc # zvar        : IceConc
>
> raster("O:/Ahmed/r001.nc")# class       : RasterLayer # dimensions  : 1328, 1264, 1678592  (nrow, ncol, ncell)# resolution  : 6250, 6250  (x, y)# extent      : -3950000, 3950000, -3950000, 4350000  (xmin, xmax, ymin, ymax)# coord. ref. : NA # data source : O:/Ahmed/r001.nc # names       : IceConc # zvar        : IceConc
>
> Any solution?
>
> N.B. I also sent the same question at stackoverflow
> <https://stackoverflow.com/questions/54593552/saving-r-raster-to-netcdf-nc-file-with-keeping-crs-information>,
> without a solution so far.
>
> Thanks
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> *Dr. Ahmed El-Gabbas,*
> Ocean Acoustics Lab,
> Alfred-Wegener-Institut
> Helmholtz-Zentrum für Polar und Meeresforschung
> <image.png>
> My Website:  https://elgabbas.github.io
> _______________________________________________
> 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: converting raster to netcdf .nc with keeping CRS information

Tue, 02/12/2019 - 08:13
Hi,

Have you tried using the 'prj' argument to writeRaster?  I don't know that it will be the solution, but according to ...

https://www.rdocumentation.org/packages/raster/versions/2.8-19/topics/writeRaster <https://www.rdocumentation.org/packages/raster/versions/2.8-19/topics/writeRaster>

It is documented among the '...' arguments.  Setting prj = TRUE will cause the crs to be written to the file.

Cheers,
Ben

> On Feb 12, 2019, at 8:34 AM, Ahmed El-Gabbas <[hidden email]> wrote:
>
> Hello all,
>
> I am having a problem while converting a raster object as NetCDF (.nc) file, with keeping the CRS information in the output file.
> Here is a reproducible code:
> require(raster)
> require(ncdf4)
> CurrTemp <- tempfile()
> download.file(url = "https://seaice.uni-bremen.de/data/amsre/asi_daygrid_swath/s6250/2003/feb/Antarctic/asi-s6250-20030214-v5.hdf <https://seaice.uni-bremen.de/data/amsre/asi_daygrid_swath/s6250/2003/feb/Antarctic/asi-s6250-20030214-v5.hdf>", destfile = CurrTemp, mode = "wb", quiet = T)
> r <- raster(CurrTemp)
> r <- flip(r,2)
> extent(r) <- c(-3950000, 3950000, -3950000, 4350000)
> crs(r) <- "+proj=stere +lat_0=-90 +lat_ts=-70 +lon_0=0 +k=1 +x_0=0 +y_0=0 +a=6378273 +b=6356889.449 +units=m +no_defs"
> r
> # class       : RasterLayer
> # dimensions  : 1328, 1264, 1678592  (nrow, ncol, ncell)
> # resolution  : 6250, 6250  (x, y)
> # extent      : -3950000, 3950000, -3950000, 4350000  (xmin, xmax, ymin, ymax)
> # coord. ref. : +proj=stere +lat_0=-90 +lat_ts=-70 +lon_0=0 +k=1 +x_0=0 +y_0=0 +a=6378273 +b=6356889.449 +units=m +no_defs
> # data source : in memory
> # names       : layer
> # values      : 0, 100  (min, max)
> So far the raster object reads well, with CRS information included.
> However, when I try to save it as .nc file, R prints "coord. ref. : NA", and the produced file does not contain the CRS information.
> writeRaster(r, filename = "O:/Ahmed/r001.nc <http://r001.nc/>", varname="IceConc",
>             overwrite=TRUE, format="CDF",
>             xname="Longitude", yname="Latitude")
> # class       : RasterLayer
> # dimensions  : 1328, 1264, 1678592  (nrow, ncol, ncell)
> # resolution  : 6250, 6250  (x, y)
> # extent      : -3950000, 3950000, -3950000, 4350000  (xmin, xmax, ymin, ymax)
> # coord. ref. : NA
> # data source : O:/Ahmed/r001.nc <http://r001.nc/>
> # names       : IceConc
> # zvar        : IceConc
>
> raster("O:/Ahmed/r001.nc <http://r001.nc/>")
> # class       : RasterLayer
> # dimensions  : 1328, 1264, 1678592  (nrow, ncol, ncell)
> # resolution  : 6250, 6250  (x, y)
> # extent      : -3950000, 3950000, -3950000, 4350000  (xmin, xmax, ymin, ymax)
> # coord. ref. : NA
> # data source : O:/Ahmed/r001.nc <http://r001.nc/>
> # names       : IceConc
> # zvar        : IceConc
> Any solution?
>
> N.B. I also sent the same question at stackoverflow <https://stackoverflow.com/questions/54593552/saving-r-raster-to-netcdf-nc-file-with-keeping-crs-information>, without a solution so far.
>
> Thanks
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Dr. Ahmed El-Gabbas,
> Ocean Acoustics Lab,
> Alfred-Wegener-Institut
> Helmholtz-Zentrum für Polar und Meeresforschung
> <image.png>
> My Website:  https://elgabbas.github.io <https://elgabbas.github.io/>_______________________________________________
> 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

converting raster to netcdf .nc with keeping CRS information

Tue, 02/12/2019 - 07:34

Hello all,


I am having a problem while converting a raster object as NetCDF (.nc) file, with keeping the CRS information in the output file.

Here is a reproducible code:

require(raster) require(ncdf4) CurrTemp <- tempfile() download.file(url = "https://seaice.uni-bremen.de/data/amsre/asi_daygrid_swath/s6250/2003/feb/Antarctic/asi-s6250-20030214-v5.hdf", destfile = CurrTemp, mode = "wb", quiet = T) r <- raster(CurrTemp) r <- flip(r,2) extent(r) <- c(-3950000, 3950000, -3950000, 4350000) crs(r) <- "+proj=stere +lat_0=-90 +lat_ts=-70 +lon_0=0 +k=1 +x_0=0 +y_0=0 +a=6378273 +b=6356889.449 +units=m +no_defs" r # class : RasterLayer # dimensions : 1328, 1264, 1678592 (nrow, ncol, ncell) # resolution : 6250, 6250 (x, y) # extent : -3950000, 3950000, -3950000, 4350000 (xmin, xmax, ymin, ymax) # coord. ref. : +proj=stere +lat_0=-90 +lat_ts=-70 +lon_0=0 +k=1 +x_0=0 +y_0=0 +a=6378273 +b=6356889.449 +units=m +no_defs # data source : in memory # names : layer # values : 0, 100 (min, max)

So far the raster object reads well, with CRS information included.

However, when I try to save it as .nc file, R prints "coord. ref. : NA", and the produced file does not contain the CRS information.

writeRaster(r, filename = "O:/Ahmed/r001.nc", varname="IceConc", overwrite=TRUE, format="CDF", xname="Longitude", yname="Latitude") # class : RasterLayer # dimensions : 1328, 1264, 1678592 (nrow, ncol, ncell) # resolution : 6250, 6250 (x, y) # extent : -3950000, 3950000, -3950000, 4350000 (xmin, xmax, ymin, ymax) # coord. ref. : NA # data source : O:/Ahmed/r001.nc # names : IceConc # zvar : IceConc raster("O:/Ahmed/r001.nc") # class : RasterLayer # dimensions : 1328, 1264, 1678592 (nrow, ncol, ncell) # resolution : 6250, 6250 (x, y) # extent : -3950000, 3950000, -3950000, 4350000 (xmin, xmax, ymin, ymax) # coord. ref. : NA # data source : O:/Ahmed/r001.nc # names : IceConc # zvar : IceConc

Any solution?


N.B. I also sent the same question at stackoverflow, without a solution so far.


Thanks


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dr. Ahmed El-Gabbas, Ocean Acoustics Lab, Alfred-Wegener-Institut Helmholtz-Zentrum für Polar und Meeresforschung
My Website:  https://elgabbas.github.io
_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Re: Sampling random directional lines within a polygon

Wed, 02/06/2019 - 17:41
Had another idea which is now implemented...

Consider any segmented path of segments of lengths L_i at angles A_i. Its
endpoint will be the vector sum of those segments, ie at (x,y) = (sum(L_i
cos(A_i)), sum(L_i sin(A_i)).

To create a segmented path to a given (x,y), solve that expression for the
angles A_i. In R you can treat this as an optimisation problem - find a set
of angles A_i that minimise the distance of the end of the segmented path
from the target end point.

Here's some code that does that for a path from 0,0 to 0,1:

pathit <- function(segments){
    obj = function(angles){
        dxdy = dxdy(segments, angles)
        xerr = dxdy$dx-1
        yerr = dxdy$dy
        err = sqrt(xerr^2 + yerr^2)
        err
    }
    angles = runif(length(segments), 0 , 2*pi)
    optim(angles, obj)
}

dxdy = function(segments, angles){
    dx = sum(segments * cos(angles))
    dy = sum(segments * sin(angles))
    list(dx=dx, dy=dy)
}

plotsegs <- function(segments, angles){
    x = rep(NA, length(segments) +1)
    y = x
    x[1] = 0
    y[1] = 0
    for(i in 2:(length(segments)+1)){
        x[i] = x[i-1] + segments[i-1]*cos(angles[i-1])
        y[i] = y[i-1] + segments[i-1]*sin(angles[i-1])
    }
    cbind(x,y)
}

This is deliberately written naively for clarity.

To use, set the segment sizes, optimise, and then plot:

 s1 = c(.1,.3,.2,.1,.3,.3,.1)
 a1 = pathit(s1)
 plot(plotsegs(s1,a1$par),type="l")

which should show a path of seven segments from 0,0 to 0,1 - since the
initial starting values are random the model can find different solutions.
Run again for a different path.

To see what the space of paths looks like, do lots and overplot them:

  lots = lapply(1:1000, function(i)plotsegs(s1,pathit(s1)$par))
  plot(c(-.1,1.1),c(-1,1))
  p = lapply(lots, function(xy){lines(xy)})

this should show 1000 paths, and illustrates the "ellipse" of path
possibles that I mentioned in the previous email.

Sometimes the optimiser struggles to find a solution and so you should
probably test the output from optim for convergence and to make sure the
target function is close enough to zero for your purposes.  For the example
above most of the time the end point is about 1e-5  from (1,0) but for
harder problems such as s = rep(.1, 11) which only has 0.1 of extra "slack"
length, the error can be 0.02 and failed convergence. Possibly longer optim
runs would help or constraining the angles.

Anyway, interesting problem....

Barry







On Wed, Feb 6, 2019 at 8:23 PM Barry Rowlingson <[hidden email]>
wrote:

> Do you want to generate these for input into some statistical process, or
> to generate some test data that looks a bit like real data? I think
> generating test data isn't too difficult, but anything that you might want
> to put into a statistical test (eg testing some hypothesis about the birds
> maximum deviation from the straight line A-B) needs a lot more care in
> formulating the path generating process.
>
> Here's some thoughts - if you consider one of the red segments in your map
> as a piece of string (rather than 10 segments) anchored at the points, then
> you can stretch it taut with a pencil and draw an ellipse with A and B as
> the foci. Any path created with that string - taut or slack as in your map
> - has to strictly lie within the ellipse. Now you can wiggle that string
> inside that ellipse and create an infinity of paths from A to B of the same
> length. I'm not sure how you can sample uniformly from that infinity such
> that any path has an equal sampling probability. Your problem is similar
> but has the additional rigid segment constraint.
>
> Any two adjacent segments of a chain, eg 1----2-------3, as long as it
> isn't taut (ie straight) can be perturbed by holding 1 and 3 still and
> moving 2 to the "mirror image" point over the straight line from 1 to 3.
> You can also take three segments 1--2--3--4 and hold 1 and 4 still and
> perturb 2 and 3 fairly easily. In this way you could set up an initial
> chain and then run multiple perturbations on the chain to get a "random"
> chain, but quite what set of all chains it would be a sample from is not
> clear. It could at least generate reasonable looking paths, but I wouldn't
> want to test a hypothesis against it.
>
> I'm going to generate a path from my office to my home now.
>
> Barry
>
>
>
>
>
>
> On Wed, Feb 6, 2019 at 7:50 PM Hannah Justen <[hidden email]> wrote:
>
>> Hello everyone,
>>
>> Thank you very much for the suggestions.
>>
>> Regarding more details (please also see attached figure):
>> I would like to simulate a bird's migration between breeding (starting
>> polygon - blue in the figure) and wintering grounds (end polygon - green in
>> the figure). The lines can start from anywhere within the starting polygon
>> and end anywhere in the end polygon. The lines shall consist of 10
>> connected segments with variable length between 300 and 1000 km (see red
>> lines in figure; two examples of possible lines with 10 segments between
>> the polygons).
>>
>> Thank you very much for you help,
>> Hannah
>>
>> ---
>> PhD Student |Ecology and Evolutionary Biology
>> Texas A&M University
>>
>> On Wed, Feb 6, 2019 at 5:12 AM Barry Rowlingson <
>> [hidden email]> wrote:
>>
>>> Interesting, but I think we need more details...
>>>
>>> Do the lines have to start and finish at specific locations in the
>>> polygons - like the centroid, or anywhere?
>>>
>>> So one line might be 3 segments of 10km each connecting two polygon
>>> centroids that are 15km apart? Imagining three rigid rods of length 10
>>> connected at their ends and with the first and last also connected to two
>>> fixed points tells me there's an infinite number of possible solutions.
>>> There's probably also a number of ways of sampling from those solutions.
>>> Its going to get very complicated with a larger number of segments.
>>>
>>> Hmmmmm.....
>>>
>>> Barry
>>>
>>>
>>>
>>>
>>> On Tue, Feb 5, 2019 at 11:30 PM Hannah Justen <[hidden email]> wrote:
>>>
>>>> Hi everyone,
>>>>
>>>> I am studying migratory tracks of birds for my dissertation and I would
>>>> like to model possible pathways between two polygons. Therefore, I would
>>>> like to sample random lines between the polygons. These lines can
>>>> differ in
>>>> total length but should consist of x - number of fragments of equal
>>>> length.
>>>> Each fragment can have slightly different orientation but overall the
>>>> lines
>>>> should connect the two polygons.
>>>>
>>>> I fail to find the appropriate R package that will allow me to do this
>>>> type
>>>> of analysis. Does anyone have a suggestion how to approach analysis?
>>>>
>>>> Thank you,
>>>> Hannah
>>>>
>>>> ---
>>>> PhD Student |Ecology and Evolutionary Biology
>>>> Texas A&M University
>>>>
>>>>         [[alternative HTML version deleted]]
>>>>
>>>> _______________________________________________
>>>> R-sig-Geo mailing list
>>>> [hidden email]
>>>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>>> <https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_r-2Dsig-2Dgeo&d=DwMFaQ&c=ODFT-G5SujMiGrKuoJJjVg&r=JTKhaSJXwF2BxCfjjnt61w&m=RH21jOLOEbLLudn70kOTH0wnklnKHk-tFm9cxjxAB9k&s=H_HhNMga7aaqbnNsWexqY1jdRFFo7zO_m9xvk2awODo&e=>
>>>>
>>>
        [[alternative HTML version deleted]]

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

Re: Sampling random directional lines within a polygon

Wed, 02/06/2019 - 14:23
Do you want to generate these for input into some statistical process, or
to generate some test data that looks a bit like real data? I think
generating test data isn't too difficult, but anything that you might want
to put into a statistical test (eg testing some hypothesis about the birds
maximum deviation from the straight line A-B) needs a lot more care in
formulating the path generating process.

Here's some thoughts - if you consider one of the red segments in your map
as a piece of string (rather than 10 segments) anchored at the points, then
you can stretch it taut with a pencil and draw an ellipse with A and B as
the foci. Any path created with that string - taut or slack as in your map
- has to strictly lie within the ellipse. Now you can wiggle that string
inside that ellipse and create an infinity of paths from A to B of the same
length. I'm not sure how you can sample uniformly from that infinity such
that any path has an equal sampling probability. Your problem is similar
but has the additional rigid segment constraint.

Any two adjacent segments of a chain, eg 1----2-------3, as long as it
isn't taut (ie straight) can be perturbed by holding 1 and 3 still and
moving 2 to the "mirror image" point over the straight line from 1 to 3.
You can also take three segments 1--2--3--4 and hold 1 and 4 still and
perturb 2 and 3 fairly easily. In this way you could set up an initial
chain and then run multiple perturbations on the chain to get a "random"
chain, but quite what set of all chains it would be a sample from is not
clear. It could at least generate reasonable looking paths, but I wouldn't
want to test a hypothesis against it.

I'm going to generate a path from my office to my home now.

Barry






On Wed, Feb 6, 2019 at 7:50 PM Hannah Justen <[hidden email]> wrote:

> Hello everyone,
>
> Thank you very much for the suggestions.
>
> Regarding more details (please also see attached figure):
> I would like to simulate a bird's migration between breeding (starting
> polygon - blue in the figure) and wintering grounds (end polygon - green in
> the figure). The lines can start from anywhere within the starting polygon
> and end anywhere in the end polygon. The lines shall consist of 10
> connected segments with variable length between 300 and 1000 km (see red
> lines in figure; two examples of possible lines with 10 segments between
> the polygons).
>
> Thank you very much for you help,
> Hannah
>
> ---
> PhD Student |Ecology and Evolutionary Biology
> Texas A&M University
>
> On Wed, Feb 6, 2019 at 5:12 AM Barry Rowlingson <
> [hidden email]> wrote:
>
>> Interesting, but I think we need more details...
>>
>> Do the lines have to start and finish at specific locations in the
>> polygons - like the centroid, or anywhere?
>>
>> So one line might be 3 segments of 10km each connecting two polygon
>> centroids that are 15km apart? Imagining three rigid rods of length 10
>> connected at their ends and with the first and last also connected to two
>> fixed points tells me there's an infinite number of possible solutions.
>> There's probably also a number of ways of sampling from those solutions.
>> Its going to get very complicated with a larger number of segments.
>>
>> Hmmmmm.....
>>
>> Barry
>>
>>
>>
>>
>> On Tue, Feb 5, 2019 at 11:30 PM Hannah Justen <[hidden email]> wrote:
>>
>>> Hi everyone,
>>>
>>> I am studying migratory tracks of birds for my dissertation and I would
>>> like to model possible pathways between two polygons. Therefore, I would
>>> like to sample random lines between the polygons. These lines can differ
>>> in
>>> total length but should consist of x - number of fragments of equal
>>> length.
>>> Each fragment can have slightly different orientation but overall the
>>> lines
>>> should connect the two polygons.
>>>
>>> I fail to find the appropriate R package that will allow me to do this
>>> type
>>> of analysis. Does anyone have a suggestion how to approach analysis?
>>>
>>> Thank you,
>>> Hannah
>>>
>>> ---
>>> PhD Student |Ecology and Evolutionary Biology
>>> Texas A&M University
>>>
>>>         [[alternative HTML version deleted]]
>>>
>>> _______________________________________________
>>> R-sig-Geo mailing list
>>> [hidden email]
>>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>> <https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_r-2Dsig-2Dgeo&d=DwMFaQ&c=ODFT-G5SujMiGrKuoJJjVg&r=JTKhaSJXwF2BxCfjjnt61w&m=RH21jOLOEbLLudn70kOTH0wnklnKHk-tFm9cxjxAB9k&s=H_HhNMga7aaqbnNsWexqY1jdRFFo7zO_m9xvk2awODo&e=>
>>>
>>
        [[alternative HTML version deleted]]

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

Re: Book: “Spatio-Temporal Statistics with R,” by Christopher K. Wikle, Andrew Zammit-Mangion, and Noel Cressie

Wed, 02/06/2019 - 09:09
I got mine last night too!


On Tue, Feb 5, 2019 at 3:00 PM Rich Shepard <[hidden email]>
wrote:

> On Tue, 5 Feb 2019, Rich Shepard wrote:
>
> > When a project budget allows I'll also buy a dead tree version so I can
> read
> > it everywhere.
>
> Well! The discounted price was too compelling so I ordered a copy and it
> will be here by the end of the month.
>
> Regards,
>
> Rich
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> --
Erin Hodgess, PhD
mailto: [hidden email]

        [[alternative HTML version deleted]]

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

Re: Sampling random directional lines within a polygon

Wed, 02/06/2019 - 06:45
[reposting to list after a bounce...]

Interesting, but I think we need more details...

Do the lines have to start and finish at specific locations in the polygons
- like the centroid, or anywhere?

So one line might be 3 segments of 10km each connecting two polygon
centroids that are 15km apart? Imagining three rigid rods of length 10
connected at their ends and with the first and last also connected to two
fixed points tells me there's an infinite number of possible solutions.
There's probably also a number of ways of sampling from those solutions.
Its going to get very complicated with a larger number of segments.

Hmmmmm.....

On Tue, Feb 5, 2019 at 11:30 PM Hannah Justen <[hidden email]> wrote:

> Hi everyone,
>
> I am studying migratory tracks of birds for my dissertation and I would
> like to model possible pathways between two polygons. Therefore, I would
> like to sample random lines between the polygons. These lines can differ in
> total length but should consist of x - number of fragments of equal length.
> Each fragment can have slightly different orientation but overall the lines
> should connect the two polygons.
>
> I fail to find the appropriate R package that will allow me to do this type
> of analysis. Does anyone have a suggestion how to approach analysis?
>
> Thank you,
> Hannah
>
> ---
> PhD Student |Ecology and Evolutionary Biology
> Texas A&M University
>
>         [[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: Sampling random directional lines within a polygon

Tue, 02/05/2019 - 18:13
Have you seen plotKML, please?  Or space time?

On Tue, Feb 5, 2019 at 4:31 PM Hannah Justen <[hidden email]> wrote:

> Hi everyone,
>
> I am studying migratory tracks of birds for my dissertation and I would
> like to model possible pathways between two polygons. Therefore, I would
> like to sample random lines between the polygons. These lines can differ in
> total length but should consist of x - number of fragments of equal length.
> Each fragment can have slightly different orientation but overall the lines
> should connect the two polygons.
>
> I fail to find the appropriate R package that will allow me to do this type
> of analysis. Does anyone have a suggestion how to approach analysis?
>
> Thank you,
> Hannah
>
> ---
> PhD Student |Ecology and Evolutionary Biology
> Texas A&M University
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> --
Erin Hodgess, PhD
mailto: [hidden email]

        [[alternative HTML version deleted]]

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

Sampling random directional lines within a polygon

Tue, 02/05/2019 - 17:30
Hi everyone,

I am studying migratory tracks of birds for my dissertation and I would
like to model possible pathways between two polygons. Therefore, I would
like to sample random lines between the polygons. These lines can differ in
total length but should consist of x - number of fragments of equal length.
Each fragment can have slightly different orientation but overall the lines
should connect the two polygons.

I fail to find the appropriate R package that will allow me to do this type
of analysis. Does anyone have a suggestion how to approach analysis?

Thank you,
Hannah

---
PhD Student |Ecology and Evolutionary Biology
Texas A&M University

        [[alternative HTML version deleted]]

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

Re: Book: “Spatio-Temporal Statistics with R,” by Christopher K. Wikle, Andrew Zammit-Mangion, and Noel Cressie

Tue, 02/05/2019 - 16:00
On Tue, 5 Feb 2019, Rich Shepard wrote:

> When a project budget allows I'll also buy a dead tree version so I can read
> it everywhere.

Well! The discounted price was too compelling so I ordered a copy and it
will be here by the end of the month.

Regards,

Rich

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

Re: Book: “Spatio-Temporal Statistics with R,” by Christopher K. Wikle, Andrew Zammit-Mangion, and Noel Cressie

Tue, 02/05/2019 - 15:36
On Tue, 5 Feb 2019, Andrew Zammit Mangion wrote:

> The book is available as a free downloadable PDF at
> https://spacetimewithr.org. This website also gives information on how to
> install the accompanying R package ?STRbook? that contains helper
> functions for use in the Labs, and a discount code for the hardcover
> version.

Christopher, Andrew, and Noel:

Thank you all very much for the ability to download the book as a PDF file.
When a project budget allows I'll also buy a dead tree version so I can read
it everywhere.

Best regards,

Rich

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

Re: Book: “Spatio-Temporal Statistics with R,” by Christopher K. Wikle, Andrew Zammit-Mangion, and Noel Cressie

Tue, 02/05/2019 - 15:34
This looks totally awesome!  Will check it out right away!

Sincerely,
Erin


On Tue, Feb 5, 2019 at 2:20 PM Andrew Zammit Mangion <[hidden email]> wrote:

> Wikle, Zammit-Mangion, and Cressie (2019) is a recently published Chapman
> & Hall/CRC book: "Spatio-Temporal Statistics with R.” The book is a blend
> of theory and hands-on Labs in R, which show how to visualize and model
> spatio-temporal data, as well as diagnose model predictions.
>
> The book is available as a free downloadable PDF at
> https://spacetimewithr.org. This website also gives information on how to
> install the accompanying R package “STRbook” that contains helper functions
> for use in the Labs, and a discount code for the hardcover version.
>
> Christopher K. Wikle
> Andrew Zammit-Mangion
> Noel Cressie
>
> NOTICE: This email is intended for the addressee named and may contain
> confidential information. If you are not the intended recipient, please
> delete it and notify the sender. Please consider the environment before
> printing this email.
>
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> --
Erin Hodgess, PhD
mailto: [hidden email]

        [[alternative HTML version deleted]]

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

Book: “Spatio-Temporal Statistics with R,” by Christopher K. Wikle, Andrew Zammit-Mangion, and Noel Cressie

Tue, 02/05/2019 - 15:19
Wikle, Zammit-Mangion, and Cressie (2019) is a recently published Chapman & Hall/CRC book: "Spatio-Temporal Statistics with R.� The book is a blend of theory and hands-on Labs in R, which show how to visualize and model spatio-temporal data, as well as diagnose model predictions.

The book is available as a free downloadable PDF at  https://spacetimewithr.org. This website also gives information on how to install the accompanying R package �STRbook� that contains helper functions for use in the Labs, and a discount code for the hardcover version.

Christopher K. Wikle
Andrew Zammit-Mangion
Noel Cressie

NOTICE: This email is intended for the addressee named and may contain confidential information. If you are not the intended recipient, please delete it and notify the sender. Please consider the environment before printing this email.


        [[alternative HTML version deleted]]


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

Re: How to get the coordinates (latitude/longitude) of a continent outline?

Sat, 02/02/2019 - 13:40
Hi,

Yes, I flubbed that.  I had it in my head that this...

https://www.naturalearthdata.com/downloads/110m-physical-vectors/110m-land/ <https://www.naturalearthdata.com/downloads/110m-physical-vectors/110m-land/>

... had Africa as a stand alone polygon, but that is not so.  Sorry for the noise.

Ben

> On Feb 2, 2019, at 10:17 AM, Sohrab Abbasnejad <[hidden email]> wrote:
>
> Dear Ben,
>
> Thank you for your reply.
>
> So far as I am aware, the rnaturalearth package provides information about countries within a continent, states within countries and "world" coastline (subsetting the coastline is not possible). Nevertheless, the package does not include maps/data of "continents". What I need is the coordinates of Africa's outline (as a single entity), not the coordinates of countries' outlines within Africa.
>
> Best,
> Sohrab
>
>
> On ‎Saturday‎, ‎February‎ ‎2‎, ‎2019‎ ‎03‎:‎38‎:‎25‎ ‎PM‎ ‎CET, Ben Tupper wrote:
>
>
> Hi,
>
> There is a whole world of options (sorry for the lame pun!), but I would recommend checking out ROpenSci's rnaturalearth package
>
> https://ropensci.org/tutorials/rnaturalearth_tutorial/ <https://ropensci.org/tutorials/rnaturalearth_tutorial/>
>
> https://CRAN.R-project.org/package=rnaturalearth <https://cran.r-project.org/package=rnaturalearth>
>
> Ben
>
>> On Feb 2, 2019, at 8:36 AM, Sohrab Abbasnejad via R-sig-Geo <[hidden email] <mailto:[hidden email]>> wrote:
>>
>> Hello,
>> I would like to have the list of coordinates of the boundary (outline) of a continent (Africa). The "map" function from the "maps" package gives the coordinates for country outlines, but not the for the continents.
>>
>> Does anybody have an idea where I can find the data?
>>
>> Thank you!
>>
>> Cheers,
>> Sohrab
>>
>>
>>
>>
>> [[alternative HTML version deleted]]
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> [hidden email] <mailto:[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 <http://www.bigelow.org/>
>
> Ecological Forecasting: https://eco.bigelow.org/ <https://eco.bigelow.org/>
>
>
>
>
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: How to get the coordinates (latitude/longitude) of a continent outline?

Sat, 02/02/2019 - 10:36
 Dear Zivan,

Your solution did the job! Thank you very much!

Best,
Sohrab

    On ‎Saturday‎, ‎February‎ ‎2‎, ‎2019‎ ‎04‎:‎07‎:‎27‎ ‎PM‎ ‎CET, Zivan Karaman <[hidden email]> wrote:  
 
 Hello Sohrab,
You can start with country maps, and then merge them in a single polygon.For example, get the maps as a shape file from here http://www.maplibrary.org/library/stacks/Africa/Africa_SHP.zip, unzip this file and run the following R code
library(sp)library(rgdal)library(rgeos)countries <- rgdal::readOGR(dsn = ".", layer = "Africa")
sp::proj4string(countries) <- sp::CRS("+init=epsg:4326")a <- rgeos::gBuffer(countries, width = 0)# ignore the warningssp::proj4string(a) <- sp::CRS("+init=epsg:4326")plot(a)# this produces quite a detailed map with islands, lakes, etc.# you can simplify it to suit your needs by tuning the tol argumentb <- rgeos::gSimplify(a, tol = 0.1)plot(b)
Cheers,Zivan


Le sam. 2 févr. 2019 à 14:36, Sohrab Abbasnejad via R-sig-Geo <[hidden email]> a écrit :

Hello,
I would like to have the list of coordinates of the boundary (outline) of a continent (Africa). The "map" function from the "maps" package gives the coordinates for country outlines, but not the for the continents.

Does anybody have an idea where I can find the data?

Thank you!

Cheers,
Sohrab




        [[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: How to get the coordinates (latitude/longitude) of a continent outline?

Sat, 02/02/2019 - 09:17
 Dear Ben,

Thank you for your reply.

So far as I am aware, the rnaturalearth package provides information about countries within a continent, states within countries and "world" coastline (subsetting the coastline is not possible). Nevertheless, the package does not include maps/data of "continents". What I need is the coordinates of Africa's outline (as a single entity), not the coordinates of countries' outlines within Africa.

Best,
Sohrab


    On ‎Saturday‎, ‎February‎ ‎2‎, ‎2019‎ ‎03‎:‎38‎:‎25‎ ‎PM‎ ‎CET, Ben Tupper wrote:  
 
 Hi,
There is a whole world of options (sorry for the lame pun!), but I would recommend checking out ROpenSci's rnaturalearth package
https://ropensci.org/tutorials/rnaturalearth_tutorial/
https://CRAN.R-project.org/package=rnaturalearth
Ben


On Feb 2, 2019, at 8:36 AM, Sohrab Abbasnejad via R-sig-Geo <[hidden email]> wrote:
Hello,
I would like to have the list of coordinates of the boundary (outline) of a continent (Africa). The "map" function from the "maps" package gives the coordinates for country outlines, but not the for the continents.

Does anybody have an idea where I can find the data?

Thank you!

Cheers,
Sohrab




 [[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: How to get the coordinates (latitude/longitude) of a continent outline?

Sat, 02/02/2019 - 09:07
Hello Sohrab,

You can start with country maps, and then merge them in a single polygon.
For example, get the maps as a shape file from here
http://www.maplibrary.org/library/stacks/Africa/Africa_SHP.zip, unzip this
file and run the following R code

library(sp)
library(rgdal)
library(rgeos)
countries <- rgdal::readOGR(dsn = ".", layer = "Africa")
sp::proj4string(countries) <- sp::CRS("+init=epsg:4326")
a <- rgeos::gBuffer(countries, width = 0)
# ignore the warnings
sp::proj4string(a) <- sp::CRS("+init=epsg:4326")
plot(a)
# this produces quite a detailed map with islands, lakes, etc.
# you can simplify it to suit your needs by tuning the tol argument
b <- rgeos::gSimplify(a, tol = 0.1)
plot(b)

Cheers,
Zivan



Le sam. 2 févr. 2019 à 14:36, Sohrab Abbasnejad via R-sig-Geo <
[hidden email]> a écrit :

> Hello,
> I would like to have the list of coordinates of the boundary (outline) of
> a continent (Africa). The "map" function from the "maps" package gives the
> coordinates for country outlines, but not the for the continents.
>
> Does anybody have an idea where I can find the data?
>
> Thank you!
>
> Cheers,
> Sohrab
>
>
>
>
>         [[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: How to get the coordinates (latitude/longitude) of a continent outline?

Sat, 02/02/2019 - 08:38
Hi,

There is a whole world of options (sorry for the lame pun!), but I would recommend checking out ROpenSci's rnaturalearth package

https://ropensci.org/tutorials/rnaturalearth_tutorial/ <https://ropensci.org/tutorials/rnaturalearth_tutorial/>

https://CRAN.R-project.org/package=rnaturalearth <https://cran.r-project.org/package=rnaturalearth>

Ben

> On Feb 2, 2019, at 8:36 AM, Sohrab Abbasnejad via R-sig-Geo <[hidden email]> wrote:
>
> Hello,
> I would like to have the list of coordinates of the boundary (outline) of a continent (Africa). The "map" function from the "maps" package gives the coordinates for country outlines, but not the for the continents.
>
> Does anybody have an idea where I can find the data?
>
> Thank you!
>
> Cheers,
> Sohrab
>
>
>
>
> [[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

How to get the coordinates (latitude/longitude) of a continent outline?

Sat, 02/02/2019 - 07:36
Hello,
I would like to have the list of coordinates of the boundary (outline) of a continent (Africa). The "map" function from the "maps" package gives the coordinates for country outlines, but not the for the continents.

Does anybody have an idea where I can find the data?

Thank you!

Cheers,
Sohrab




        [[alternative HTML version deleted]]

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

Re: How i can do a shape merge?

Fri, 02/01/2019 - 11:50
On 2/1/19 07:11, Fernando Gimeno wrote:
> Hello
>
> I'm looking a method with the same result that Arcgis "merge"
>
> I have to do a shape merge with a lot of archives but most common tools on
> R has not merged alll shape and always i have to export to arcgis. Has
> anyone worked this?
>
> Thank you
>
With sp type layers, use bind from the raster package, to do many layers
you use do.call with it.
https://rspatial.org/spatial/7-vectmanip.html#append
do.call(bind, listoflayers)

With sf you can use rbind, though if you have a lot of data you might
want to use data.table and noted in this discussion.
https://github.com/r-spatial/sf/issues/798
do.call(rbind, listoflayers)

But really if you have a lot of layers, loading them into memory in R
before combining is not particularly efficient. Consider using
commandline: ogr2ogr -append
https://www.gdal.org/ogr2ogr.html
You can call ogr2ogr from R with the gdalUtils package.

Enjoy,
Alex

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

Pages