Dear Barry,

all UTM zones have a width of 6° longitude, so the corresponding value in km 
is depending on the latitude. Internally, a transverse-Mercator projection is 
used for each zone. This projection is based on the mean longitude of the UTM 
zone. The coordinates of Oslo for instance in UTM are 6642682 597868. This 
means, that the distance from Oslo to equator is 6642682 m and the distance to 
the mean meridian of zone 32 is 97868 m (you have to subtract 500000 m which 
is done to avoid negative easting values...).

If you want to devide all UTM-zones into 10 x 10 km rectangles, you should do 
something like this:

library(rgdal)

dist2equat <- function(zone,y)
{
  x <- zone * 6 - 183
  coord <- SpatialPoints(cbind(x,y))
  proj4string(coord) <- CRS("+proj=longlat +ellps=WGS84 +datum=WGS84")
  coord_utm <- spTransform(coord, CRS(paste("+proj=utm +zone=",zone,
                           " +ellps=WGS84 +datum=WGS84 +units=m +no_defs 
+towgs84=0,0,0",sep="")))
  as.vector(coordinates(coord_utm)[1,2])
}

## Zone 32
zone <- 32
rectangles <- NULL
k <- 0
lat_rect <- seq.int(0,dist2equat(zone,80), 10000)
for (i_lat_rect in lat_rect)
{
  k <- k + 1
  lat <- SpatialPoints(cbind(500000, i_lat_rect))
  proj4string(lat) <- CRS(paste("+proj=utm +zone=",zone,
                                " +ellps=WGS84 +datum=WGS84 +units=m +no_defs 
+towgs84=0,0,0",sep=""))
  coord_longlat <- spTransform(lat, CRS("+proj=longlat +ellps=WGS84 
+datum=WGS84"))
  lon <- SpatialPoints(cbind(c(as.vector(coordinates(coord_longlat)[1,1])-3, 
                       as.vector(coordinates(coord_longlat)[1,1])+3), 
                       rep.int(as.vector(coordinates(coord_longlat)[1,2]),2)))
  proj4string(lon) <- CRS("+proj=longlat +ellps=WGS84 +datum=WGS84")
  lon_utm <- spTransform(lon, CRS(paste("+proj=utm +zone=",zone,
                         " +ellps=WGS84 +datum=WGS84 +units=m +no_defs 
+towgs84=0,0,0",sep="")))
  rectangles[[k]] <- seq.int(as.vector(coordinates(lon_utm)[1,1]), 
as.vector(coordinates(lon_utm)[2,1]), 10000)                         
}

pp <- NULL
j <- 0
for (i in 1:(length(lat_rect)-1))
{
  for (k in 1:(length(rectangles[[i]])-1))
  {
    j <- j + 1
    x <- c(rectangles[[i]][k],rectangles[[i]][k+1],rectangles[[i]]
[k+1],rectangles[[i]][k],rectangles[[i]][k])
    y <- c(lat_rect[i],lat_rect[i],lat_rect[i+1],lat_rect[i+1],lat_rect[i])
    p <- Polygons(list(Polygon(cbind(x,y),hole=FALSE)), j)
    pp[[j]] <- NULL
    pp[[j]] <- list(p)
  }
  print(round(i/(length(lat_rect)-1)*100,2))
}

SpP = SpatialPolygons(unlist(pp), pO=1:length(pp), CRS(paste("+proj=utm 
+zone=",zone,
          " +ellps=WGS84 +datum=WGS84 +units=m +no_defs 
+towgs84=0,0,0",sep="")))

SpPp <- SpatialPolygonsDataFrame(SpP,data.frame(ID=1:length(SpP)))

writeOGR(SpPp, "/path/to/folder", "rectangles_UTMzone32", "SpPp", driver="ESRI 
Shapefile")

Please check carefully the code before using it. I've not really prooven it...

Best regards

Lukas

Am Montag, 1. Oktober 2012, 10:11:22 schrieb Massimiliano Ruocco:
> Thanks for the answer
> Yes, should be fine for me. I don't need polar areas. So shoud be fine
> to go from -80 to 80 for lat.
> So an approximative idea to proceed could be the following:
> 
> 1) scan all the UTM zone
> 2) divide the utm zone in quad of 10kmX10km
> 
> Just a question...i am not sure i really understand the UTM coord. Is
> each zone a 500kmX500km quad?
> 
> THanks again
> 
> On 10/01/2012 10:05 AM, Barry Rowlingson wrote:
> > On Mon, Oct 1, 2012 at 8:09 AM, Massimiliano Ruocco <ruocco@idi.ntnu.no> 
wrote:
> >> Dear all,
> >> i would like to divide the world map in grid of equal dimension
> >> (example
> >> quad of 10kmx10km). Is it correct to use the UTM coord instead of
> >> lat/lon ones? Is there any drawback on doing that?
> >> 
> >> IS there any existing routine doing it?
> >> 
> >   Since we figured out that the earth isn't flat we've known its
> > 
> > impossible. You can't divide a sphere into a grid like that - what are
> > you going to do at the poles?
> > 
> >   You can project small parts to coordinates such as UTM and divide
> > 
> > into a regular square grid in those coordinates, but even those aren't
> > perfect, and get less perfect nearer the poles, at which point they
> > are completely wrong...
> > 
> > I think UTM zones typically have a max latitude they should be used
> > at, so as long as you don't care about polar bears and penguins you
> > should be okay...
> > 
> > Barry
	[[alternative HTML version deleted]]

