Hello! I am trying to find a method to find bbox bounds (left, right, top, bottom) from given zoom level and coordinates. I am writing a function in MATLAB that uses zoom and coordinates as parameters to go to openstreetmap.org and export the OSM just as openstreetmap does so that I can easily save several different OSM files and open them as xml files from within MATLAB, moving towards the next goal of recreating maps from the OSM files. asked 18 Dec '18, 22:50 jholland4134
showing 5 of 9
show 4 more comments
|
I do not understand your question, sorry. Why should a zoom level affect coordinates at all? Please give some more detail. By chance: do you mean the edge coordinates of a view area?
My apologies, I meant how does the zoom level effect the bound box's coordinates/min and max latitude and longitude.
For example, if I select latitude of 28.06597 and longitude of -82.52889 with a zoom level of 19, top=28.06582, bottom=28.06612, left=-82.52937, and right=-82.52841. I'm trying to figure out how to calculate these bounds. Link I'm referring to: https://www.openstreetmap.org/export#map=19/28.06597/-82.52889
So basically you wan to know how the website calculates these four values based on your centre coordinates from the URL ("28.06597/-82.52889") and the currently displayed map size? While someone could surely answer that (probably with a deep reference to the OSM website code), I fail to see why this is useful - except if you want to program such a website. So, is this what you want?
The bounds of the map on the website don't just depend on the zoom level and center coordinate.T he size of the map div inside the browser window also matters, i.e. the screen resolution and a few things more. But maybe you are actually searching for something different. Did you already read slippy map tilenames? It contains a collection of formulas and explanations.
aseerel4c26, that is correct but what I am trying to do is to write a function for MATLAB to retrieve the OSM from openstreetmap.org by providing zoom and coordinates as parameters. Right now, the code works but how I was handling zoom's effect on the bbox is not the same as open street map, leading to a smaller bbox and OSM files that differ from open street's exported OSM files.
scai, I have not yet but will take a look. Thank you for the link.
After looking over the link to the slippy tilenames, I noticed the Perl LonLat_to_bbox program seems to be what I'm looking for. The only issue to sort out is that the code is meant for embedding a map and uses the desired width and height as part finding the corresponding OSM.
@jholland4134: Yes, Perl LonLat_to_bbox seems to be what you want, but I do not understand your problem to use this code. As also said in my first comment: you need to provide more detail. E.g. which framework do you use in Matlab? What are you displaying there?
It would be nice if you could add this to your original question text ("edit") - that makes this question entry easier to read for others coming by with the same question later on.
@jholland4134: By the way, the https://www.openstreetmap.org/export function of osm.org is meant for small scale exports only. No big ones, no heavy use, and is - as the website in general - targeted at mappers. There are other options - see https://wiki.openstreetmap.org/wiki/Downloading_data . As long as you are just in development phase that use of /export is perfectly fine!
@aseerel4c26 Thank you for the suggestion, I updated the question with some more detail. I simply want to use MATLAB to export the OSM file and then open it within MATLAB as an XML. The purpose is to use coordinates for several locations from another file as function parameters to go to openstreetmap and export the corresponding OSM files.