[R-sig-Geo] readOGR and proj4 string

Roger Bivand Roger.Bivand at nhh.no
Thu Apr 10 08:57:16 CEST 2008


On Thu, 10 Apr 2008, Agustin Lobo wrote:

> The manual page of readOGR states:
>
> p4s 	PROJ4 string defining CRS, if default NULL, the value is read from
> the OGR data set
>
> then, if a  *.prj file is present for a *.shp,
> why is the proj4string of the resulting SpatialPolygonsDataframe
> set to NA? is this a general behaviour or am I doing someting
> wrong?

Puzzling. Could you make your test file available for me to check?

Roger

>
> > absUTMpolysHABS2 <- readOGR("C:/ALOBO/Lidia",layer="test_TNT")
>
> where I have:
>
> test_TNT.avl
> test_TNT.dbf
> test_TNT.prj
> test_TNT.shp
> test_TNT.shx
>
> with test_TNT.prj:
>
> PROJCS["ED50_/_UTM_zone_31N_(CM_3E)",GEOGCS["ED50_/_Geographic",DATUM["D_European_1950",SPHEROID["International_1924",6378388.0,297.0]TOWGS84[,-87.0,-98.0,-121.0,0.0,0.0,0.0,0.0]],PRIMEM["Greenwich",0.0],UNIT["Decimal_Degree",0.01745329251994330]],PROJECTION["Transverse_Mercator"],PARAMETER["Latitude_Of_Center",0.0],PARAMETER["Longitude_Of_Origin",3.0],PARAMETER["Scale_Factor",0.9996000000],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],UNIT["Meter",1.0]]
>
> I get:
> > class(delme)
> [1] "SpatialPolygonsDataFrame"
> attr(,"package")
> [1] "sp"
> > str(delme,max.level=2)
> Formal class 'SpatialPolygonsDataFrame' [package "sp"] with 5 slots
>   ..@ data       :'data.frame': 1555 obs. of  16 variables:
>   ..@ polygons   :List of 1555
>   ..@ plotOrder  : int [1:1555] 148 143 792 740 209 335 895 619 1127
> 1160 ...
>   ..@ bbox       : num [1:2, 1:2]  412000 4584000  466000 4624000
>   .. ..- attr(*, "dimnames")=List of 2
>   ..@ proj4string:Formal class 'CRS' [package "sp"] with 1 slots
> > delme at proj4string
> CRS arguments: NA
>
> Agus
>

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