How IGN tile servers work?

In my previous blog article I introduced an IGN – Google Maps integration library. In this post I want to explain how IGN map server interface.

IGN ‘chops’ the world into small square tiles 256 x 256 pixel each. The size is equal to Google map tiles. Image format is JPG (Google uses PNG images).

There are 5 tile servers (as for 2011.04.11) – tsN.iberpix.ign.es, where 0 <= N <= 4. The tile URL is composed in the following manner:
http://ts|tile server index|.iberpix.ign.es/tileserver/n=|map type|;z=|UTM zone|;r=|map scale|;i=|tile x coordinate|;j=|tile y coordinate|.jpg

where:

  • tile server index – as commented before
  • map type – topo map identifiers useful for outdoor activities:
    • 1:1,000,000 – mapa_millon
    • 1:200,000 – mapa_mtn200
    • 1:50,000 – mapa_mtn50
    • 1:25,000 – mapa_mtn25
  • UTM zone – just the number, without hemishere designator and latitude band. Mainland Spain range: 29-31, Canary Islands: 27-28
  • map scale – Map scale pixels per meter multiplied by 1000. Must be a power of 2. The highest value that works (according to my checks) is 2048000 (2,048 m/px), the lowest is 1000 (1 m/px)
  • tile x-y coordinates – cartesian coordinates of a tile (in a propietary IGN coordinate system). More on this later in this article

An example of a tile: http://ts0.iberpix.ign.es/tileserver/n=mapa_millon;z=30;r=256000;i=5;j=68.jpg

How to calculate tile (cartesian) coordinates?

IGN uses UTM (Universal Transverse Mercator) coordinate system indirectly to calculate tile (x, y) references.

Flash introduction to UTM – it “flattens” the earth surface into zones (where we assume that the surface is not spherical but flat). To reference an earth point with an UTM coordinate, you need three numbers: UTM zone (reference to the grid rectangle), x and y. x gives you the distance from the central meridian of each zone (“false easting”) in meters. The zone meridian has a fixed (artificial) value of 500,000 (to avoid negative coordinates). y gives you the distance from earth’s equator (in meters too). As you see, using UTM is useful to get a grasp of distances (if point A’s UTM coordinates are (500,000, 2,000,000) and B’s (500,000, 2,001,000) they are 1000 m = 1 km away).

The IGN tile coordinate is based on the UTM coordinate of the lower left pixel and map scale (in meters per pixel). Lower left pixel of the (0, 0) IGN tile corresponds to (0, 0) UTM point. Since each tile has 256 pixels, it represents the world fragment in a scale and UTM coordinate unit is meter, (1, 1) tile’s lower left pixel corresponds to:

(1 * 256 [px] * scale [m/px], 1 * 256 [px] * scale [m/px]) UTM point.

e.g. for 128 m/px scale, (1, 1) tile’s lower left pixel UTM is (32768, 32768).

generalizing, for given a (i, j) tile and scale, lower left pixel UTM is:

(i * 256 [px] * scale [m/px], j * 256 [px] * scale [m/px])

To calculate tile IGN coordinates (given a tile scale) that cover a point with given UTM coordinates:
(floor(x / (256 [px] * scale [m/px])), floor(y / (256 [px] * scale [m/px])))

Notice that x UTM coordinates can be negative and thus tile coordinates. UTM (-1, 4000000) point (lat-lng: 36.01619ºN, 8.54615ºW) in the 30N zone is legal, although it lies outside of the zone (which spans from 6ºW to 0º). It’s supported by the IGN tile server – it can return tiles covering areas outside of an UTM zone, although with higher projection errors.

About these ads

2 thoughts on “How IGN tile servers work?

  1. Hi

    That is a very interesting article.

    I just discovered the Spanish IGN site, but I face the fact it calculates differently the map scales, zoom & coordinates, comparing to the Mobac (Mobile Atlas Creator), and so I fail to interface it.

    I try to use your inputs to recalculate the tiles number correlating to the real scale, but I fail.

    Your inputs would be very precious to achieve that.

    Thanks in advance.

    • I’m not an expert in map projections (and I didn’t work on the project since one year and a half), but I think that the web service I use uses a different projection that Mobac requires.

      If you want to visualize SIGPAC maps in Mobac, download the 1.8 version that includes the SIGPAC definition. Then export it to the newest Mobac.

Comments are closed.