Back to homepage    
    Intuitive and smart cartography

 Our offer
    Products
Gallery
Achievements
Typical project
Services

 Getting started
    Paste your data
Save your project
 
 Features
    What is Géoclip?
A smooth interface
A wealth of information
Multiple themes
 Technical
 information
    From GIS to the Web
Zooming, selecting...
Database access
Display modes
Flash, SVG and so on

 Resources
    Sites and forums
Referencing sites

 Who are we?
    Our team
Partners
Customers
 


Technical information > From GIS to the Web > Converting coordinates
 

Changing the coordinate system means changing the scale and redifining the coordinates of a reference point, the geometrical centre of the map or the upper left corner of the virtual frame of the map. For example, the Midi-Pyrénées region is approximately 305km (190 miles) wide and 270km (168 miles) high. To have it fit inside a square 1,000 pixels wide, you must start from the maximum distance i.e. 305km, and multiply by 1,000/305. In the end, one pixel equals 305/1,000km, i.e. 305m (334 yards).

Let us consider, for the sake of argument, that Toulouse is at the centre of the map. In the Lambert II projection, the coordinates of Toulouse are roughly, in meters (x0c=528 400, y0c=1,844 600). In the end, they will be, in pixels (x1c=500, y1c=500).

The distances between a given point and the centre in each coordinate system are in the same ratio as the map widths: (x1-x1c)/(x0-x0c)=1,000/305. This leads to the formula for changing coordinates, for a point whose coordinates are (x0,y0) in Lambert II and (x1,y1) in the screen system.
Let e=1,000/305:
     x1 = x1c + e*(x0-x0c)

But in the screen system, the Y-axis points downwards, because the origin is in the upper left corner by convention. As a result, the formula for ordinates becomes:
     y1=y1c - e*(y0-y0c)

To convert coordinates, the following steps are required:
1) applying a cartesian projection (for example coordinates in meters, but not in degrees);
2) determining the map's rectangular footprint and whether the width or height is the longest distance;
3) calculating the scale factor;
4) applying the above formulae.

Tips for optimising the image in Flash:
Considering that a precision of one tenth of a pixel is sufficient on screen, leave only one decimal space. This will reduce the size of the coordinate file that is sent. Hunting down every kilobyte must be a constant obsession for those who want to provide comfortable content to a wide audience.

Similarly, a commonly used trick consists in describing each polygon by alternating absolute and relative coordinates.
For example, in screen coordinates, a square can be defined by the vector of its abscissae [600,610,610,600] and of its ordinates [400,410,410,400]. Replacing these by [600,10,0,-10] and [400,10,0,-10] is an improvement, since the number of characters drops by 3+3=6. The first point is described in absolute coordinates (600,400), while the others are described in relation to the first point. Smaller still, the last point, which is identical to the first one, can be dropped: [600,10,0] and [400,10,0].

 
For more information on the required calculations:
contact version française english version russian intro