[R-sig-Geo] CRS for the European Biogeographical Regions in R

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Sun Feb 8 12:37:23 CET 2015


On Sat, Feb 7, 2015 at 4:53 PM, Roland Kaiser <kardinal.eros at gmail.com> wrote:

> #       the projection information is given in the *.qpj file

I can't see a *.qpj file in that shapefile. There is a *.prj file
which contains projection info.

> #       unfortunately, it is not read from the dataset by the OGR driver

The *.prj file **is** read when using readOGR:

 > r=readOGR(".","BiogeoRegions2011")
 OGR data source with driver: ESRI Shapefile
 Source: ".", layer: "BiogeoRegions2011"
 with 12 features and 4 fields
 Feature type: wkbPolygon with 2 dimensions
 > proj4string(r)
 [1] "+proj=laea +lat_0=52 +lon_0=10 +x_0=4321000 +y_0=3210000
+ellps=GRS80 +units=m +no_defs"

- that's a full projection specification, rather than an epsg code
though, because that's what's in the file.

> #       we have do define it manually by specifing argument p4s

No we don't!

> pg <- readOGR(dsn = "BiogeoRegions2011_shapefile",
>         layer = "BiogeoRegions2011", p4s = "+init=epsg:3035")

Is the .prj file text coding the same projection as epsg:3035?
http://epsg.io/ says 3035 is:

+proj=laea +lat_0=52 +lon_0=10 +x_0=4321000 +y_0=3210000 +ellps=GRS80
+towgs84=0,0,0,0,0,0,0 +units=m +no_defs

So yes. But there's no need to specify it in readOGR since you have
the .prj file. The maptools functions readShapeSpatial and friends
ignore the .prj file - I don't know why they exist any more!

 > r2=readShapeSpatial("BiogeoRegions2011.shp")
 > proj4string(r2)
[1] NA

Ouch.

Barry



More information about the R-sig-Geo mailing list