11

I have been developing in Google Maps for awhile and am switching to OpenLayers but am stuck on one point: I am drawing vectors that are mostly circular but also involve some custom geometry so I can't use createRegularPolygon. I'm creating an array of points and sending it to a OpenLayers.Layer.Vector object. This works great but the resulting 'circles' are only round near the equator, not at higher latitudes. They are squashed about the same amount as the basemap is at higher latitudes, which seems to makes sense. If I use Google as a base layer then they are the correct shape at all latitudes, but I'm making an offline mobile solution so that won't do.

What do I use for a base layer (or what parameters to set) so that my geometry remains round at all latitudes without using Google or online maps?

0

3 Answers 3

15

There exists no map of the entire earth in which all (true, spherical) circles remain truly round. However, there are ways of mapping the earth in which almost all sufficiently small circles are round. These are based on conformal projections. By definition, the changes that a conformal projection makes to distances within small areas are of two types only: a uniform stretching and a rotation. Obviously these changes don't make circles less round.

August Epicycloidal

Map of the earth with an August Epicycloidal projection. Most circles will appear truly round on this map.

Commonly used conformal projections are the Mercator (a cylindrical projection), Stereographic (an azimuthal projection), and the Lambert Conformal Conic (a conic projection, obviously). These cover the three major families of projections, giving you the flexibility to choose a particular "look" to the graticule of meridians and lines of latitude. Additional options, which may be available in some GISes, include the Miller Oblated Stereographic, Littrow, Bipolar Oblique Conic Conformal, Lagrange, Eisenlohr, August Epicycloidal, Guyou, Peirce Quincuncial, GS50, various Adams projections, and Lee. (Source: Snyder & Voxland, An Album of Map Projections. USGS Professional Paper 1453.) These last two indicate the wealth of possible conformal projections that can be created and show how conformal projections are not truly "shape preserving": Adams projections conformally map a hemisphere into a square and the Lee projection places it into a triangle. In fact, the Riemann Mapping Theorem of Complex Analysis shows that you can conformally map a hemisphere into any polygon whatsoever!

OpenLayers uses the Proj4js projection library. Source code for the projections is distributed in the /proj4js/lib/projCode/ folder. The conformal projections included with the latest release (1.0.2) are the Mercator, two Transverse Mercators, two oblique Mercators ("Hotine" and "Swiss Oblique"), Lambert Conformal Conic, and Stereographic.

Unless your application is designed to work worldwide, explore and study these options to determine which would be best for your region of interest. All of these can easily be recentered and rescaled to minimize the total distortion (not just of shapes, but of areas and distances too) within a specific area. The default worldwide solution is some variant of the Mercator, popularized by Google maps.

6
  • More on this answer found here: pasda.psu.edu/help/projection.asp Commented Aug 27, 2015 at 18:35
  • @mapBaker Thank you for offering that link. Its characterization of a conformal projection unfortunately is incorrect: "A conformal projection maintains shapes such as rectangles." This is true only for infinitesimal shapes, not for shapes of finite size.
    – whuber
    Commented Aug 27, 2015 at 18:38
  • do you know anyone at PSU that could help adjust that document? Commented Aug 27, 2015 at 18:48
  • @mapBaker Unfortunately no; I don't have any current contacts there. I'm not even sure they would want to adjust it. There's a fine line between being correct and being pedantic. I believe they might have valued simplicity of exposition and--for their particular audience--did not want to get into the distinction between the preservation of geometric properties on large scales versus small scales. I value simplicity of exposition, too, but made an effort in this answer to find a more accurate compromise between simplicity and correctness by emphasizing sufficiently small circles.
    – whuber
    Commented Aug 27, 2015 at 18:53
  • 1
    @Andre UTM is a system of different projections, all of which are conformal. It uses special projections (polar stereographic) at high latitudes. Regardless, almost everywhere the mapped image of any 15 km circle ought to appear almost perfectly circular. One possible cause of visual distortion could be a display with a non-unit aspect ratio; that is, where the x scale and y scales differ: then you would see an ellipse with its axes parallel to the coordinate axes.
    – whuber
    Commented Sep 2, 2020 at 17:09
13

I guess your circles look something like this:

enter image description here

(Source: Esri mapping center blog)

You will want to use Web Mercator EPSG:900913 instead of WGS84 EPSG:4326 for perfect circles

More on this topic and an example of how the circles look like in Mercator: Tissot's indicatrix helps illustrate map projection distortion

To make openlayers use Mercator, you have to set the sphericalMercator option in your base layer.

sphericalMercator: true,
1
  • Thanks! that was exactly the info I needed. I thought I was working with a layer that was in EPSG:900913 but that wasn't the case. I also had to make sure all of the transforms were going from EPSG:4326 to EPSG:900913 and it works perfectly. Now I just have to figure out how to not have the broken image icons show when it tries to load in the map tiles while offline.
    – kschaos
    Commented Aug 9, 2011 at 16:19
2

Well, obviously you'll have problem as long as you use basemap in EPSG:4326 projection. What you need is Spherical Mercator projection which, as you noticed, Google Maps and other commercial map providers are. Go ahead and read this to get a better grasp on this problem.

For you offline mobile solution OpenStreetMap would probably be a good solution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.