Question

I am trying to calculate the height above map (ignoring topography) given a zoom level. I know the equation for scale at a specific zoom level is 591657550.5/2^(level-1) (https://gis.stackexchange.com/questions/7430/google-maps-zoom-level-ratio), but I am unsure on how to use this information (or whether or not this is the right information) to solve for height above map. Any help is appreciated.

Was it helpful?

Solution

I set my google map size to 5cm selected a zoom level, and then re-found that location with that zoom in google earth to get a eye altitude level (the D value in the angular size equation http://en.wikipedia.org/wiki/Forced_perspective). I was able to find the h value in the angular size equation by first setting my map length on screen to 5cm, and then using the scale equation of 591657550.5/2^(level-1) *5cm to calculate the h value in the angular size equation. Knowing these two variables I was able to calculate the constant angle for which google maps displayed images when maps was at a 5cm width (85.36222058). From these pieces of information I was able to construct this method which calculates eye altitude above map from zoom level with relative accuracy

public float getAltitude(float mapzoom){
    //this equation is a transformation of the angular size equation solving for D. See: http://en.wikipedia.org/wiki/Forced_perspective
    float googleearthaltitude;
    float firstPartOfEq= (float)(.05 * ((591657550.5/(Math.pow(2,(mapzoom-1))))/2));//amount displayed is .05 meters and map scale =591657550.5/(Math.pow(2,(mapzoom-1))))
    //this bit ^ essentially gets the h value in the angular size eq then divides it by 2
    googleearthaltitude =(firstPartOfEq) * ((float) (Math.cos(Math.toRadians(85.362/2)))/(float) (Math.sin(Math.toRadians(85.362/2))));//85.362 is angle which google maps displays on a 5cm wide screen
    return googleearthaltitude;
}

Sorry if my explanation is poorly explained. If you guys want to use this method feel free to. Sorry for any poorly worded sentences.

OTHER TIPS

I have basically converted Javascript code to Java. I hope this works.

public int convertRangeToZoom(double range) {
    //see: google.maps.v3.all.debug.js
    int zoom = (int) Math.round(Math.log(35200000 / range) / Math.log(2)); 
    if (zoom < 0) zoom = 0; 
    else if (zoom > 19) zoom = 19; 
    return zoom;
} 

public int convertZoomToRange(double zoom){
    //see: google.maps.v3.all.debug.js
    int range = (int) 35200000/(Math.pow(2, zoom)); 
    if (range < 300) range = 300; 
    return range; 
} 

https://groups.google.com/forum/#!msg/google-earth-browser-plugin/eSL9GlAkWBk/T4mdToJz_FgJ

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top