简体   繁体   中英

Changing WGS84 to EPSG:5330 in R

I would like to change my coordinate form WGS84 to EPSG:5330. Hope, anyone can help me thanks

ID,X,Y   
1,106.6874498,-6.2107887   
2,106.6883199,-6.2069667

Easy-cheesy with the sp library.

library(sp)
# Create SpatialPoints out of coordinates. 
# Assign WGS84 (EPSG 4326) coordinate reference system.
pts <- SpatialPoints(coords = data.frame(x = c(106.6874498, 106.6883199), 
                                         y = c(-6.2107887, -6.2069667)),
                     proj4string = CRS("+init=epsg:4326")) 

# Transform SpatialPoints to EPSG 5330.    
pts_epsg5330 <- spTransform(x = pts, CRSobj = CRS("+init=epsg:5330"))

Result:

# Get coordinates of new SpatialPoints.
> coordinates(pts_epsg5330)

           x        y
[1,] 3532231 213991.4
[2,] 3532328 214415.3

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM