Skip to content

[Q]: Converting SpatialPolygons with proj4string to spatstat owin

3 messages · Michael Höhle, Roger Bivand

#
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


Dear R-Sig-Geo,

I have a simple -- and probably trivial question -- which originates
from a lack of understanding about projections.

The problem occurs when using maptools to read some shapefile for
Germany (available from http://www.cdc.gov/epiinfo/europe/) in the WGS84
system.

library("maptools")
de <- readShapeSpatial("gm.shp",proj4string=CRS("+proj=longlat
+datum=WGS84 +ellps=WGS84"))

When plotting these data with plot(de) Germany looks nice and normal.
However, when I convert these data to a spatstat "owin":

owin.de <- as(de, "owin")
plot(owin.de)

the projection information appears to be lost, because the map is
distorted now.

Is there an easy way to fix this problem?

Best regards,

Michael

- --
R version 2.8.1 (2008-12-22)
i386-apple-darwin8.11.1

locale:
C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] rgdal_0.6-7     maps_2.1-0      spatstat_1.15-1 deldir_0.0-7
[5] gpclib_1.4-1    mgcv_1.4-1      maptools_0.7-21 sp_0.9-34
[9] foreign_0.8-29

loaded via a namespace (and not attached):
[1] grid_2.8.1      lattice_0.17-20 tcltk_2.8.1     tools_2.8.1
Warning message:
'DESCRIPTION' file has 'Encoding' field and re-encoding is not possible
- --

Michael H?hle, Ph.D.
Department of Statistics
University of Munich
Ludwigstrasse 33
80539 Munich
Germany

Phone:    +49 89 2180 6404
Fax:      +49 89 2180 5040

Email: hoehle at stat.uni-muenchen.de
Homepage: http://www.stat.uni-muenchen.de/~hoehle
PGP public key id: 0xA9589121

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFJ73noJenxFqlYkSERAvapAKDNTAxzAr7TFQhkUjqQnBOUvZFogACglyt3
71rdMKt6Hxvy9r0r44VTryQ=
=ks0C
-----END PGP SIGNATURE-----
#
On Wed, 22 Apr 2009, Michael H?hle wrote:

            
The plot method for Spatial* objects looks to see whether the geometries 
are in geographical coordinates. If they are, it applies a correction to 
the y axis depending on the distance from the Equator. You can get the 
spatstat look by fixing the aspect to 1 in plot(de, asp=1), overriding the 
adjustment.
Project the geometries to the plane (spTransform methods in rgdal).

Hope this helps,

Roger

  
    
1 day later
#
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Dear Roger,
Thats very helpful. Fiddling around with the aspect ratio, I tricked
spatstat to use the correct aspect ratio:

plot(owin.de,asp=attr(de,"asp"),main="")

to give me a nice looking map plotted with spatstat.
Ok, I'll look into that.

Thanks for the help.

Best regards,

Michael

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFJ8ZW5JenxFqlYkSERAmA5AKC0zaSIRGchcvaCIBF+KALS4n7B8ACfRaIe
ve26DmdtmILiNCysJ53oE0M=
=mLrH
-----END PGP SIGNATURE-----