[R-sig-Geo] project the lat./long. to x/y

Roger Bivand Roger.Bivand at nhh.no
Wed Dec 6 15:21:30 CET 2006


On Wed, 6 Dec 2006, zhijie zhang wrote:

> Dear friends,
>   I had a point pattern dataset, whose locations was defined by  lat./long..
> In the past, I used ARCGIS to specify its coordinate system and the
> projection method, now i want to do it in R. I don't know how to do it,
> because it needs me to specify the *Geographic Coordinate System and the
> Projected Coordinate System.* Maybe i mistake the information in ARCGIS and
> only the projection method need to be specified because of my poor knwledge
> on coordiante systems.

Coordinate systems are unusually difficult to understand for everybody!

In rgdal:

EPSG <- make_EPSG()
EPSG[grep("Xian", EPSG$note), 1:2]

gives a list of the known projections including "Xian",

among which:

CRS("+init=epsg:2384")

looks promising. The a= and b= specify the ellipsoid used, but I have not
been able to find an authority to confirm that it is D_Xian_1980. One way
to check would be to take a long/lat value in WGS84 (for known datum) and
convert it to the target projection in both ArcGIS and with spTransform()
in rgdal, and see how far they differ. I do not see anything helpful in 
http://www.asprs.org/resources/GRIDS - referenced on the make_EPSG help 
page, which is often a good authority, so you may need to double-check 
with local sources.

The way to go would be to make your (point?) data set into a Spatial* 
object with a projection argument like CRS("+proj=longlat +ellps=WGS84") 
if the ellipsoid is correct, and use spTransform to get to the 
Gauss_Kruger Xian datum representation.

Roger

PS. Yes, the Windows binary of the rgdal version you give below was built 
on R 2.4.0 (you are on Windows?). You need to download a Windows binary 
package manually from http://cran.r-project.org/bin/windows/contrib/ 
(there is a 0.4-12 version for R 2.3); the same may apply to other 
packages.

> 
> ---------------------------------------------------The information in ARCGIS
> after projecting the dataset-------
> Geometry Type: Point
> 
> *Geographic Coordinate System:* #specify the coordinate system
> GCS_Xian_1980
> Datum: D_Xian_1980
> Prime Meridian: 0
> 
> *Projected Coordinate System:* Xian_1980_3_Degree_GK_CM_117E   #specify the
> projection method
> Projection: Gauss_Kruger
> False_Easting: 500000.00000000
> False_Northing: 0.00000000
> Central_Meridian: 117.00000000
> Scale_Factor: 1.00000000
> Latitude_Of_Origin: 0.00000000
> Linear Unit: Meter (1.000000)
> ----------------------------------------------------------------------------------------------------------------------------
> mapproject(x, y, projection="", parameters=NULL, orientation=NULL)  *#only
> allows us to define the projected coordinate system
> Anybody knows how to finish it in R? Maybe rgdal() can it, but it's a liitle
> difficult for me*.
> 
> *Example of my dataset:*
> 
> ID  CLASS SOILTEM AIRTEM GHEIGHT H      *LAT     LONG*
> 1   1      19       20      50        30.61688 117.4140
> 2   1      19       21      65        30.61686 117.4140
> 3   2      20       22      55        30.61680 117.4139
> 4   3      20       26      10        30.61675 117.4139
> 5   4      20       23      75        30.61679 117.4140
> 6   1      21       21      55        30.61685 117.4141
> 
> BTW, when i load the package rgdal, the following errors appear,*where is
> the wrong*? Does it mean i need to use the R2.4.0 version?
> error in load(dataFile, ns) : ReadItem uncorrect:no class 25
> Warning message:
> package'rgdal'is build with R2.4.0
> error: package'rgdal' R's input code fail
> error: 'rgdal'package/name space load fail,
> -------------------------------package information
> ----------------------------
> R : Version 2.3.1 (2006-06-01)
> rgdal_0.5-1
> ---------------------------------------------
> 
> 

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