Here is an updated sense of where I'm at. I decided to re-read in my data file using ReadOGR.
MyDataFile <- read.csv("reduced1.csv")
class(MyDataFile)
coordinates(MyDataFile)<-~X+Y
class(MyDataFile)
writeOGR(MyDataFile, "Folder", "File", driver = "ESRI Shapefile")
proj4string(MyDataFile)
Checking the CRS at this point gives me 'NA' so I try and assign it
Redefined <- readOGR(dsn="Folder", layer = "File")
proj4string(Redefined) <- CRS("+init=epsg:4326") # WGS 84
[1] "+init=epsg:4326 +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"
Now for reading in my boundaries file:
Map <-readOGR(".","infuse_dist_lyr_2011")
proj4string(Map)
[1] "+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +datum=OSGB36 +units=m +no_defs +ellps=airy +towgs84=446.448,-125.157,542.060,0.1502,0.2470,0.8421,-20.4894"
So now to transform.
NewMap <- spTransform(Map, proj4string(Redefined))
CRS
function doesn't apply to sp-class objects, its applied to strings to create CRS objects. Useproj4string(map)
orraster::projection(map)
to get the projection string of an sp-class object. That's where your warning comes from.CRS(map)
really give an error aboutCRS(h)
? We care about precision here...readOGR
orraster::shapefile
it should pick up the projection from the .prj file. In your rewrite, show the output ofsummary
on your spatial objects.