NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

Hello everyone. I have started working with OSM maps. However, I have been struggling with one issue. Is there any way to extract the OSM map given the set of bounding box coordinates of min and max longitude and latitudes? Please let me know how I can visualize the roads, buildings, and water within these coordinates as I intend to use it as a semantic segmentation mask for my UAV imagery with the exact bounding box coordinates.

Thank you

asked 29 Nov '22, 12:52

Dawood's gravatar image

Dawood
11113
accept rate: 0%


Is there any way to extract the OSM map

if by map you mean the render on OSM.org, then you don't need to extract anythig.

if by map you mean the data, then it's probably better to download an extract of the are of interest (see https://download.geofabrik.de/), load it in a database, and then use psycopg or any other python-pg library.

permanent link

answered 29 Nov '22, 19:00

Marcos%20Dione's gravatar image

Marcos Dione
71113
accept rate: 0%

Thanks for the reply Marcos. Sorry I am new to this. I want to extract the renders only. Could you explain what do you mean by 'you don't need to extract anything'? Becuase whenever I try to download the render maps from OSM.org usinhg http link, it downloads the osm file instead which I dont require as I need the rendered maps (preferrably without symbols).

(29 Nov '22, 19:10) Dawood
1

I want to extract the renders only

and

I need the rendered maps (preferrably without symbols).

are a little bit contradictory. Let me try to explain:

You can already create web maps that use OSM's tilesas background. This is legal and requires almost no effort from your part. You can also add more data on top. You have probably already seen many of these types of maps. But that means you get the tiles as they are.

If you want to render your own maps, then the effort is quite different. Check https://switch2osm.org/serving-tiles/

(30 Nov '22, 07:15) Marcos Dione

I understand your answer. However, my requirement is a little different. I have a set of coordinates (min and max lat and long) for a bounding box e.g. east = 13.372295, west = 13.3692166. north = 52.523443, south = 52.5214641 and I want to extract the exact osm map that lies inside these geographic coordinates. However, when I try to extract the map I always receive a tile with the unnecessary area which is outside my bounding box. Please let me know if this is possible. If yes, then how?

(30 Nov '22, 11:24) Dawood
1

It's quite complex. You first have to convert your LatLon coords into tile numbers. For ZL0 it's easy, because it's always 0,0,0; for ZL1 is not that difficult, having only 4 tiles to select from. But for deeper Zoom Levels, it's a formula like (but not quite) the one in this function:

https://github.com/StyXman/osm-tile-tools/blob/master/map_utils.py#L64

So first you have to decide which ZL you want, then find the right tiles to download, then do just that. I wish I had a better code to point you to, or more time to do it myself, but with a little bit of luck you can take it from here.

(01 Dec '22, 16:36) Marcos Dione
1

I think you just need to further divide the answer by 256 to get the numbers you need.

(01 Dec '22, 17:15) Marcos Dione

https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames

But please remember, downloading a big amount of tiles is bad, and contradicts https://operations.osmfoundation.org/policies/tiles/

permanent link

answered 01 Dec '22, 19:09

yvecai's gravatar image

yvecai
1.5k1226
accept rate: 9%

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×710
×78
×22
×13
×9

question asked: 29 Nov '22, 12:52

question was seen: 2,188 times

last updated: 01 Dec '22, 19:09

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum