Here's another way with spbabel.
library(dplyr)
library(spbabel)
pts <-
tibble::tribble(~ID, ~x, ~y, ~grp,
1 , -33, -23,1,
2 , -32, -23,1,
3 , -32, -22,1,
4 , -33, -22,1,
5 , -32,
Hi Antonio,
have you tried with sf? Like:
library(sf)
pts <-
tibble::tribble(~ID, ~x, ~y, ~grp,
1 , -33, -23,1,
2 , -32, -23,1,
3 , -32, -22,1,
4 , -33, -22,1,
5 , -32, -23,2,
Thanks Lulla,
Nice solution. I could also export it as a shapefile after transforming it
to a spatial polygon dataframe.
The problem is that I could not "individualize" the squares in a multipart
layer. They all have the same ID. I tried to change this without success:
"Single ID required".
The
Maybe something like this?
poly <- SpatialPolygons(list(Polygons(tapply(seq_len(nrow(vertices)),
vertices$cod,
function(x)
Polygon(vertices[x,1:2])), ID="1")),
Hi,
I have a data.frame with the vertices (lon / lat) and codes from several
squares (more than 500 in the real dataset).
I want to create an object with these polygons (squares) and after this
export it as a shapefile.
With the script below I can draw one square.
library(sp)
P1 =
Dear Ákos and Vijay,
Thank you very much for the solutions. They work perfectly!
Sincerely,
Milu
On Tue, Aug 14, 2018 at 6:12 PM, Vijay Lulla wrote:
> And if you need coordinates as part of your data frame just do
> cbind(coordinates(x), as.data.frame(x, xy = TRUE))
>
> On Tue, Aug 14, 2018
And if you need coordinates as part of your data frame just do
cbind(coordinates(x), as.data.frame(x, xy = TRUE))
On Tue, Aug 14, 2018 at 11:50 AM Bede-Fazekas Ákos
wrote:
> Dear Milu,
>
> I think that you are looking for as.data.frame(x, xy = TRUE).
>
> HTH,
> Ákos Bede-Fazekas
> Hungarian
Dear Milu,
I think that you are looking for as.data.frame(x, xy = TRUE).
HTH,
Ákos Bede-Fazekas
Hungarian Academy of Sciences
2018.08.14. 17:03 keltezéssel, Miluji Sb írta:
Dear all,
I have the following rasterbrick (x);
class : RasterBrick
dimensions : 112, 272, 30464, 7305 (nrow,
Dear all,
I have the following rasterbrick (x);
class : RasterBrick
dimensions : 112, 272, 30464, 7305 (nrow, ncol, ncell, nlayers)
resolution : 0.25, 0.25 (x, y)
extent : -132, -64, 24, 52 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84