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: 9 min 37 sec ago

Re: how to plot different rows of a SpatialPolygonsDataFrame in trellis panels

Fri, 06/01/2018 - 01:17


On 06/01/2018 05:38 AM, Waichler, Scott R wrote:
> Kent,
>
> Thank you for your response to my problem.  Unfortunately, I can't use sf because it has system dependencies I can't meet.  I am using RHEL 6, and am up-to-date with it for gdal, geos, and proj (versions 1.7.3, 3.3.2, 4.7.0 respectively), but the R package sf requires later versions for all of these.   The vignettes for sf make it sound very useful, but alas it seems to be out of reach for me at present.  I am surprised a package that is being positioned for widespread adoption has such stringent requirements.

According to https://download.osgeo.org/gdal/old_releases/ the gdal
version you are running is from 2010. You may have followed how gdal has
improved since 2010, and how it has continuously adapted to the dynamics
of the geospatial software ecosystem, as well as to the development of
new geospatial standards.

I made a deliberate choice to let sf users benefit from these
improvements by picking gdal 2.0.1 from 2015 as a minimum requirement,
rather than keep them in the stone ages.

Keeping sf, rgdal and rgeos to work with new releases of gdal, geos and
proj takes a considerable amount of our time not only for Roger and me,
but also for the CRAN maintainers. I hope this takes away some of your
surprise.

>
> Best,
> Scott Waichler
> Pacific Northwest National Laboratory
> Richland, Washington, USA
>
>> -----Original Message-----
>> From: Kent Johnson [mailto:[hidden email]]
>> Sent: Thursday, May 24, 2018 6:05 AM
>> To: [hidden email]; Waichler, Scott R <[hidden email]>
>> Subject: Re: how to plot different rows of a SpatialPolygonsDataFrame in
>> trellis panels
>>
>> On Thu, May 24, 2018 at 6:00 AM, <[hidden email]> wrote:
>>
>> Message: 1
>> Date: Wed, 23 May 2018 18:39:07 +0000
>> From: "Waichler, Scott R" <[hidden email]>
>> To: "[hidden email]" <[hidden email]>
>> Subject: [R-sig-Geo] how to plot different rows of a
>>         SpatialPolygonsDataFrame in trellis panels
>>
>> Hello,
>>
>> I have a SpatialPolygonsDataFrame.  I would like to do a trellis plot on one of
>> the attributes, so that in the panel for a given attribute value, only those
>> polygons with that value are plotted.  So, each panel has different polygons
>> plotted in it.  I can't figure out how to do this.  In the toy example below, I
>> would like to create a trellis plot with one panel showing the polygons with id
>> = 1, and another panel showing the polygons with id = 2.
>>
>> My goal beyond this toy problem is to do the same thing with stplot, where
>> panels correspond to times and each time has a different set of polygons
>> plotted.  Will that be possible?  In all the examples I can find of using stplot
>> for a space-time grid with the spatial objects being polygons, the polygons
>> are the same across time.
>>
>> # based on example in help("SpatialPolygonsDataFrame-class")
>> Sr1 = Polygon(cbind(c(2,4,4,1,2),c(2,3,5,4,2)))
>> Sr2 = Polygon(cbind(c(5,4,2,5),c(2,3,2,2)))
>> Sr3 = Polygon(cbind(c(4,4,5,10,4),c(5,3,2,5,5)))
>> Sr4 = Polygon(cbind(c(5,6,6,5,5),c(4,4,3,3,4)), hole = TRUE)
>> Srs1 = Polygons(list(Sr1), "s1")
>> Srs2 = Polygons(list(Sr2), "s2")
>> Srs3 = Polygons(list(Sr3, Sr4), "s3/4")
>> SpP = SpatialPolygons(list(Srs1,Srs2,Srs3), 1:3)
>> grd <- GridTopology(c(1,1), c(1,1), c(10,10))
>> polys <- as(grd, "SpatialPolygons")
>> centroids <- coordinates(polys)
>> x <- centroids[,1]
>> y <- centroids[,2]
>> z <- 1.4 + 0.1*x + 0.2*y + 0.002*x*x
>> id = factor(sample(c(1,2), size=length(polys), replace=T))
>> tmp <- SpatialPolygonsDataFrame(polys,
>>       data=data.frame(x=x, y=y, z=z, id=id, row.names=row.names(polys)))
>> plot(tmp)  # plots all the square polygons (n = 10*10)
>> spplot(tmp)  # plots values of x, y, z, id in separate panels, each with 100
>> polys
>> spplot(tmp, zcol=z)  # error message about duplication of factor level
>> spplot(tmp ~ id, zcol=z, data=tmp)  # won't take formula
>>
>> You can do the facetting with ggplot2::geom_sf (in the dev version of
>> ggplot2) though I don't think it will use different coordinate ranges for
>> different facets:
>>
>> devtools::install_github('tidyverse/ggplot2')
>> library(sf)
>> library(ggplot2)
>> tmp2 = st_as_sf(tmp)
>>
>> ggplot(tmp2) + geom_sf(aes(fill=z)) + facet_wrap(~id)
>>
>> A couple of suggestions here, using tmap or ggspatial, that look promising:
>> https://stackoverflow.com/questions/47678480/mapping-different-states-
>> with-geom-sf-using-facet-wrap-and-scales-free
>>
>> Kent Johnson
>>
>>
>> Thank you,
>> ScottWaichler
>> Pacific Northwest National Laboratory
>> scott.waichler _at_ pnnl.gov
> _______________________________________________
> 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

Re: how to plot different rows of a SpatialPolygonsDataFrame in trellis panels

Thu, 05/31/2018 - 22:38
Kent,

Thank you for your response to my problem.  Unfortunately, I can't use sf because it has system dependencies I can't meet.  I am using RHEL 6, and am up-to-date with it for gdal, geos, and proj (versions 1.7.3, 3.3.2, 4.7.0 respectively), but the R package sf requires later versions for all of these.   The vignettes for sf make it sound very useful, but alas it seems to be out of reach for me at present.  I am surprised a package that is being positioned for widespread adoption has such stringent requirements.

Best,
Scott Waichler
Pacific Northwest National Laboratory
Richland, Washington, USA

> -----Original Message-----
> From: Kent Johnson [mailto:[hidden email]]
> Sent: Thursday, May 24, 2018 6:05 AM
> To: [hidden email]; Waichler, Scott R <[hidden email]>
> Subject: Re: how to plot different rows of a SpatialPolygonsDataFrame in
> trellis panels
>
> On Thu, May 24, 2018 at 6:00 AM, <[hidden email]> wrote:
>
> Message: 1
> Date: Wed, 23 May 2018 18:39:07 +0000
> From: "Waichler, Scott R" <[hidden email]>
> To: "[hidden email]" <[hidden email]>
> Subject: [R-sig-Geo] how to plot different rows of a
>         SpatialPolygonsDataFrame in trellis panels
>
> Hello,
>
> I have a SpatialPolygonsDataFrame.  I would like to do a trellis plot on one of
> the attributes, so that in the panel for a given attribute value, only those
> polygons with that value are plotted.  So, each panel has different polygons
> plotted in it.  I can't figure out how to do this.  In the toy example below, I
> would like to create a trellis plot with one panel showing the polygons with id
> = 1, and another panel showing the polygons with id = 2.
>
> My goal beyond this toy problem is to do the same thing with stplot, where
> panels correspond to times and each time has a different set of polygons
> plotted.  Will that be possible?  In all the examples I can find of using stplot
> for a space-time grid with the spatial objects being polygons, the polygons
> are the same across time.
>
> # based on example in help("SpatialPolygonsDataFrame-class")
> Sr1 = Polygon(cbind(c(2,4,4,1,2),c(2,3,5,4,2)))
> Sr2 = Polygon(cbind(c(5,4,2,5),c(2,3,2,2)))
> Sr3 = Polygon(cbind(c(4,4,5,10,4),c(5,3,2,5,5)))
> Sr4 = Polygon(cbind(c(5,6,6,5,5),c(4,4,3,3,4)), hole = TRUE)
> Srs1 = Polygons(list(Sr1), "s1")
> Srs2 = Polygons(list(Sr2), "s2")
> Srs3 = Polygons(list(Sr3, Sr4), "s3/4")
> SpP = SpatialPolygons(list(Srs1,Srs2,Srs3), 1:3)
> grd <- GridTopology(c(1,1), c(1,1), c(10,10))
> polys <- as(grd, "SpatialPolygons")
> centroids <- coordinates(polys)
> x <- centroids[,1]
> y <- centroids[,2]
> z <- 1.4 + 0.1*x + 0.2*y + 0.002*x*x
> id = factor(sample(c(1,2), size=length(polys), replace=T))
> tmp <- SpatialPolygonsDataFrame(polys,
>       data=data.frame(x=x, y=y, z=z, id=id, row.names=row.names(polys)))
> plot(tmp)  # plots all the square polygons (n = 10*10)
> spplot(tmp)  # plots values of x, y, z, id in separate panels, each with 100
> polys
> spplot(tmp, zcol=z)  # error message about duplication of factor level
> spplot(tmp ~ id, zcol=z, data=tmp)  # won't take formula
>
> You can do the facetting with ggplot2::geom_sf (in the dev version of
> ggplot2) though I don't think it will use different coordinate ranges for
> different facets:
>
> devtools::install_github('tidyverse/ggplot2')
> library(sf)
> library(ggplot2)
> tmp2 = st_as_sf(tmp)
>
> ggplot(tmp2) + geom_sf(aes(fill=z)) + facet_wrap(~id)
>
> A couple of suggestions here, using tmap or ggspatial, that look promising:
> https://stackoverflow.com/questions/47678480/mapping-different-states-
> with-geom-sf-using-facet-wrap-and-scales-free
>
> Kent Johnson
>
>
> Thank you,
> ScottWaichler
> Pacific Northwest National Laboratory
> scott.waichler _at_ pnnl.gov _______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Re: polygon over or intersect with more than 2 files/layers

Thu, 05/31/2018 - 03:47
On Thu, 31 May 2018, Bannar-Martin, Katherine wrote:

> Hi,
>
> I've had no success at finding a tool in an R package that can calculate
> the intersection/overlap of polygons for more than 2 layers.
>
> e.g.
> plot(st_intersection(st_union(LateYear2008),st_union(LateYear2009),st_union(LateYear2010),st_union(LateYear2011),st_union(LateYear2012),
> st_union(LateYear2013),st_union(LateYear2014),st_union(LateYear2015),st_union(LateYear2016),st_union(LateYear2017)),
> col = 'red',xlim=c(min(d$x),max(d$x)),ylim=c(min(d$y),max(d$y)),axes =
> TRUE) does NOT work.
Why would you think it might, given that the help page only shows pairs of
objects? The underlying code in GEOS is for binary operations. GRASS also
handles binary overlay, and the same applies to PostGIS.

It might be possible to work out intersection candidates by building trees
of envelopes and querying multiple layers based on non-zero envelope
intersection, but

>
> Does anyone have any suggestions? Is there a way to save a shapefile
> with multiple layers of polygons and then run an over/intersection tool.
>

No, a "shapefile" has one layer only, unless you want a folder with
multiple shapefiles. GPKG can take multiple layers, but it isn't obvious
why this would help.

> I can run each pair-wise overlap between layers in a loop but the number
> of combinations is long.

Obviously. If you have to have vector, you have to do this pairwise. If
raster is an option, probably there are many more possibilities; GRASS
r.cross takes multiple raster layers for example.

>
> Efficient solutions welcomed.

  ... and code contributions ??

Roger

>
> Thanks!
> Katherine
>
> [[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]
http://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

polygon over or intersect with more than 2 files/layers

Wed, 05/30/2018 - 17:12
Hi,

I've had no success at finding a tool in an R package that can calculate the intersection/overlap of polygons for more than 2 layers.

e.g. plot(st_intersection(st_union(LateYear2008),st_union(LateYear2009),st_union(LateYear2010),st_union(LateYear2011),st_union(LateYear2012),
st_union(LateYear2013),st_union(LateYear2014),st_union(LateYear2015),st_union(LateYear2016),st_union(LateYear2017)),
col = 'red',xlim=c(min(d$x),max(d$x)),ylim=c(min(d$y),max(d$y)),axes = TRUE)
does NOT work.

Does anyone have any suggestions? Is there a way to save a shapefile with multiple layers of polygons and then run an over/intersection tool.

I can run each pair-wise overlap between layers in a loop but the number of combinations is long.

Efficient solutions welcomed.

Thanks!
Katherine

        [[alternative HTML version deleted]]

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

Re: Extract xy coordinates from raster of interesting neighborhood cells

Wed, 05/30/2018 - 16:04
Thanks so much Vijay and Ben, now it works!!!

             Originally, I expect 24 for each 4 point (96 total).
Apologies, in my example preparation I changed the raster objects
'land_mask' and 'r' and the idea of my second point [45.12069,
-88.369745] is to force NA results.

             The code below is a solution that I expected:

### Alternative to what Ben suggested!
## Set neighborhood matrix.  Focal cell is 0 while neighbors are 1!!
neigh <- matrix(1L, nrow=5, ncol=5); neigh[3,3] <- 0L
e1<-adjacent(r, N_cells , directions=neigh, pairs=FALSE)
ng_coords1 <- xyFromCell(r, e1)
plot(r);
points(pts, col='red', pch=16);
points(ng_coords, col='black', pch=16);
points(ng_coords1, col='blue', pch=16)
### END

--
======================================================================
Alexandre dos Santos
Proteção Florestal
IFMT - Instituto Federal de Educação, Ciência e Tecnologia de Mato Grosso
Campus Cáceres
Caixa Postal 244
Avenida dos Ramires, s/n
Bairro: Distrito Industrial
Cáceres - MT                      CEP: 78.200-000
Fone: (+55) 65 99686-6970 (VIVO) (+55) 65 3221-2674 (FIXO)

         [hidden email]
Lattes: http://lattes.cnpq.br/1360403201088680
OrcID: orcid.org/0000-0001-8232-6722
Researchgate: www.researchgate.net/profile/Alexandre_Santos10
LinkedIn: br.linkedin.com/in/alexandre-dos-santos-87961635
Mendeley:www.mendeley.com/profiles/alexandre-dos-santos6/
======================================================================

Em 30/05/2018 16:29, Vijay Lulla escreveu:
> Or you can try something like this?
>
> ### START
> require(raster)
> require(sp)
>
> r <- raster(nc=30, nr=30)
> r <- setValues(r, round(runif(ncell(r))* 255))
>
> xd     <- c(-24.99270,45.12069,99.40321,73.64419)
> yd  <- c(-45.435267,-88.369745,-7.086949,44.174530)
> pts <- data.frame(xd,yd)
> pts_s<- SpatialPoints(pts)
>
> N_cells <- cellFromXY(r, pts_s)
> e<-adjacent(r, N_cells , directions='bishop', pairs=FALSE)
>
> ng_coords <- xyFromCell(r, e)
> plot(r)
> points(pts, col='red', pch=16)
> points(ng_coords, col='black', pch=16)
>
> [[elided Yahoo spam]]
[[elided Yahoo spam]]
> neigh <- matrix(1L, nrow=5, ncol=5); neigh[3,3] <- 0L
> e1<-adjacent(r, N_cells , directions=neigh, pairs=FALSE)
> ng_coords1 <- xyFromCell(r, e1)
> plot(r);
> points(pts, col='red', pch=16);
> points(ng_coords, col='black', pch=16);
> points(ng_coords1, col='blue', pch=16)
> ### END
>
> HTH,
> Vijay.
>
> On Wed, May 30, 2018 at 4:22 PM, Ben Tupper <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     Hi,
>
>     I'm not sure why you expect 24 points - you have 4 locations and
>     for each you want the 4 bishop's directions - so, I think at most
>     you should expect 16 points.  See
>     http://www.lpc.uottawa.ca/publications/moransi/moran.htm
>     <http://www.lpc.uottawa.ca/publications/moransi/moran.htm>
>     <http://www.lpc.uottawa.ca/publications/moransi/moran.htm
>     <http://www.lpc.uottawa.ca/publications/moransi/moran.htm>> for
>     where I expect 4 points for bishop's for each input location;
>     perhaps you have a different idea of bishop's direction?
>
>     Your second point [45.12069, -88.369745] is on to the southern
>     edge of the raster - so it can't find points southward - only the
>     2 northward.
>
>     Finally, it may not make any difference at all, but your pts_s has
>     no coordinate reference.  Below I show where I assign the same
>     projection as your raster.  I also don't have 'land_mask' so I
>     reused 'r' and used xyFromCell to backwards extract the adjacent
>     cell coordinates.
>
>     Does that do the trick for you?
>
>     Cheers,
>     Ben
>
>     ### START
>     require(raster)
>     require(sp)
>
>     ## Create a raster
>     r <- raster(nc=30, nr=30)
>     r <- setValues(r, round(runif(ncell(r))* 255))
>     plot(r)
>
>     ##Given interesting points coordinates
>     xd     <- c( -24.99270,   45.12069,  99.40321, 73.64419)
>     yd     <- c(-45.435267, -88.369745, -7.086949, 44.174530)
>     pts <- data.frame(xd,yd)
>     pts_s<- SpatialPoints(pts)
>     projection(pts_s) <- projection(r)
>     points(pts_s, col="red", pch=16)
>
>     ## Find pixels center of each point
>     N_cells <- cellFromXY(r, pts_s)
>
>     e <- adjacent(r, N_cells , directions='bishop', id=TRUE, sorted =
>     TRUE)
>     xy <- xyFromCell(r, e[,'to'], spatial = TRUE)
>
>
>     #Visualization
>
>     plot(r)
>     points(pts_s, col="red", pch=16)
>     points(xy, col="black", pch=16)
>     ### END
>
>
>
>
>
>     > On May 30, 2018, at 3:11 PM, ASANTOS via R-sig-Geo
>     <[hidden email] <mailto:[hidden email]>> wrote:
>     >
>     > Dear R-Sig-Geo Members,
>     >
>     >     I've like to extract xy coordinates from raster of 24
>     neigborhood cells that surround the 4 given points (pts_s) pixels
>     and for this I used:
>     >
>     > #Packages
>     >
>     > require(raster)
>     > require(sp)
>     >
>     > ## Create a raster
>     > r <- raster(nc=30, nr=30)
>     > r <- setValues(r, round(runif(ncell(r))* 255))
>     > plot(r)
>     >
>     > ##Given interesting points coordinates
>     > xd     <- c(-24.99270,45.12069,99.40321,73.64419)
>     > yd  <- c(-45.435267,-88.369745,-7.086949,44.174530)
>     > pts <- data.frame(xd,yd)
>     > pts_s<- SpatialPoints(pts)
>     > points(pts_s, col="red", pch=16)
>     >
>     > ## Find pixels center of each point (My idea is not to use the
>     original point coordinates, but coordinates of the center of
>     interesting pixel).
>     > N_cells <- cellFromXY(r, pts_s)
>     >
>     >
>     > # Extract xy coordinates from raster of 24 neighborhood cells
>     given pixel number N_cells
>     > e<-adjacent(r, N_cells , directions='bishop', id=TRUE)
>     > coordinates(land_mask)[e[,1],] ## Doesn't return 24 neighborhood
>     by N_cells object
>     > ng_coords<-coordinates(land_mask)[e[,1],]
>     > #
>     >
>     > #Visualization
>     >
>     > plot(r)
>     > points(pts_s, col="red", pch=16)
>     > points(ng_coords, col="black", pch=16)
>     > ##
>     >
>     >     But I don't have success because the ng_coords object is not
>     a 24 neighborhood cells of each point that I search. There are
>     solution for this?
>     >
>     > Thanks in advance,
>     >
>     > Alexandre
>     >
>     > --
>     >
>     ======================================================================
>     > Alexandre dos Santos
>     > Proteção Florestal
>     > IFMT - Instituto Federal de Educação, Ciência e Tecnologia de
>     Mato Grosso
>     > Campus Cáceres
>     > Caixa Postal 244
>     > Avenida dos Ramires, s/n
>     > Bairro: Distrito Industrial
>     > Cáceres - MT                      CEP: 78.200-000
>     > Fone: (+55) 65 99686-6970 (VIVO) (+55) 65 3221-2674 (FIXO)
>     >
>     > [hidden email]
>     <mailto:[hidden email]>
>     > Lattes: http://lattes.cnpq.br/1360403201088680
>     <http://lattes.cnpq.br/1360403201088680>
>     > OrcID: orcid.org/0000-0001-8232-6722
>     <http://orcid.org/0000-0001-8232-6722>
>     > Researchgate: www.researchgate.net/profile/Alexandre_Santos10
>     <http://www.researchgate.net/profile/Alexandre_Santos10>
>     > LinkedIn: br.linkedin.com/in/alexandre-dos-santos-87961635
>     <http://br.linkedin.com/in/alexandre-dos-santos-87961635>
>     > Mendeley:www.mendeley.com/profiles/alexandre-dos-santos6/
>     <http://www.mendeley.com/profiles/alexandre-dos-santos6/>
>     >
>     > _______________________________________________
>     > R-sig-Geo mailing list
>     > [hidden email] <mailto:[hidden email]>
>     > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>     <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] <mailto:[hidden email]>
>     https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>     <https://stat.ethz.ch/mailman/listinfo/r-sig-geo>
>
>
>
>
> --
> Vijay Lulla, Ph.D.
>
> Assistant Professor,
> Dept. of Geography, IUPUI
> 425 University Blvd, CA-207C.
> Indianapolis, IN-46202
> [hidden email] <mailto:[hidden email]>
>
> <http://vijaylulla.com>
> http://vijaylulla.com

        [[alternative HTML version deleted]]

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

Re: Extract xy coordinates from raster of interesting neighborhood cells

Wed, 05/30/2018 - 15:29
Or you can try something like this?

### START
require(raster)
require(sp)

r <- raster(nc=30, nr=30)
r <- setValues(r, round(runif(ncell(r))* 255))

xd     <- c(-24.99270,45.12069,99.40321,73.64419)
yd  <- c(-45.435267,-88.369745,-7.086949,44.174530)
pts <- data.frame(xd,yd)
pts_s<- SpatialPoints(pts)

N_cells <- cellFromXY(r, pts_s)
e<-adjacent(r, N_cells , directions='bishop', pairs=FALSE)

ng_coords <- xyFromCell(r, e)
plot(r)
points(pts, col='red', pch=16)
points(ng_coords, col='black', pch=16)


### Alternative to what Ben suggested!
## Set neighborhood matrix.  Focal cell is 0 while neighbors are 1!!
neigh <- matrix(1L, nrow=5, ncol=5); neigh[3,3] <- 0L
e1<-adjacent(r, N_cells , directions=neigh, pairs=FALSE)
ng_coords1 <- xyFromCell(r, e1)
plot(r);
points(pts, col='red', pch=16);
points(ng_coords, col='black', pch=16);
points(ng_coords1, col='blue', pch=16)
### END

HTH,
Vijay.

On Wed, May 30, 2018 at 4:22 PM, Ben Tupper <[hidden email]> wrote:

> Hi,
>
> I'm not sure why you expect 24 points - you have 4 locations and for each
> you want the 4 bishop's directions - so, I think at most you should expect
> 16 points.  See http://www.lpc.uottawa.ca/publications/moransi/moran.htm <
> http://www.lpc.uottawa.ca/publications/moransi/moran.htm> for where I
> expect 4 points for bishop's for each input location; perhaps you have a
> different idea of bishop's direction?
>
> Your second point [45.12069, -88.369745] is on to the southern edge of the
> raster - so it can't find points southward - only the 2 northward.
>
> Finally, it may not make any difference at all, but your pts_s has no
> coordinate reference.  Below I show where I assign the same projection as
> your raster.  I also don't have 'land_mask' so I reused 'r' and used
> xyFromCell to backwards extract the adjacent cell coordinates.
>
> Does that do the trick for you?
>
> Cheers,
> Ben
>
> ### START
> require(raster)
> require(sp)
>
> ## Create a raster
> r <- raster(nc=30, nr=30)
> r <- setValues(r, round(runif(ncell(r))* 255))
> plot(r)
>
> ##Given interesting points coordinates
> xd     <- c( -24.99270,   45.12069,  99.40321,  73.64419)
> yd     <- c(-45.435267, -88.369745, -7.086949, 44.174530)
> pts <- data.frame(xd,yd)
> pts_s<- SpatialPoints(pts)
> projection(pts_s) <- projection(r)
> points(pts_s, col="red", pch=16)
>
> ## Find pixels center of each point
> N_cells <- cellFromXY(r, pts_s)
>
> e <- adjacent(r, N_cells , directions='bishop', id=TRUE, sorted = TRUE)
> xy <- xyFromCell(r, e[,'to'], spatial = TRUE)
>
>
> #Visualization
>
> plot(r)
> points(pts_s, col="red", pch=16)
> points(xy, col="black", pch=16)
> ### END
>
>
>
>
>
> > On May 30, 2018, at 3:11 PM, ASANTOS via R-sig-Geo <
> [hidden email]> wrote:
> >
> > Dear R-Sig-Geo Members,
> >
> >     I've like to extract xy coordinates from raster of 24 neigborhood
> cells that surround the 4 given points (pts_s) pixels and for this I used:
> >
> > #Packages
> >
> > require(raster)
> > require(sp)
> >
> > ## Create a raster
> > r <- raster(nc=30, nr=30)
> > r <- setValues(r, round(runif(ncell(r))* 255))
> > plot(r)
> >
> > ##Given interesting points coordinates
> > xd     <- c(-24.99270,45.12069,99.40321,73.64419)
> > yd  <- c(-45.435267,-88.369745,-7.086949,44.174530)
> > pts <- data.frame(xd,yd)
> > pts_s<- SpatialPoints(pts)
> > points(pts_s, col="red", pch=16)
> >
> > ## Find pixels center of each point (My idea is not to use the original
> point coordinates, but coordinates of the center of interesting pixel).
> > N_cells <- cellFromXY(r, pts_s)
> >
> >
> > # Extract xy coordinates from raster of 24 neighborhood cells given
> pixel number N_cells
> > e<-adjacent(r, N_cells , directions='bishop', id=TRUE)
> > coordinates(land_mask)[e[,1],] ## Doesn't return 24 neighborhood by
> N_cells object
> > ng_coords<-coordinates(land_mask)[e[,1],]
> > #
> >
> > #Visualization
> >
> > plot(r)
> > points(pts_s, col="red", pch=16)
> > points(ng_coords, col="black", pch=16)
> > ##
> >
> >     But I don't have success because the ng_coords object is not a 24
> neighborhood cells of each point that I search. There are solution for this?
> >
> > Thanks in advance,
> >
> > Alexandre
> >
> > --
> > ======================================================================
> > Alexandre dos Santos
> > Proteção Florestal
> > IFMT - Instituto Federal de Educação, Ciência e Tecnologia de Mato Grosso
> > Campus Cáceres
> > Caixa Postal 244
> > Avenida dos Ramires, s/n
> > Bairro: Distrito Industrial
> > Cáceres - MT                      CEP: 78.200-000
> > Fone: (+55) 65 99686-6970 (VIVO) (+55) 65 3221-2674 (FIXO)
> >
> >        [hidden email]
> > Lattes: http://lattes.cnpq.br/1360403201088680
> > OrcID: orcid.org/0000-0001-8232-6722
> > Researchgate: www.researchgate.net/profile/Alexandre_Santos10
> > LinkedIn: br.linkedin.com/in/alexandre-dos-santos-87961635
> > Mendeley:www.mendeley.com/profiles/alexandre-dos-santos6/
> >
> > _______________________________________________
> > 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
>


--
Vijay Lulla, Ph.D.

Assistant Professor,
Dept. of Geography, IUPUI
425 University Blvd, CA-207C.
Indianapolis, IN-46202
[hidden email]

<http://vijaylulla.com>
http://vijaylulla.com

        [[alternative HTML version deleted]]

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

Re: Extract xy coordinates from raster of interesting neighborhood cells

Wed, 05/30/2018 - 15:22
Hi,

I'm not sure why you expect 24 points - you have 4 locations and for each you want the 4 bishop's directions - so, I think at most you should expect 16 points.  See http://www.lpc.uottawa.ca/publications/moransi/moran.htm <http://www.lpc.uottawa.ca/publications/moransi/moran.htm> for where I expect 4 points for bishop's for each input location; perhaps you have a different idea of bishop's direction?  

Your second point [45.12069, -88.369745] is on to the southern edge of the raster - so it can't find points southward - only the 2 northward.

Finally, it may not make any difference at all, but your pts_s has no coordinate reference.  Below I show where I assign the same projection as your raster.  I also don't have 'land_mask' so I reused 'r' and used xyFromCell to backwards extract the adjacent cell coordinates.

Does that do the trick for you?

Cheers,
Ben

### START
require(raster)
require(sp)

## Create a raster
r <- raster(nc=30, nr=30)
r <- setValues(r, round(runif(ncell(r))* 255))
plot(r)

##Given interesting points coordinates
xd     <- c( -24.99270,   45.12069,  99.40321,  73.64419)
yd     <- c(-45.435267, -88.369745, -7.086949, 44.174530)
pts <- data.frame(xd,yd)
pts_s<- SpatialPoints(pts)
projection(pts_s) <- projection(r)
points(pts_s, col="red", pch=16)

## Find pixels center of each point
N_cells <- cellFromXY(r, pts_s)

e <- adjacent(r, N_cells , directions='bishop', id=TRUE, sorted = TRUE)
xy <- xyFromCell(r, e[,'to'], spatial = TRUE)


#Visualization

plot(r)
points(pts_s, col="red", pch=16)
points(xy, col="black", pch=16)
### END





> On May 30, 2018, at 3:11 PM, ASANTOS via R-sig-Geo <[hidden email]> wrote:
>
> Dear R-Sig-Geo Members,
>
>     I've like to extract xy coordinates from raster of 24 neigborhood cells that surround the 4 given points (pts_s) pixels and for this I used:
>
> #Packages
>
> require(raster)
> require(sp)
>
> ## Create a raster
> r <- raster(nc=30, nr=30)
> r <- setValues(r, round(runif(ncell(r))* 255))
> plot(r)
>
> ##Given interesting points coordinates
> xd     <- c(-24.99270,45.12069,99.40321,73.64419)
> yd  <- c(-45.435267,-88.369745,-7.086949,44.174530)
> pts <- data.frame(xd,yd)
> pts_s<- SpatialPoints(pts)
> points(pts_s, col="red", pch=16)
>
> ## Find pixels center of each point (My idea is not to use the original point coordinates, but coordinates of the center of interesting pixel).
> N_cells <- cellFromXY(r, pts_s)
>
>
> # Extract xy coordinates from raster of 24 neighborhood cells given pixel number N_cells
> e<-adjacent(r, N_cells , directions='bishop', id=TRUE)
> coordinates(land_mask)[e[,1],] ## Doesn't return 24 neighborhood by N_cells object
> ng_coords<-coordinates(land_mask)[e[,1],]
> #
>
> #Visualization
>
> plot(r)
> points(pts_s, col="red", pch=16)
> points(ng_coords, col="black", pch=16)
> ##
>
>     But I don't have success because the ng_coords object is not a 24 neighborhood cells of each point that I search. There are solution for this?
>
> Thanks in advance,
>
> Alexandre
>
> --
> ======================================================================
> Alexandre dos Santos
> Proteção Florestal
> IFMT - Instituto Federal de Educação, Ciência e Tecnologia de Mato Grosso
> Campus Cáceres
> Caixa Postal 244
> Avenida dos Ramires, s/n
> Bairro: Distrito Industrial
> Cáceres - MT                      CEP: 78.200-000
> Fone: (+55) 65 99686-6970 (VIVO) (+55) 65 3221-2674 (FIXO)
>
>        [hidden email]
> Lattes: http://lattes.cnpq.br/1360403201088680
> OrcID: orcid.org/0000-0001-8232-6722
> Researchgate: www.researchgate.net/profile/Alexandre_Santos10
> LinkedIn: br.linkedin.com/in/alexandre-dos-santos-87961635
> Mendeley:www.mendeley.com/profiles/alexandre-dos-santos6/
>
> _______________________________________________
> 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

Extract xy coordinates from raster of interesting neighborhood cells

Wed, 05/30/2018 - 14:11
Dear R-Sig-Geo Members,

     I've like to extract xy coordinates from raster of 24 neigborhood
cells that surround the 4 given points (pts_s) pixels and for this I used:

#Packages

require(raster)
require(sp)

## Create a raster
r <- raster(nc=30, nr=30)
r <- setValues(r, round(runif(ncell(r))* 255))
plot(r)

##Given interesting points coordinates
xd     <- c(-24.99270,45.12069,99.40321,73.64419)
yd  <- c(-45.435267,-88.369745,-7.086949,44.174530)
pts <- data.frame(xd,yd)
pts_s<- SpatialPoints(pts)
points(pts_s, col="red", pch=16)

## Find pixels center of each point (My idea is not to use the original
point coordinates, but coordinates of the center of interesting pixel).
N_cells <- cellFromXY(r, pts_s)


# Extract xy coordinates from raster of 24 neighborhood cells given
pixel number N_cells
e<-adjacent(r, N_cells , directions='bishop', id=TRUE)
coordinates(land_mask)[e[,1],] ## Doesn't return 24 neighborhood by
N_cells object
ng_coords<-coordinates(land_mask)[e[,1],]
#

#Visualization

plot(r)
points(pts_s, col="red", pch=16)
points(ng_coords, col="black", pch=16)
##

     But I don't have success because the ng_coords object is not a 24
neighborhood cells of each point that I search. There are solution for this?

Thanks in advance,

Alexandre

--
======================================================================
Alexandre dos Santos
Proteção Florestal
IFMT - Instituto Federal de Educação, Ciência e Tecnologia de Mato Grosso
Campus Cáceres
Caixa Postal 244
Avenida dos Ramires, s/n
Bairro: Distrito Industrial
Cáceres - MT                      CEP: 78.200-000
Fone: (+55) 65 99686-6970 (VIVO) (+55) 65 3221-2674 (FIXO)

         [hidden email]
Lattes: http://lattes.cnpq.br/1360403201088680
OrcID: orcid.org/0000-0001-8232-6722
Researchgate: www.researchgate.net/profile/Alexandre_Santos10
LinkedIn: br.linkedin.com/in/alexandre-dos-santos-87961635
Mendeley:www.mendeley.com/profiles/alexandre-dos-santos6/

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

Re: spam message when sending a mail to the list

Wed, 05/30/2018 - 11:54
I answered 48 minutes ago to the message "[R-sig-Geo] spam message when
sending a mail to the list"
and 30minutes later came another spam. This time is from this mail:
AmandaCruise <[hidden email]>
They are really quickly to send us spam, after our posting.





2018-05-30 16:39 GMT+00:00 AmandaCruise <[hidden email]>:

> Hi marta,  thanks for the reply. I am Amanda Cruise . What part of the
> city are you in? Let me clear you something first, i am here for fun only.
> Nothing serious. All I need a partner on my bed who can satisfy me. So tell
> me this about yourself….whats your favorite position and how many inches is
> it?
>
> On Wed, 30 May 2018 at 10:39 AM, marta azores <[hidden email]>
> wrote:
>
>>
>>
>>
>>
        [[alternative HTML version deleted]]

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

Re: spam message when sending a mail to the list

Wed, 05/30/2018 - 10:59
Me too, but from two different mails, both included the name elisa.
Photos+viruses

2018-05-30 14:03 GMT+00:00 Laura Poggio <[hidden email]>:

> Dear list,
> not sure if it is just me, but I sent two messages to the list in the past
> couple of days. In both cases I immediately received a message from an
> unknown sender with some "particular requests". This is not happening when
> I send mails to other contacts.
>
> I can provide more information to the maintainers or please just let me
> know if/where to report them.
>
> Thanks
>
> laura
>
>         [[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: spam message when sending a mail to the list

Wed, 05/30/2018 - 09:39
Thanks for your patience. If you receive such messages after posting, please contact the list owner, rather than post on the list. Several higher volume R lists have seen this behaviour over the last month, and steps are being taken to stop it, so far without sufficient success. Diagnoses are discussed off-list for obvious reasons.

Roger Bivand
List admin.

Norwegian School of Economics
Bergen, Norway



Fra: chris english
Sendt: onsdag 30. mai, 16.19
Emne: Re: [R-sig-Geo] spam message when sending a mail to the list
Til: Andres Diaz Loaiza
Kopi: [hidden email]


Laura, Andres, As Roger admonished me, just never respond ( a mistake I made ), as it is very difficult to both maintain this valuable communication regards spatial statistics and exclude the clearly un-statistically minded. Chris On Wed, May 30, 2018 at 10:08 AM, Andres Diaz Loaiza wrote: > Hi LAura, > > To me also happened the same, even worst because they are now sending > photos which I am probably sure contains viruses. > > Is true that the maillist maintainer should exclude this mail address > > The mail of the sender is: [hidden email] > > All the best, > > Andres > > 2018-05-30 16:03 GMT+02:00 Laura Poggio : > > > Dear list, > > not sure if it is just me, but I sent two messages to the list in the > past > > couple of days. In both cases I immediately received a message from an > > unknown sender with some "particular requests". This is not happening > when > > I send mails to other contacts. > > > > I can provide more information to the maintainers or please just let me > > know if/where to report them. > > > > Thanks > > > > laura > > > > [[alternative HTML version deleted]] > > > > _______________________________________________ > > R-sig-Geo mailing list > > [hidden email] > > https://stat.ethz.ch/mailman/listinfo/r-sig-geo > > > > > > -- > Andrés D. > > [[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


        [[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: spam message when sending a mail to the list

Wed, 05/30/2018 - 09:34
Hi Chris,
of course the message is immediately deleted and no response. And I do
understand the issues of the maintainers (and really appreciate their
efforts!).
The senders vary, one is what Andres mentioned, but I got a couple of
others. However they are now sending "not safe for work" images. I am just
afraid that the mailing list will be soon blocked by mail filters.


Thanks

Laura

On 30 May 2018 at 15:19, chris english <[hidden email]>
wrote:

> Laura, Andres,
>
> As Roger admonished me, just never respond ( a mistake I made ), as it is
> very difficult to both maintain this
> valuable communication regards spatial statistics and exclude the clearly
> un-statistically minded.
>
> Chris
>
> On Wed, May 30, 2018 at 10:08 AM, Andres Diaz Loaiza <[hidden email]>
> wrote:
>
>> Hi LAura,
>>
>> To me also happened the same, even worst because they are now sending
>> photos which I am probably sure contains viruses.
>>
>> Is true that the maillist maintainer should exclude this mail address
>>
>> The mail of the sender is:  [hidden email]
>>
>> All the best,
>>
>> Andres
>>
>> 2018-05-30 16:03 GMT+02:00 Laura Poggio <[hidden email]>:
>>
>> > Dear list,
>> > not sure if it is just me, but I sent two messages to the list in the
>> past
>> > couple of days. In both cases I immediately received a message from an
>> > unknown sender with some "particular requests". This is not happening
>> when
>> > I send mails to other contacts.
>> >
>> > I can provide more information to the maintainers or please just let me
>> > know if/where to report them.
>> >
>> > Thanks
>> >
>> > laura
>> >
>> >         [[alternative HTML version deleted]]
>> >
>> > _______________________________________________
>> > R-sig-Geo mailing list
>> > [hidden email]
>> > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>> >
>>
>>
>>
>> --
>> Andrés D.
>>
>>         [[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: spam message when sending a mail to the list

Wed, 05/30/2018 - 09:19
Laura, Andres,

As Roger admonished me, just never respond ( a mistake I made ), as it is
very difficult to both maintain this
valuable communication regards spatial statistics and exclude the clearly
un-statistically minded.

Chris

On Wed, May 30, 2018 at 10:08 AM, Andres Diaz Loaiza <[hidden email]>
wrote:

> Hi LAura,
>
> To me also happened the same, even worst because they are now sending
> photos which I am probably sure contains viruses.
>
> Is true that the maillist maintainer should exclude this mail address
>
> The mail of the sender is:  [hidden email]
>
> All the best,
>
> Andres
>
> 2018-05-30 16:03 GMT+02:00 Laura Poggio <[hidden email]>:
>
> > Dear list,
> > not sure if it is just me, but I sent two messages to the list in the
> past
> > couple of days. In both cases I immediately received a message from an
> > unknown sender with some "particular requests". This is not happening
> when
> > I send mails to other contacts.
> >
> > I can provide more information to the maintainers or please just let me
> > know if/where to report them.
> >
> > Thanks
> >
> > laura
> >
> >         [[alternative HTML version deleted]]
> >
> > _______________________________________________
> > R-sig-Geo mailing list
> > [hidden email]
> > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> >
>
>
>
> --
> Andrés D.
>
>         [[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: spam message when sending a mail to the list

Wed, 05/30/2018 - 09:08
Hi LAura,

To me also happened the same, even worst because they are now sending
photos which I am probably sure contains viruses.

Is true that the maillist maintainer should exclude this mail address

The mail of the sender is:  [hidden email]

All the best,

Andres

2018-05-30 16:03 GMT+02:00 Laura Poggio <[hidden email]>:

> Dear list,
> not sure if it is just me, but I sent two messages to the list in the past
> couple of days. In both cases I immediately received a message from an
> unknown sender with some "particular requests". This is not happening when
> I send mails to other contacts.
>
> I can provide more information to the maintainers or please just let me
> know if/where to report them.
>
> Thanks
>
> laura
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>


--
Andrés D.

        [[alternative HTML version deleted]]

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

spam message when sending a mail to the list

Wed, 05/30/2018 - 09:03
Dear list,
not sure if it is just me, but I sent two messages to the list in the past
couple of days. In both cases I immediately received a message from an
unknown sender with some "particular requests". This is not happening when
I send mails to other contacts.

I can provide more information to the maintainers or please just let me
know if/where to report them.

Thanks

laura

        [[alternative HTML version deleted]]

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

Re: error installing rgdal with gdal 2.3.0 on centos7

Wed, 05/30/2018 - 08:42
Dear Roger,
I was trying to install the version from CRAN, sorry I should have
mentioned it.

The C++ compiler on centos7 seemed to be too old. The solution that worked
was:
installing the devtoolset environment
activate the environment
run R  CMD INSTALL rgdal_1-2.20.tar.gz from the activated environment
(normal install.packages("rgdal") worked as well)
exit the environment

The package is now working without problems (hopefully ... initial tests
fine).

Thanks a lot for the help that set us on the right path.

Laura



On 29 May 2018 at 17:18, Roger Bivand <[hidden email]> wrote:

> On Tue, 29 May 2018, Laura Poggio wrote:
>
> Dear all,
>> I am trying to install rgdal on a centos 7 machine.
>>
>
> Which version of rgdal - the current CRAN source?


>
> First I installed from source gdal 2.3.0. No errors and it is working as
>> expected.
>>
>> I then tried to install rgdal using R 3.4.4
>>
>> I get the error:
>>
>> In file included from /usr/local/include/gdal.h:45:0,
>>                 from gdal_test.cc:1:
>> /usr/local/include/cpl_port.h:187:6: error: #error Must have C++11 or
>> newer.
>> #    error Must have C++11 or newer.
>>
>
> Is this during configure? Could you try by downloading the tarball and
> running
>
> R CMD INSTALL rgdal_1-2.20.tar.gz
>
> In configure, the value of CXX is taken from "${RBIN}" CMD config CXX
> where "${RBIN}" is RBIN="${R_HOME}/bin/R" and R_HOME=`R RHOME`, so
>
> R CMD config CXX
>
> which in your case may need -std=g++11 or some such added - please inform.
>
> Roger
>
>
>> I can use a previous version of gdal (2.2.1) without problems, but I was
>> wondering if other people found a more robust solution that could work
>> with
>> future versions.
>>
>> Thanks a lot
>>
>> Laura
>>
>>         [[alternative HTML version deleted]]
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> [hidden email]
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
>>
> --
> Roger Bivand
> Department of
> <https://maps.google.com/?q=Department+of&entry=gmail&source=g>
> Economics, Norwegian School of Economics,
> Helleveien 30, N-5045 Bergen, Norway.
> voice: +47 55 95 93 55; e-mail: [hidden email]
> http://orcid.org/0000-0003-2392-6140
> https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en
>
        [[alternative HTML version deleted]]

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

Re: error installing rgdal with gdal 2.3.0 on centos7

Tue, 05/29/2018 - 11:18
On Tue, 29 May 2018, Laura Poggio wrote:

> Dear all,
> I am trying to install rgdal on a centos 7 machine.

Which version of rgdal - the current CRAN source?

> First I installed from source gdal 2.3.0. No errors and it is working as
> expected.
>
> I then tried to install rgdal using R 3.4.4
>
> I get the error:
>
> In file included from /usr/local/include/gdal.h:45:0,
>                 from gdal_test.cc:1:
> /usr/local/include/cpl_port.h:187:6: error: #error Must have C++11 or newer.
> #    error Must have C++11 or newer.
Is this during configure? Could you try by downloading the tarball and
running

R CMD INSTALL rgdal_1-2.20.tar.gz

In configure, the value of CXX is taken from "${RBIN}" CMD config CXX
where "${RBIN}" is RBIN="${R_HOME}/bin/R" and R_HOME=`R RHOME`, so

R CMD config CXX

which in your case may need -std=g++11 or some such added - please inform.

Roger

>
> I can use a previous version of gdal (2.2.1) without problems, but I was
> wondering if other people found a more robust solution that could work with
> future versions.
>
> Thanks a lot
>
> Laura
>
> [[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]
http://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

error installing rgdal with gdal 2.3.0 on centos7

Tue, 05/29/2018 - 08:00
Dear all,
I am trying to install rgdal on a centos 7 machine.
First I installed from source gdal 2.3.0. No errors and it is working as
expected.

I then tried to install rgdal using R 3.4.4

I get the error:

In file included from /usr/local/include/gdal.h:45:0,
                 from gdal_test.cc:1:
/usr/local/include/cpl_port.h:187:6: error: #error Must have C++11 or newer.
 #    error Must have C++11 or newer.

I can use a previous version of gdal (2.2.1) without problems, but I was
wondering if other people found a more robust solution that could work with
future versions.

Thanks a lot

Laura

        [[alternative HTML version deleted]]

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

Re: converting hierarchical clusters to polygons

Mon, 05/28/2018 - 08:39
On Mon, May 28, 2018 at 6:00 AM, <[hidden email]> wrote:

> From: "Bannar-Martin, Katherine"
>         <[hidden email]>
> To: "[hidden email]" <[hidden email]>
> Subject: [R-sig-Geo] converting hierarchical clusters to polygons
> Message-ID:
>         <[hidden email].
> dfo-mpo.ca>
>
> Content-Type: text/plain; charset="utf-8"
>
> I have used hierarchical clustering to assign lats and longs (start and
> end positions of lines) to separate cluster IDs.
> I now need to convert each cluster of points to a polygon.
>

> I have 100s of clusters per year (13 years) so I do not want to have 1000s
> of separate polygon files, but instead one layer with all the polygons per
> year.
>
> Dummy data to show approximate structure:
> GISID     x             y             Attribute              Year
>  CLUSTER_ID
> 1             -129.24 52.994   Start                     2005      1
> 2             -131.26 52.73     Start                     2006      33
> 3             -126.02 49.297   End                       2005      5
>
This uses tidyverse and sf to find the convex hull of points in each
cluster and create a simple features object with one row per polygon. It
retains the Year and CLUSTER_ID so you can select by year and show all
clusters or write one file per year.

library(tidyverse)
library(sf)

d = read_table2(col_names=TRUE,
file="GISID     x             y             Attribute              Year
   CLUSTER_ID
1             -129.24 52.994   Start                     2005      1
2             -131.26 52.73     Start                     2006      33
3             -126.02 49.297   End                       2005      5")

groups = d %>%
  select(-GISID, -Attribute) %>%
  nest(x, y) %>%
  mutate(poly = map(data, ~st_convex_hull(st_multipoint(as.matrix(.[,c('x',
'y')]))))) %>%
  select(-data) %>%
  st_sf()

# For example to plot all polygons for one year, colored y CLUSTER_ID:
groups %>% filter(Year==2006) %>% select(-Year) %>% plot()

HTH,
Kent Johnson

        [[alternative HTML version deleted]]

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

converting hierarchical clusters to polygons

Sun, 05/27/2018 - 13:58
I have used hierarchical clustering to assign lats and longs (start and end positions of lines) to separate cluster IDs.
I now need to convert each cluster of points to a polygon.
My first attempt was with CHULL, with the aim to then convert each convex polygon to a polygon layer. However, I cannot get the hulls to plot by cluster and then save as an external object.
I think the easiest method would be to take the outside points of each cluster of points and connect them with a polyline and then convert it to a polygon.
I have 100s of clusters per year (13 years) so I do not want to have 1000s of separate polygon files, but instead one layer with all the polygons per year.

Dummy data to show approximate structure:
GISID     x             y             Attribute              Year       CLUSTER_ID
1             -129.24 52.994   Start                     2005      1
2             -131.26 52.73     Start                     2006      33
3             -126.02 49.297   End                       2005      5
...

Any advice, helpfiles, or vignettes would be greatly appreciated. I've read a variety of stackoverflow entries and r-sig-geo entries and have unsuccessfully adapted other solutions.
e.g. https://stackoverflow.com/questions/44928507/draw-polygons-around-clusters-from-hclust
https://www.nceas.ucsb.edu/scicomp/usecases/GenerateConvexHullAndROIForPoints
Thanks!

        [[alternative HTML version deleted]]

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

Pages