Some ideas that can help you:
- Web tile has a certain resolution (PPI, pixels per inch). You probably want to avoid displaying the tile as a texture that looses a lot of PPI. So a tile that is 256x256 probably wouldn't look too good shown as a 1024x1024 texture.
- Each OSM zoom level has its own (approximate) map scale.
- Since you say you'll show a flat Earth, you can still calculate the current map scale based on the distance of the observer from the Earth, the latitude the observer is on and the size of the screen.
Once you have the current map scale, you can calculate the zoom level (code taken from my project Maperitive):
public static float MapScaleToOsmZoomLevel(float mapScale, float latitude, float ppi)
{
const float MetersPerInch = 2.54f / 100;
const double EarthCircumference = EarthRadius * Math.PI * 2;
double realLengthInMeters = EarthCircumference * Math.Cos (Deg2Rad (latitude));
double zoomLevelExp = (realLengthInMeters*ppi) / (256*MetersPerInch*mapScale);
return (float) Math.Log(zoomLevelExp, 2);
}
Now you have a zoom level as a real value and you can calculate the actual zoom level based on a "quality" setting - for example if you want a higher quality, you can use something like Math.Ceiling(zoom)
.
For the Mercator projection, the extent can not reach North and South pole for mathematical reasons.
The standard Google and Openstreetmap mercator projection is limited to 85.011° North and South to get a square map.
See http://wiki.openstreetmap.org/wiki/Slippy_map_tilenames#X_and_Y for explanation.
Using EPSG:3857, the extent of a map is -20037508,-20037508,20037508,20037508
in CRS units. Using degree coordinates at this point make little sense.
You have to change your GCP to reflect the proper extent coordinates.
EDIT 1
Adding the GCPs does not change the corner coordinates. Instead apply the correct bounds to the file with -a_ullr
. This way it works:
gdal_translate -a_srs EPSG:3857 -a_ullr -20037508 20037508 20037508 -20037508 Mercator.tif MercatorULLR-CRS.tif
gdalwarp -s_srs EPSG:3857 -t_srs EPSG:4326 MercatorULLR-CRS.tif Equirectangular.tif
And the result looks like this:
Note that I have chosen EPSG:4326 as output. Really a geographic CRS, but displayes the same way a equirectangular projection would. The blue marble background exceeds the part between 85.011° and 90°.
EDIT 2
GDAL also works with GCP, but that requires a further step:
- Apply the GCP
- Transform the picture using the GCP to World Mercator
- Reproject from World Mercator to your desired CRS
To apply the GCP correctly, you have to know the local coordinate systems used for native tif and your CRS. The tif has the origin in the upper left corner, X to the right, and Y to the bottom. The World Mercator has the origin at 0°E/0°N, X to the East, and Y to the North.
So the command lines are:
gdal_translate -gcp 0.0 0.0 -20037508 20037508 -gcp 1000.0 0.0 20037508 20037508 -gcp 1000.0 1000.0 20037508 -20037508 -gcp 0.0 1000.0 -20037508 -20037508 Mercator.tif MercatorGCP.tif
gdalwarp -r bilinear -t_srs EPSG:3857 MercatorGCP.tif MercatorCRS.tif
gdalwarp -t_srs EPSG:4326 MercatorCRS.tif Equirectangular.tif
Best Answer
Projections are like pushing string. As you try to preserve one aspect, you get distortions in some other parameter (e.g. distance or bearing). To preserve both shape and area you may need to consider an interrupted projection like Goodes Homolosine or the off-beat Buckminster-Fuller 'Dymaxion' projection. In these projections, the distortions are present but minimised because the interruptions effectively 'reset' the projection. However, you lose sensible bearings and distances with these projections so they would be useless for navigation.
Because you mention Australia and Greenland in the same breath, the presumption in your question is that you want a global projection. Local projections are best for locally preserving area and shape simultaneously of course... and there are a tediously huge number of these!
Just to be pedantic, a globe probably is a projection because globes tend to be perfectly spherical unlike the Earth... but that's getting into the realms of arguing about how many fairies could dance on the head of a pin :)