[R-sig-Geo] [Q]: Converting SpatialPolygons with proj4string to spatstat owin

Roger Bivand Roger.Bivand at nhh.no
Thu Apr 23 08:14:16 CEST 2009


On Wed, 22 Apr 2009, Michael Höhle wrote:

> -----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 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.

>
> the projection information appears to be lost, because the map is
> distorted now.
>
> Is there an easy way to fix this problem?

Project the geometries to the plane (spTransform methods in rgdal).

Hope this helps,

Roger

>
> Best regards,
>
> Michael
>
> - --
>>> sessionInfo()
> 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-----
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

-- 
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: Roger.Bivand at nhh.no


More information about the R-sig-Geo mailing list