[R] How to write a shapefile with projection

Monica Pisica pisicandru at hotmail.com
Mon Nov 7 15:18:55 CET 2011


Hi Patrick,

Thanks for letting me know. I mostly use rgdal to read and write rasters so until now i kind of ignore other functionality. Unfortunately i supposed that a package dedicated to shapefiles would be the answer and had the functionality i needed. But rgdal does a nice job in saving my files as i need. It is good to know how to add the projection file to the shapefiles for the future, if it is not generated from the onset.

Thanks again,

Monica

----------------------------------------
> Date: Sat, 5 Nov 2011 14:27:29 +0100
> From: patrick.giraudoux at univ-fcomte.fr
> To: pisicandru at hotmail.com
> CC: r-help at r-project.org
> Subject: re: How to write a shapefile with projection
>
> > Hi,
> >
> > Sorry i have put such a detailed question to the list about writing a shapefile with projection. I realized that if i use writeOGR from rgdal and not the other write shapefile functions i can get a shapefile with projection recognized by ArcGIS. The command is (in case anybody wonders):
> >
> > ?writeOGR(crest.sp, "I:\\LA_levee\\Shape", "llev_crest_pts6", driver = "ESRI Shapefile")
> >
> > where crest.sp is a spatial point data frame with projection.
> >
> > Thanks,
> >
> > Monica
>
> Indeed.
>
> writePointsShape() does not write the projection file, but using the
> function showWKT from rgdal, you can also create one like that:
>
> writePointsShape(crest.sp,"crest")
> cat(showWKT(proj4string(crest.sp)),file="crest.prj")
>
> Patrick
>
>
 		 	   		  


More information about the R-help mailing list