0

I exported a part of my city using OpenstreetMap, so I have a .osm file that contains at the beginning of the file:

<bounds minlat="34.8743000" minlon="-1.3494000" maxlat="34.9035000" maxlon="-1.2926000"/>

I want to know the size of my map in Km. How do I do it?

  • Use [this](https://stackoverflow.com/a/27943/2983568) to compute the x and y sides/distances in km, then multiply x by y to get the area in km2. – evilmandarine Feb 18 '22 at 15:16
  • Thank you for your response, but I did not understand well, these two functions return at the end a single value which is named d, what are these x and y that you mentioned? more detail, please. Thanks in advance. – Fleur Rouge Mar 01 '22 at 14:12
  • I should have asked you first: what do you mean by "size of my map"? Is it the area (in km2)? – evilmandarine Mar 01 '22 at 14:32
  • Yes, I would at the end a sentence like: The dimensions of the map are X km × Y km (or in km2). – Fleur Rouge Mar 01 '22 at 14:41

1 Answers1

0

I'll put this in an answer. These are the points you have as coordinates (boundaries) for your map:

                    ----------------- (max lat, max lon)
                    |               |
                    |               |
                    |               
                    |               y
                    |               
                    |               |
                    |               |
(min lat, min lon)  ------  x  ------ (min lat, max lon)

The function in the answer I referenced provides the distance between 2 points. So to compute x you need the distance between point (min lat, min lon) and point (min lat, max lon). You can compute y in a similar way.

For example point at bottom left is (lat1, lon1) and bottom right is (lat2, lon2) -> using the function you get x.

Same thread, optimized code.

Now if you just need this information once without actually programming anything, this is not so much a question for SO but you may use this link to get the numbers.

evilmandarine
  • 4,241
  • 4
  • 17
  • 40
  • Thanks for your feedback, but it's still not clear. The map I have has no shape (it is neither square nor rectangular), is your explanation valid for that too? Otherwise I have only one min lat, max lat, min lon and max lon! : – Fleur Rouge Mar 08 '22 at 16:29
  • *The map I have has no shape (it is neither square nor rectangular), is your explanation valid for that too?* Of course not. If you only have the bounding box, there is no easy way to compute the area. You may check [this](https://math.stackexchange.com/a/404476). – evilmandarine Mar 08 '22 at 17:59