[R-sig-Geo] Transforming from WGS84 to NAD83 Stateplane Alaska zone 1
Gregovich, Dave P (DFG)
dave.gregovich at alaska.gov
Thu Jul 19 04:11:33 CEST 2012
Hello,
I apologize for reposting, but am still confounded after spending more time with the following problem, despite some help from the group.
I am attempting to learn GIS in R. I have worked with ArcGIS a lot, and know that my data is projecting correctly in that environment relative to other trusted data. When I import a text file of animal locations into ArcGIS, then define the projection as WGS84, then transform to NAD83, I can obtain proj4strings from the resulting shapefiles to use as follows:
#__________________________________________________________
#ArcGIS portion---
#step 1: bring text file into ArcGIS
#step 2: display xy events, defining projection as WGS 84
#step 3: export this data to a shapefile (WGS84)
# --result: 'bear_ArcGIS_wgs84',
bear.file.loc<-"c:/dave/temp/rgis"
bear.wgs84.layer<-"bear_ArcGIS_wgs84"
bear_wgs84<-readOGR(dsn=bear.file.loc,layer=bear.wgs84.layer)
string.wgs84<-proj4string(bear_wgs84)
#step 4: project this shapefile to NAD83 State Plane AK zone 1
# --result: 'bear_nad83',
bear.nad83.layer<-"bear_ArcGIS_nad83"
bear_nad83<-readOGR(dsn=bear.file.loc,layer=bear.nad83.layer)
string.nad83.sp.ak.z1<-proj4string(bear_nad83)
###check coords...
coordinates(bear_nad83)
Then, I would like to ensure that an analogous process in R (via sp and rgdal) works, so I attempt this, using the proj4strings from above:
#__________________________________________________________
#R portion---
#step 1: read table into R
txt.loc<-"C:/dave/temp/rgis/bear.txt"
bear.via.R.wgs84<-read.table(txt.loc,header=T,sep=",",stringsAsFactors=F)
#step 2: define coordinate columns
#coordinates(bear.via.R.wgs84)<-c("Long_","Latitude")
coordinates(bear.via.R.wgs84)<- ~Long_ + Latitude
#step 3: define projection
proj4string(bear.via.R.wgs84)<-string.wgs84
writeOGR(bear.via.R.wgs84,dsn=bear.file.loc,layer="bear_R_wgs84",
driver=ogrDrivers()[7,1])
bear.via.R.nad83<-spTransform(bear.via.R.wgs84,CRS(string.nad83.sp.ak.z1))
proj4string(bear.via.R.nad83)
writeOGR(bear.via.R.nad83,dsn=bear.file.loc,layer="bear_R_nad83",
driver=ogrDrivers()[7,1])
###check coords...
coordinates(bear.via.R.nad83)
#__________________________________________________________
As you can see if you are saintly enough to still be with me, the coordinates do not jive. I attach the animal locations I am working with in case there is someone who wants to try to replicate the process. I am also attaching the shapefiles generated by ArcGIS and by R in case they are useful to you.
Thanks so much for your time.
__________________________________
Dave Gregovich
Research Analyst
Alaska Department of Fish and Game
Wildlife Conservation Division
Douglas, AK 99821
(907) 465-4291
dave.gregovich at alaska.gov
__________________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20120719/f237c7f0/attachment.html>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: bear.txt
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20120719/f237c7f0/attachment.txt>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bear_shapefiles.zip
Type: application/x-zip-compressed
Size: 12130 bytes
Desc: bear_shapefiles.zip
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20120719/f237c7f0/attachment.bin>
More information about the R-sig-Geo
mailing list