[R-sig-Geo] LatLong to UTM zone and coordinates?

Roger Bivand Roger.Bivand at nhh.no
Mon Jan 2 10:58:47 CET 2012


On Sun, 1 Jan 2012, Albin Blaschka wrote:

> Am 2012-01-01 12:41, schrieb Albin Blaschka:
>> longitude <- 13.34
>> 
>> UTMzone <- (180 + longitude) / 6
>> UTMzone <- trunc(UTMzone)
>> 
>> UTMzone
>
> Ups, sorry, a little too quick and too dirty this was...
> This should be now the correct answer, still not considering any special 
> cases...
>
> longitude <- seq(-180,180)
> UTMzone <- (180 + longitude) / 6
> UTMzone <- trunc(UTMzone)
> UTMzone <- UTMzone + 1
> UTMzone

Thanks! This gives the zones, and for look-up, you could do:

library(maptools)
brdrs <- seq(-180, 180, 6)
longitude <- seq(-180,180)
# or your data
cbind(longitude, findInterval(longitude, brdrs, all.inside=TRUE))

looking like:

data(wrld_simpl)
plot(wrld_simpl)
abline(v=brdrs)
text(x=brdrs[-1]-3, 0, labels=1:60, col="red")

So the zone would be the output of:

findInterval(<yourLongitudes>, brdrs, all.inside=TRUE)

Roger

>
> Sorry for the noise,
> regards,
> Albin
>
>

-- 
Roger Bivand
Department of Economics, NHH Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no



More information about the R-sig-Geo mailing list