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

Hi again, I just downloaded spain.osm, but I don't know how include it in a openlayers map which I have...

What should I do? I'm very confused Thanks in advance.

asked 05 Jul '12, 17:24

garciasanchezdani's gravatar image

garciasanche...
55559
accept rate: 0%

edited 24 Jan '14, 14:02

aseerel4c26's gravatar image

aseerel4c26 ♦
32.6k18248554

Hi friends, thanks very much for your answers. I'd like know what data contains this .osm ... this is, what can I see with this .osm of Spain? I imagine I can see pois, for example, right? And for I've understood, this .osm has a little portion of the real database of openstreetmap...Am I right? hehe Sorry for my english. Best regards.

(06 Jul '12, 08:20) garciasanche...

Please add your comments as comments not answers. To see yourself what this .osm file contains, just open it with text editor. And if you do it, then use some smaller extract (up to some MB instead of hundreds).

(06 Jul '12, 10:36) RM87
2

The problem with .osm files is that they tend to be large, so "opening it with an editor" might not be straightforward. Users of Unix-like operating systems already have tools such as "more", "head", "tail", "grep" etc. that make extracting data from large files relatively easy, but there isn't anything built-in on Windows, although versions of many of them compiled for Windows are available here.

That said, it's often easier to deal with OSM data in a compressed format. If you have a look at Geofabrik's download page, you can see that the 5Gb spain.osm is only 292MB as a .pbf file (which is this format). The switch2osm pages suggest using .pbf files because they're smaller, and recent versions of the OSM tools and things such as mkgmap can work with them.

If you need to convert between .pbf and .osm formats, you can use osmconvert to do that.

(06 Jul '12, 12:07) SomeoneElse ♦
1

One thing to mention - I notice that on the page that you probably downloaded from it says "Last maps update: 13 December 2011". If that date's accurate, you may want to consider using a more recent extact - there's a list here. Personnally I've found Geofabrik's to be up to date and reliable, but plenty of others are available.

(06 Jul '12, 12:12) SomeoneElse ♦

You need to load the file into a database (using osm2pgsql or imposm) and then install a rendering engine that makes tiles from it for display in OpenLayers. You could use TileMill for that.

permanent link

answered 05 Jul '12, 18:51

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
82.5k927201273
accept rate: 23%

I don't understand for what I need use TileMill...? The other thing, I understood...I have a .osm file (of Spain in my case) and I need upload in a database, using osm2pgsql for example. Thanks.

(06 Jul '12, 09:31) garciasanche...

Ok, I downloaded and installed Tilemill in my computer. I'm going to start using it.

(06 Jul '12, 09:59) garciasanche...

I'd have a look at the switch2osm site, particularly the "serving tiles" sections. You've already got an OpenLayers map, so you'd then just need to add another layer to that, defining the layer something like:

var newLayer = new OpenLayers.Layer.OSM("My new map", "http://myserver/osm_tiles/${z}/${x}/${y}.png", {numZoomLevels: 19});
permanent link

answered 05 Jul '12, 20:28

SomeoneElse's gravatar image

SomeoneElse ♦
36.9k71370866
accept rate: 16%

Hi! Thanks for your answer. But I don't understand some things... - With this .osm, what I have to do? Upload it to a server mine? This file has 5 GB! - What is switch2osm? And what it serving tiles? For I understand, serving tiles offers me the possibility of make a dinamyc map serving me in each moment, the section of map where I am, right? Regards.

(06 Jul '12, 08:26) garciasanche...

Click the http://switch2osm.org/serving-tiles/ link above it explains how to set up a rendering server and database into which you could load the Spanish .osm file that you've downloaded - then you can point your Openlayers map at it.

(or does "a openlayers map which I have" in the question mean "an Openlayers map which I could set up in the future, but haven't done so yet")

(06 Jul '12, 11:04) SomeoneElse ♦

No, I've it in local, but no of spain, I have a sample map with OpenLayers

(06 Jul '12, 11:45) garciasanche...
Your answer
toggle preview

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:

×230
×122
×68

question asked: 05 Jul '12, 17:24

question was seen: 9,887 times

last updated: 24 Jan '14, 14:02

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