Herman Toothrot
Herman Toothrot

Reputation: 1533

How to import projection in readShapePoly() function? - R

I am importing a polygon shapefile from Arcmap that has already a projection set and comes with all its files (sbn,sbx,prj,etc).

However after I use the readShapePoly function, when I do a summary it looks like the projection information is blank. Is the projection included already or not recognized?

Object of class SpatialPolygonsDataFrame
Coordinates:
        min     max
x   35551.4 1585917
y 6318047.3 9408727
Is projected: NA 
proj4string : [NA]
Data attributes:

I know there is a proj4string attribute but it's not clear how to use it and the prj file it's already attached to the .shp file. I can consider another function that does a better job if there is one. Not sure if rgdal with readOGR does what I want.

edit follow up: I tried with readOGR thanks for the reply. I am using this code test<-readOGR(dsn=getwd(), layer="grid") and the shapefile is here speedy.sh/Ry8rU/grid.zip and it still doesn't read the projection.

Upvotes: 0

Views: 1578

Answers (1)

Mox
Mox

Reputation: 531

If you must use RShapePoly, try something like:

to read the projection on your shapefile:

proj4string(yourshapefile.pr) 

[1] "+init=epsg:2163 +proj=laea +lat_0=45 +lon_0=-100 +x_0=0 +y_0=0 +a=6370997 +b=6370997 +units=m +no_defs"

now project it

yourshapefile.pr <- spTransform(yourshapefile, CRS( "+init=epsg:2163" )) #US National Atlas Equal Area

Upvotes: 1

Related Questions