OSM in Google Earth
For viewing OSM data in Google Earth, you can either use existing KML network links or create your own KML files for a specific purpose from .osm files.
Important legal note
Do not use data from Google Earth to add or change anything in OpenStreetMap, ie. don't look at a satellite image from Google and add or change streets or other things. Somebody has a copyright on the data shown in Google Earth and using any data from it will compromise the OSM database. See the Legal FAQ for more information.
Dynamic KML network links
Google Earth Map Overlays
http://ge-map-overlays.appspot.com/ is a Python script running on the Google App Engine that dynamically computes tile coordinates for the current view in Google Earth.
At http://ge-map-overlays.appspot.com/openstreetmap you can download a KML network link that displays OpenStreetMap tiles on top of the Google Earth layers. You can choose between Mapnik, OpenCycleMap, Hike & Bike Map, OpenPisteMap and Osmarender tile sets. The server script computes the resolution of the tiles depending on latitude and distance to the virtual camera, so that the number of tiles loaded by Google Earth is more or less constant independent of the view. In the side bar, you can adjust the opacity of the tiles with the slider on the bottom.
The website requires (free) registration for resource balancing and exclusion of malicious use.
The website http://www.mgmaps.com/kml/ offers similar capacities with various rendering including four from OSM (Mapnik, Osmarender, OpenAerialMap and Cyclemap) and a transparency slider.
Mapnik Tiles in Google Earth
Similarly, the network link at OpenStreetMapLayer.kmz dynamically displays Mapnik tiles in Google Earth. It shows a fixed grid of tiles in the center of the screen (so tilting does not work so well), but it does not require registration.
Google Earth Overlay Server
The Google Earth Overlay Server (GEOS) is a public web service to dynamically load maps in Google Earth. The underlying python software is freely available from github and can easily be ran locally with full flexibility and custom maps.
Query to map
Look at Query-to-map to select small parts or single objects of OSM and show them as KML also in Google Earth.
Creating KML image overlays
Using OSMLib
OSMLib can export kml files. Install the gems osmlib-base and osmlib-export (see below). The latter includes an executable osmexport. Using the included example rule file, kml-complex.oxr, you can generate a kml file using a command line like
osmexport /path/to/kml-complex.oxr data.osm data.kml
You need to have ruby and RubyGems installed (executables ruby and gem). Then installing a functional osmexport should be as simple as
gem install libxml-ruby builder GeoRuby gem install osmlib-base osmlib-export
Using Maperitive
Maperitive can export the map into a bitmap which comes together with the KML file. You can export the bitmap in two ways:
- By clicking on the Export To Bitmap menu item.
- By using the export-bitmap command (see http://maperitive.net/docs/manual/Commands/ExportBitmap.html).