Home > OS >  Convert coordinate system (data vs shapefile)
Convert coordinate system (data vs shapefile)

Time:08-17

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:

  1. 51.40633 | 0.015208
  2. 51.40165 | 0.014715
  3. 51.40253 | 0.015171

The coordinates of the shapefile are as follows:

  1. 544173.0 | 184701.4
  2. 544180.2 | 184700.2
  3. 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)))
  • Related