[R-sig-Geo] get X and Y form point shapefile

Michael Sumner mdsumner at gmail.com
Wed Feb 10 23:13:40 CET 2010


xy <- coordinates(sample.shp)

will give you a 2-column matrix "xy" of the X and Y coordinates.

For more complete reporting for this list, please provide the packages
you are using and the version. The easiest way is to use sessionInfo()

See here for more information, and the posting guide:
http://www.r-project.org/mail.html

Cheers, Mike.

On Thu, Feb 11, 2010 at 8:54 AM, gianni lavaredo
<gianni.lavaredo at gmail.com> wrote:
> dear Rearchers
>
> I know this is easy but after 5 hours on R, I am honest and  I don't
> rememeber to get X, Y coordinate from point shapefile
>
> sample.shp <- readShapeSpatial("sample.shp")
> proj4string(sample.shp) <- CRS("+init=epsg:26911")
> str(sample.shp)
>  str(sample.shp)
>
> Formal class 'SpatialPointsDataFrame' [package "sp"] with 5 slots
>  ..@ data       :'data.frame': 50372 obs. of  1 variable:
>  .. ..$ Z: num [1:50372] 1498 1498 1499 1499 1503 ...
>  .. ..- attr(*, "data_types")= chr "N"
>  ..@ coords.nrs : num(0)
>  ..@ coords     : num [1:50372, 1:2] 268753 268754 268763 268761 268774 ...
>  .. ..- attr(*, "dimnames")=List of 2
>  .. .. ..$ : chr [1:50372] "0" "1" "2" "3" ...
>  .. .. ..$ : chr [1:2] "coords.x1" "coords.x2"
>  ..@ bbox       : num [1:2, 1:2] 268501 4147540 268881 4147786
>  .. ..- attr(*, "dimnames")=List of 2
>  .. .. ..$ : chr [1:2] "coords.x1" "coords.x2"
>  .. .. ..$ : chr [1:2] "min" "max"
>  ..@ proj4string:Formal class 'CRS' [package "sp"] with 1 slots
>  .. .. ..@ projargs: chr "+init=epsg:26911"
>
> thanks
> gianni
>
>        [[alternative HTML version deleted]]
>
> _______________________________________________
> 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