Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7498293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T19:25:27+00:00 2026-05-29T19:25:27+00:00

I need to calculate the scale given a bounding box in map coordinates (EPSG:900913)

  • 0

I need to calculate the scale given a bounding box in map coordinates (EPSG:900913) and the width/height of the image.

This is becose Im implementing a very basic WMS server but in certain moments i need to know the scale of the image.

A simple request would be :

  wms.exe?LAYERS=all&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&FORMAT=image%2Fjpeg&SRS=EPSG%3A900913&BBOX=-7810029.800979,-2298920.0623849,-7809724.0528659,-2298614.3142718&WIDTH=256&HEIGHT=256

that request is originated from a openlayer component in a web page configured with this parameters :

var optionsGmap = {
projection: new OpenLayers.Projection("EPSG:900913"),
units: "m",
sphericalMercator: true,
numZoomLevels: 16,
maxExtent: new OpenLayers.Bounds(-20037508.34, -20037508.34, 20037508.34, 20037508.34),
scales : [110936068.185464,55468034.0927321,27734017.0463661,13867008.523183,6933504.26159152,
    3466752.13079576,1733376.06539788,866688.03269894,433344.01634947,216672.008174735,108336.004087367,54168.0020436837,27084.0010218419,
    13542.0005109209,6771.00025546046,3385.50012773023],
maxResolution: "auto" };

theres formula to calculate this? I have access to a postgres+posgis in the backend but I prefer to do the calculation by my self in C code.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T19:25:28+00:00Added an answer on May 29, 2026 at 7:25 pm

    The lengths of each side of an orthogonal geographical area are as follows:

    lengthEastWestNorth = (east - west) * ((equatorial_circumference * cos(north)) / (2*pi) ) ;
    lengthEastWestSouth = (east - west) * ((equatorial_circumference* cos(south)) / (2*pi)) ;
    lengthNorthSouth = (north - south) * (polar_circumference/(2*pi)) ;
    

    Note that east, west, north, south are long/lat angles in radians since that is what the trig function in C’s <math.h> require. Conversion from degrees to radians is simply r = pi/180.0. The units of the result are whatever units you use for the circumferences. The north-south sides are of equal length, the east-west dimensions differ depending on latitude, and the length of the north-south extent, hence three values not two or four.

    To calculate the scale you probably need only one of these values, I suggest the lengthNorthSouth value since it requires no trig functions and therefore no conversion to radians (divide by 360 rather than 2*pi in this case).

    The length of one side divided by the corresponding side length of the image will yield the scale.

    Geographical calculations are necessarily approximations, and the map projection may use different circumferential values for example, so you will have to determine the nearest preferred scale to determine the intended scale. Subtract the calculated scale from each of the preferred scales in turn to determine the scale with the smallest absolute (remove the sign) difference.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to scale down an image that has a height or width greater
I need to calculate the distance (in meters and miles) between two coordinates given
I need to calculate word frequencies of a given set of adjectives in a
How could I calculate the zoom level (graphics scale) to fit any image to
I need to calculate available height of an element and add it to a
I need to calculate Math.exp() from java very frequently, is it possible to get
I need to calculate averages, standard deviations, medians etc for a bunch of numerical
I need to calculate the time complexity of the following code: for (i =
I need to calculate the number of FULL month in SQL, i.e. 2009-04-16 to
I need to calculate date (year, month, day) which is (for example) 18 working

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.