Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Please excuse what is probably an obvious question from a relative newB to GIS -- this seems like it should be a snap.

I've been developing in Gmaps 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.

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

share|improve this question

migrated from stackoverflow.com Aug 9 '11 at 8:32

This question came from our site for professional and enthusiast programmers.

3 Answers 3

up vote 10 down vote accepted

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,
share|improve this answer
    
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 Aug 9 '11 at 16:19

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.

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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