[R-sig-Geo] Converting longitude and latitude to UK OS references

Rob Robinson rob@rob|n@on @end|ng |rom bto@org
Sun Oct 23 11:43:25 CEST 2022


Ummm... If you reverse lon, lat in your colnames() you might be a bit
closer?
Cheers
Rob

*************** Learn about Britain's Birds at www.bto.org/birdfacts
  ******************

Dr Rob Robinson, Associate Director - Research (he/him)
Hon Reader: Univ East Anglia | Visiting Researcher: Swiss Ornithological
Institute
British Trust for Ornithology, The Nunnery, Thetford, Norfolk, IP24 2PU
Ph: +44 (0)1842 750050       T: @btorobrob
E: rob.robinson using bto.org      W: www.bto.org/about-bto/our-staff/rob-robinson

======== "How can anyone be enlightened, when truth is so poorly lit"
========


On Sun, 23 Oct 2022 at 10:09, Nick Wray <nickmwray using gmail.com> wrote:

> I am trying to convert longitude and latitude values for UK weather
> stations to UK Ordnance Survey National Grid References.  There are sites
> where one can do them one at a time but I have a large number.  I have
> found some code which does the conversion and include the first three
> points which I want to convert as an example
>
> library(sp)
>
> xy<-as.data.frame(cbind(c(55.8533,55.8551,55.8473),c(-2.38588,-2.39620,-2.11304)))
> colnames(xy)<-c("lon","lat")
> xy
> coordinates(xy)<-~lon+lat
> ## see site in jounral convert llon lat
> proj4string(xy)<-CRS("+init=epsg:4326")
> ptsOS<-spTransform(xy,CRS("+init=epsg:27700"))
> ptsOS
>
> but it doesn't give the right answers - the output doesn't correspond to
> either what I get whn I put an individual point into a conversion site nor
> with other points in the same region which I have got from other sources
> and are mutually compatible
>
> Can anyone explain where I'm going wrong and how I can fix this?  Thanks
> Nick Wray
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo using r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list