|
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 __________________________________ _______________________________________________ R-sig-Geo mailing list [hidden email] https://stat.ethz.ch/mailman/listinfo/r-sig-geo |
|
On Thu, Jul 19, 2012 at 3:11 AM, Gregovich, Dave P (DFG)
<[hidden email]> wrote: > 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: > Yeah there's a constant shift between the R coordinates and the ESRI coordinates: > coordinates(bear_R_nad83)-coordinates(bear_ArcGIS_nad83) coords.x1 coords.x2 [1,] 4181322 -5575097 [2,] 4181322 -5575097 [3,] 4181322 -5575097 - a workaround would just be to add this offset to your coordinates.... I've tried to figure out where this is coming from but with no success. I've not had any problems with coordinates as long as I stick to EPSG-defined coordinate systems. I don't have a copy of ArcGis to hand, but I recall it has all sorts of other systems in it.... Barry _______________________________________________ R-sig-Geo mailing list [hidden email] https://stat.ethz.ch/mailman/listinfo/r-sig-geo |
|
Administrator
|
On Thu, 19 Jul 2012, Barry Rowlingson wrote:
> On Thu, Jul 19, 2012 at 3:11 AM, Gregovich, Dave P (DFG) > <[hidden email]> wrote: >> 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: >> > > Yeah there's a constant shift between the R coordinates and the ESRI > coordinates: > > > coordinates(bear_R_nad83)-coordinates(bear_ArcGIS_nad83) > coords.x1 coords.x2 > [1,] 4181322 -5575097 > [2,] 4181322 -5575097 > [3,] 4181322 -5575097 > > - a workaround would just be to add this offset to your coordinates.... > > I've tried to figure out where this is coming from but with no > success. I've not had any problems with coordinates as long as I stick > to EPSG-defined coordinate systems. I don't have a copy of ArcGis to > hand, but I recall it has all sorts of other systems in it.... The EPSG codes 3468 and 26931 (Alaska I NAD83) are off by: > coordinates(bear_nad83) - coordinates(spTransform(bear_wgs84, + CRS("+init=epsg:26931"))) coords.x1 coords.x2 [1,] 1.191571 -0.4911515 [2,] 1.191572 -0.4911513 [3,] 1.191571 -0.4911517 .... with the main difference being: > CRS("+init=epsg:26931") CRS arguments: +init=epsg:26931 +proj=omerc +lat_0=57 +lonc=-133.6666666666667 +alpha=323.1301023611111 +k=0.9999 +x_0=5000000 +y_0=-5000000 +gamma=323.1301023611111 +datum=NAD83 +units=m +no_defs +ellps=GRS80 +towgs84=0,0,0 and > CRS(proj4string(bear_nad83)) CRS arguments: +proj=omerc +lat_0=57 +lonc=-133.6666666666667 +alpha=-36.86989764583333 +k=0.9999 +x_0=5000000 +y_0=-5000000 +datum=NAD83 +units=m +no_defs +ellps=GRS80 +towgs84=0,0,0 +alpha being 360-alpha, and +gamma being declared. readOGR() is reading the contents of bear_ArcGIS_nad83.prj correctly, +alpha is given there as a negative number, and no +gamma is given, which appears to be why projection is failing. There are more details of the complications of the (Hotine) oblique mercator here: http://www.remotesensing.org/geotiff/proj_list/epsg_om.html Hope this helps, Roger > > Barry > > _______________________________________________ > R-sig-Geo mailing list > [hidden email] > https://stat.ethz.ch/mailman/listinfo/r-sig-geo > -- Roger Bivand Department of Economics, NHH Norwegian School of Economics, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43 e-mail: [hidden email] _______________________________________________ R-sig-Geo mailing list [hidden email] https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Roger Bivand
Economic Geography Section Department of Economics Norwegian School of Economics and Business Administration Helleveien 30 N-5045 Bergen, Norway |
| Powered by Nabble | Edit this page |
