[R-sig-Geo] incompatible projections/coordinate-systems?

Michael Sumner mdsumner at gmail.com
Tue Nov 17 02:21:25 CET 2009


The plot functions do not automatically transform between coordinate
systems, they just assume the space is shared.

yta and vagar share the same PROJ.4 string:

identical(proj4string(yta), proj4string(vagar))
[1] TRUE

so, assuming that all 3 coordinate systems have been recorded
correctly in the .prj files this should be fine:

plot(yta)
plot(vagar, add = TRUE)
sdn.reproj <- spTransform(sdn, CRS(proj4string(vagar)))
plot(sdn.reproj, add = T)

You are expected to ensure the projections are the same when plotting,
or using overlay.

I guess it wouldn't take much for those functions to do the job
on-the-fly, but often the metadata is non-existent or incorrectly
specified and so a manual step like this can save subtle errors. Also,
it's much more work to handle rasters with on-the-fly reprojection -
it takes a lot more options and is not reversible like vector
reprojection often is.

Cheers, Mike.

On Tue, Nov 17, 2009 at 11:02 AM, Hans Ekbrand <hans at sociologi.cjb.net> wrote:
> Hi list,
>
> I'm a newcomer to GIS and r-sig-geo. I have exported some shapefiles
> from ArcGIS and succeeded in plotting them with R. But one shapefile has
> a different coordinate system, I think, and it does not turn up in the
> graph when added to the others. In ArcGIS, this layer had an "unknown"
> coordinate system, but rendered at the right location in relation to the
> other layers.
>
> I have made a tar-archive with the shape-files and a script to import
> them into R and generate a map. The problematic shape is "sdn".
>
> http://sociologi.cjb.net/temp/create-map-data.tbz
> http://sociologi.cjb.net/temp/create-map.r
>
> Here is the summary output of a "good" shape, "yta", followed by summary
> of the problematic shape "sdn".
>
>> summary(yta)
>
> Object of class SpatialPolygonsDataFrame
>
> Coordinates:
>
>       min       max
>
> r1  303850  344600.1
>
> r2 6388900 6415400.0
>
> Is projected: TRUE
>
> proj4string :
>
> [+proj=utm +zone=33 +ellps=GRS80 +units=m +no_defs]
>
> Data attributes:
>
>      KKOD         SHAPE_AREA          SHAPE_LEN
>
>  Min.   :1.000   Min.   :7.812e+05   Min.   :    3530
>
>  1st Qu.:3.000   1st Qu.:1.125e+06   1st Qu.:    5514
>
>  Median :5.000   Median :3.006e+06   Median :    9121
>
>  Mean   :4.941   Mean   :1.272e+09   Mean   :  647692
>
>  3rd Qu.:7.000   3rd Qu.:1.685e+07   3rd Qu.:   37437
>
>  Max.   :7.000   Max.   :3.119e+10   Max.   :21081735
>
>
>
>> summary(sdn)
>
> Object of class SpatialPolygonsDataFrame
>
> Coordinates:
>
>       min     max
>
> r1 1247825 1288137
>
> r2 6382086 6422038
>
> Is projected: TRUE
>
> proj4string :
>
> [+proj=tmerc +lat_0=0 +lon_0=15.80827777777778 +k=1 +x_0=1500000 +y_0=0
>
> +ellps=bessel +units=m +no_defs]
>
> Data attributes:
>
>   SW_MEMBER           NAMN       DISTRIKT       REG_DATUM         DATUM
>
>  Min.   : 1   10 Högsbo  : 1   Centrum: 4   1996/01/01:21   2001/09/10:21
>
>  1st Qu.: 6   11 Älvsborg: 1   Norr   :10
>
>  Median :11   12 Frölunda: 1   Väster : 7
>
>  Mean   :11   13 Askim   : 1
>
>  3rd Qu.:16   14 Tynnered: 1
>
>  Max.   :21   15 Styrsö  : 1
>
>              (Other)    :15
>
>  OPERATör    KVALITET      AREA             PERIMETER
>
>  eoh:21   Min.   :0   Min.   :  3729696   Min.   :10507
>
>          1st Qu.:0   1st Qu.:  9113274   1st Qu.:15376
>
>          Median :0   Median : 16307500   Median :21493
>
>          Mean   :0   Mean   : 34423248   Mean   :26351
>
>          3rd Qu.:0   3rd Qu.: 34864909   3rd Qu.:32932
>
>          Max.   :0   Max.   :198632325   Max.   :64221
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>



More information about the R-sig-Geo mailing list