OSM Inspector/WxS

From OpenStreetMap Wiki
Jump to navigation Jump to search

The OSM Inspector uses WMS and WFS OGC standards internally to exchange data between the server and your web browser. If you want to use the OSM Inspector data outside the OSM Inspector web interface, you can use the same API calls to get to the data. This would allow you, for instance, to create your own OSM Inspector user interface. Or you can use the data in your own projects.

Getting rid of some duplicate nodes

WMS access

The overlays you see in the OSM Inspector are generated from a WMS server.

You can get a list of available views available via WMS from here:Getting rid of some duplicate nodes

 http://tools.geofabrik.de/osmi/view

This will return a list of views available e.g.

addresses
boundaries
geometry
...

Note that the available layers might be different from what you see in the web user interface, because the web site sometimes adds several internal layers to one visible external layer to make things easier for users. This is most often used to show one layer on higher zoom levels with more details and one layer on smaller zoom level that only show some colored dots for the areas where information is available.

You can access the WMS server in any GIS client using a WMS URL of the form:

 http://tools.geofabrik.de/osmi/view/NAME_OF_VIEW/wxs?PARAMETERS

For NAME_OF_VIEW use one of the names of a view like this:

 http://tools.geofabrik.de/osmi/view/addresses/wxs?PARAMETERS

As usual you send a GetCapabilities request to find out which layers within a view are available and how to call them, by requesting a description of the service as an XML file e.g. for the address view:

 http://tools.geofabrik.de/osmi/view/addresses/wxs?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetCapabilities

WMS access in JOSM

JOSM can also access OSMI WMS servers. JOSM doesn't have a full WMS implementation, so the use is a bit more complicated.

Go to the preference of for WMS and TMS, and "add a new WMS entry by entering the URL".

1. Enter service URL: use the following URL to get the list of OSM Inspector layers of a view:

 http://tools.geofabrik.de/osmi/view/NAME_OF_VIEW/wxs?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetCapabilities

Replace the NAME_OF_VIEW with a name of the view. In March 2014, the name must be amongst:

  • geometry
  • tagging
  • places
  • highways
  • areas
  • coastline
  • routing
  • addresses
  • boundaries
  • water
  • pubtrans_railway
  • pubtrans_mixed
  • pubtrans_network

For example, the geometry view:

 http://tools.geofabrik.de/osmi/view/geometry/wxs?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetCapabilities

Press "Get layers".

2. Select layers: choose one or several layers.

3. Select image format: in order to receive transparent layer, you should choose image/png.

The layer should now be available in the imagery menu.


Example of generated URL:

wms:http://tools.geofabrik.de/osmi/views/geometry/wxs?FORMAT=image/png&TRANSPARENT=TRUE&VERSION=1.1.1&SERVICE=WMS&REQUEST=GetMap&LAYERS=duplicate_node_in_way,single_node_in_way&STYLES=&SRS={proj}&WIDTH={width}&HEIGHT={height}&BBOX={bbox}
wms:http://tools.geofabrik.de/osmi/views/routing/wxs?FORMAT=image/png&TRANSPARENT=TRUE&VERSION=1.1.1&SERVICE=WMS&REQUEST=GetMap&LAYERS=unconnected_minor5&STYLES=&SRS={proj}&WIDTH={width}&HEIGHT={height}&BBOX={bbox}


Information icon.svg The OSM Inspector layer seems to be a lot faster in the WGS84 Geographic than in the Mercator projection method.

WMS access in Merkaartor

You can add WMS servers with Tools → WMS Servers Editor. Enter a name and the URL (replacing NAME_OF_VIEW with your desired view)

 http://tools.geofabrik.de/osmi/view/NAME_OF_VIEW/wxs?

Press the button Get Capabilities and wait a few moments. The list below the button should be filled with the available layers. Select one ore more layers you want to use and press Add. Afterwards you can add a new background layer by selecting Layers → Add new image layer. Right click on the added layer in the layer dock and select WMS adapter → The entry you created.

WFS access

With WMS you can get fully rendered maps, with WFS you can get to the raw data. All the data that you see in the OSM Inspector can be accessed through WFS requests.

The WFS URL is the same as the WMS URL:

 http://tools.geofabrik.de/osmi/view/NAME_OF_VIEW/wxs?

Say you want all the buildings with addresses in Karlsruhe. You can then use the following URL:

 http://tools.geofabrik.de/osmi/view/addresses/wxs?SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&BBOX=8.3,48.95,8.5,49.04&TYPENAME=buildings_with_addresses

This will get you the contents of the buildings_with_addresses layer in the addresses view in the GML format.

Or perhaps you want all the single nodes in a way that need fixing near central Adelaide, you might use the following URL:

http://tools.geofabrik.de/osmi/view/geometry/wxs?SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&BBOX=138.5,-35,138.6,-34.9&TYPENAME=single_node_in_way

Make sure you always use a BBOX on your WFS request, otherwise you'll get all the data in the layer and the download can take a long time!

The WFS server (www.mapserver.org) understands version 1.0.0 and 1.1.0. Coordinates must be given in EPSG:4326 (longitude/latitude). The bounding box order is specified as Western longitude, Northern latitude, Eastern longitude, and Southern latitude. Basically, the lower left corner followed by the upper right corner using lon/lat pairs.