Dear OSGEO list members,
I try it again hoping that someone could give me some hint.
I have the problem that a raster grid does not fit to two additional
spatial objects in the coordinate space of the plot, when plotted as
overlay.
I presume I need to recenter the raster grid but don`t know how? Any help
is welcome.
Cheers
Axel Hille
Infos to problem:
First, I exported the "Geneland" (R-package) output
file (population assignments, georeferenced ) , where the coordinates of
the individual samples are given in meters in the UTM-32N projection
(Middle Europe)
R-2.10.1-code:
< head(mat.neu)
< UTM.32E UTM.32N
< 1 555799.2 5538765
< 2 555825.5 5538792
by means of the function "haplo" by Cristoph Heibl as an ARCView ascii
raster grid
R-2.10.1 "file.show":
< gncols 100
< nrows 100
< xllcorner -276050.539270941
< yllcorner 4802126.61354771
< cellsize 14070.0737708024
< NODATA_value -9999
< 0.3275 0.3225 0.315 0.325 ..........
With readAsciGrid of "maptools" I read in the file,
R-2.10.1-code:
< (file1 <- paste(MCMC.PATH.TRANS3,"trans3.map.arcgis1",sep=""))
< x.grid <- readAsciiGrid(file1, as.image=FALSE, proj4string=
CRS("+init=epsg:32632"))
< summary(x.grid)
< Object of class SpatialGridDataFrame
< Coordinates:
< min max
< coords.x1 -276050.5 1130957
< coords.x2 4802126.6 6209134
< Is projected: TRUE
< proj4string :
< [+init=epsg:32632 +proj=utm +zone=32 +ellps=WGS84 +datum=WGS84 +units=m
+no_defs +towgs84=0,0,0]
< Number of points: 2
< Grid attributes:
< cellcentre.offset cellsize cells.dim
< 1 -269015.5 14070.07 100
< 2 4809161.7 14070.07 100
< Data attributes:
< Min. 1st Qu. Median Mean 3rd Qu. Max.
< 0.0000 0.3187 0.3325 0.3427 0.3463 1.0000
Then I wanted to plot it and add two additional Spatial objects, a
SpatialPolygonsDataFrame (European map in the same projection)
and a SpatialLine object (rivers),
R-2.10.1-code:
str(eur.SPpdf2, max.level=2)
> Formal class 'SpatialPolygonsDataFrame' [package "sp"] with 5 slots
> ..@ data :'data.frame': 66 obs. of 20 variables:
> .. ..- attr(*, "data_types")= chr [1:20] "C" "C" "C" "C" ...
> ..@ polygons :List of 66
> ..@ plotOrder : int [1:66] 12 47 44 59 38 33 11 34 1 5 ...
> ..@ bbox : num [1:2, 1:2] -1112905 4041472 1351429
6597694
> .. ..- attr(*, "dimnames")=List of 2
> ..@ proj4string:Formal class 'CRS' [package "sp"] with 1 slots
R-2.10.1-code:
summary(eur.SPpdf2)
> Object of class SpatialPolygonsDataFrame
> Coordinates:
> min max
> x -1112905 1351429
> y 4041472 6597694
> Is projected: TRUE
> proj4string :
> [+init=epsg:32632 +proj=utm +zone=32 +ellps=WGS84 +datum=WGS84 +units=m
+no_defs +towgs84=0,0,0]
> Data attributes: LAYER FIPS_ADMIN GMI_ADMIN .......
R-2.10.1-code:
eur.river.SPldf2 <- spTransform(eur.river.SPldf,
CRS("+init=epsg:32632")) # UTM32N
bb.river <- eur.river.spl...@bbox
bb.river
> min max
> r1 298399.7 849034.5
> r2 5265325.5 5749782.6
The plot is ok for the vector shapes, but the raster does not align within
the coordinate space.
As I'm not so familiar with the information given for the raster file I#m
asking the rgeo users
what to do to place the raster correctly within the plot.
Raster infos:
object.size(x.grid)
> [1] 82916
object.size(slot(x.grid, "grid"))
> [1] 556
object.size(slot(x.grid, "grid.index"))
> [1] 24
object.size(slot(x.grid, "coords"))
> [1] 344
object.size(slot(x.grid, "bbox"))
> [1] 440
The plot is ok for the vector shapes, but the raster does not align within
the coordinate space.
As I'm not so familiar with the information given for the raster file I#m
asking the rgeo users
what to do to place the raster correctly within the plot.
Raster infos:
object.size(x.grid)
> [1] 82916
object.size(slot(x.grid, "grid"))
> [1] 556
object.size(slot(x.grid, "grid.index"))
> [1] 24
object.size(slot(x.grid, "coords"))
> [1] 344
object.size(slot(x.grid, "bbox"))
> [1] 440
x.g...@bbox
> min max
> coords.x1 -276050.5 1130957
> coords.x2 4802126.6 6209134
> x.g...@bbox["coords.x1", ]
> min max
> -276050.5 1130956.8
> print(slot(slot(x.grid, "grid"), "cellsize"), digits=20)
[1] 14070.0737708024 14070.0737708024
> print(slot(slot(x.grid, "grid"), "cellcentre.offset"), digits=20)
[1] -269015.50238554 4809161.65043311
> print(slot(slot(x.grid, "grid"), "cells.dim"), digits=20)
[1] 100 100
>
x.g...@bbox["coords.x1", ]
> min max
> -276050.5 1130956.8
> print(slot(slot(x.grid, "grid"), "cellsize"), digits=20)
[1] 14070.0737708024 14070.0737708024
> print(slot(slot(x.grid, "grid"), "cellcentre.offset"), digits=20)
[1] -269015.50238554 4809161.65043311
> print(slot(slot(x.grid, "grid"), "cells.dim"), digits=20)
[1] 100 100
>
-- GMX DSL: Internet, Telefon und Entertainment für nur 19,99 EUR/mtl.!
http://portal.gmx.net/de/go/dsl02
--
http://portal.gmx.net/de/go/dsl02
[[alternative HTML version deleted]]
_______________________________________________
R-sig-Geo mailing list
[email protected]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo