On Fri, 19 Mar 2010, Axel Hille wrote:

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.

Don't presume, it is usually misleading.

You have not motivated this or your previous question, and are writing from a German free email provider, so we have no idea whether this is homework or what. Remember that a concise motivation and an informative affiliation assist helpers in perceiving "where you are coming from". The reason for no reply to your earlier question was most likely that you are not clear enough (or concise enough - most of the printout you included was irrelevant and obscures the issue).

Most likely the coordinate reference systems of the data differ, but I don't know if you know what a coordinate reference system is - a graduate geography student would, and wouldn't ask this question.

Your workflow (point data to Geneland, grid interpolation in a "haplo" of unknown provenance, Arc ASCII grid read in) leaves lots of possibilities for the raster to get out of register with respect to the (assumed) UTM32 points. Do you know definitely that the boundary polygons and rivers are also in UTM32? They are declared as such, but are the declarations correct? Do the input points plot correctly (are they in UTM32?)? Have you exported the input points/rivers/boundaries to KML to double-check in GE?

Try interpolating with some other tool and see whether the same problem occurs, or whether it is created in Geneland/haplo.

Hope this helps,

Roger

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


--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: [email protected]

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

Reply via email to