[R-sig-Geo] Changing projection of a shapefile
Barry Rowlingson
b.rowlingson at lancaster.ac.uk
Wed Mar 2 10:21:11 CET 2011
On Tue, Mar 1, 2011 at 5:17 PM, Ervan Rutishauser
<er.rutishauser at gmail.com> wrote:
> Dear R-user,
>
> I would like to change the projection of a shapefile using R, but can't get
> it.
> I know that the shapefile is projected in CSG67 (French Guiana) ( see :
> http://spatialreference.org/ref/epsg/4623/ ), but seems not to be defined in
> the shapefile.
> I would like to change this projection in WSG84 N22.
> Here is what I did:
>
>> gap<-readShapePoly("Donnees/Paracou_PT/ArcView_export/Gaps 2000 Topo
> FM.shp")
>> proj4string(gap)
> [1] NA
>> proj4string(gap)<-CRS("+init=epsg:4623")
> Erreur dans `proj4string<-`(`*tmp*`, value = <S4 object of class "CRS">) :
> Geographical CRS given to non-conformant data
>> proj4string(gap)<-CRS("+proj=longlat +ellps=intl
> +towgs84=-186,230,110,0,0,0,0 +units=m")
> Erreur dans `proj4string<-`(`*tmp*`, value = <S4 object of class "CRS">) :
> Geographical CRS given to non-conformant data
>
This could be because your data is outside the valid range for the
CRS you are trying to apply. Here is an example where I get the same
error by giving a lat-long value that is outside +-90 and +-180, and
try to apply epsg:4326 (WGS84 lat-long coords):
> d=data.frame(x=200,y=900,z=1)
> coordinates(d)=~x+y
> proj4string(d)=CRS("+init=epsg:4326")
Error in `proj4string<-`(`*tmp*`, value = <S4 object of class "CRS">) :
Geographical CRS given to non-conformant data
Try with values that are valid lat-long:
> d=data.frame(x=20,y=9,z=1)
> coordinates(d)=~x+y
> proj4string(d)=CRS("+init=epsg:4326")
So whats the 'bbox(gap)' and is it valid for that CRS?
Barry
More information about the R-sig-Geo
mailing list