My data and shapefile (both for the same city) both have geospatial coordinates, but in different coordinate reference systems.
The coordinates in the data are as follows:
- 51.40633 | 0.015208
- 51.40165 | 0.014715
- 51.40253 | 0.015171
The coordinates of the shapefile are as follows:
- 544173.0 | 184701.4
- 544180.2 | 184700.2
- 544180.3 | 184700.6
I would like to convert the coordinate system in the data to match the coordinate system used in the shapefile. Thank you!
################## update:
pts <- cbind(epcp1$longitude,epcp1$latitude) #coordinates of homes based on postcode
#transform coordinates to same as shapefile (area level coordinates) pts = SpatialPoints(pts, proj4string = CRS(proj4string(shapefile)))
CodePudding user response:
looks like you can use spTransform
from sp
. But you need to make the first SpatialPoints object with its native CRS:
pts <- cbind(epcp1$longitude,epcp1$latitude)
# assuming WGS84...
pts = SpatialPoints(pts, proj4string = CRS(" init=epsg:4326"))
pts_reproj <- spTransform(pts, CRSobj = CRS(proj4string(shapefile)))