Hi R- Reserchers
To improve my analysis i need a raster with 0.5 x 0.5 of resolution.
I use this code but I tried several solution to find the right command to
obtain 0.5x0.5 resolution
Thanks
Ale
> dem.area <-
([EMAIL PROTECTED],[EMAIL PROTECTED],1])*([EMAIL PROTECTED],[EMAIL
PROTECTED],1]) #A#
makes the dem area
> dem.pixelsize <- round(sqrt(dem.area/length(ground$Z)),0) #A# makes the
cell size
> dem.pixelsize
[1] 1
> dem.grid <-
GridTopology(cellcentre.offset=c([EMAIL PROTECTED],1],[EMAIL PROTECTED],1]),
cellsize=c(dem.pixelsize,dem.pixelsize),
cells.dim=c(round(([EMAIL PROTECTED],[EMAIL
PROTECTED],1])/dem.pixelsize,0),round
(([EMAIL PROTECTED],[EMAIL PROTECTED],1])/dem.pixelsize,0)))
> dem.grid
X1 X2
cellcentre.offset 267586.6 4147061
cellsize 1.0 1
cells.dim 1405.0 829
> dem <- as(SpatialGrid(dem.grid, proj4string = CRS(as.character(NA))),
"SpatialGridDataFrame")
> ID <- as.factor(1:([EMAIL PROTECTED]@cells.dim[2]))
> [EMAIL PROTECTED] <- as.data.frame(ID)
> proj4string(dem) <- CRS("+init=epsg:26911")
> str(dem["ID"])
Formal class 'SpatialGridDataFrame' [package "sp"] with 6 slots
..@ data :'data.frame': 1164745 obs. of 1 variable:
.. ..$ ID: Factor w/ 1164745 levels "1","2","3","4",..: 1 2 3 4 5 6 7 8 9
10 ...
..@ grid :Formal class 'GridTopology' [package "sp"] with 3 slots
.. .. ..@ cellcentre.offset: num [1:2] 267587 4147061
.. .. ..@ cellsize : num [1:2] 1 1
.. .. ..@ cells.dim : int [1:2] 1405 829
..@ grid.index : int(0)
..@ coords : num [1:2, 1:2] 267587 268991 4147061 4147889
.. ..- attr(*, "dimnames")=List of 2
.. .. ..$ : NULL
.. .. ..$ : chr [1:2] "coords.x1" "coords.x2"
..@ bbox : num [1:2, 1:2] 267586 4147060 268991 4147889
.. ..- attr(*, "dimnames")=List of 2
.. .. ..$ : chr [1:2] "coords.x1" "coords.x2"
.. .. ..$ : chr [1:2] "min" "max"
..@ proj4string:Formal class 'CRS' [package "sp"] with 1 slots
.. .. ..@ projargs: chr " +init=epsg:26911 +proj=utm +zone=11 +ellps=GRS80
+datum=NAD83 +units=m +no_defs +towgs84=0,0,0"
>
_______________________________________________
R-sig-Geo mailing list
[email protected]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo