RU:Potlatch 1/Photo-mapping

From OpenStreetMap Wiki
Jump to navigation Jump to search


Help (89606) - The Noun Project.svg

Placing film icons and showing a thumbnail on Potlatch

You can use Potlatch 1.1 for photo-mapping - where your photos are placed at their location in the editing window, so you can see street-sign locations and so on.

Existing services

  • Potlatch by default works with OpenStreetPhoto. Set into Photo KML.
  • MapPIN'on OSM provides KML for Potlatch. Set into Photo KML.

mcknut is setting up something similar.

Setting up your own service

Firstly, upload your photos to a server.

Then generate a KML file with the following structure:

  • Document
    • Placemark
      • description - the HTML to be displayed in the pop-up window
      • name
      • Icon
      • Point
        • coordinates - comma-separated lat,long

Because of limitations in flash player there can not be any newlines between the coordinates tag and the coordinates, and there must be a newline between the description tag and the CDATA section (at least if you structure the description like the example below).

Upload this to your server too. See,51.586247993078,6.3980099509113,52.911278561422 for an example.

If you have lots of photos, then you can write a script that will respond to the bbox parameters as above and output the KML.

Make sure there is a crossdomain.xml file at the root level of your server, so that Flash's security model will be happy. The easiest way is just to copy Flickr's crossdomain.xml - see .

Finally, put the full address of the KML file (but not including ?bbox=a,b,c,d - Potlatch will add this) in the Potlatch options dialogue. Then click the camera icon to load photos.

Example KML generation script

The following is a very quick and dirty script to generate KML compatible with Potlatch photo-mapping. It takes filenames as command-line parameters, assumes they are all in the current working directory, and also creates thumbnail files in the same directory by extracting thumbnail data from EXIF. Coordinates are also taken from EXIF data.


echo -e '<?xml version="1.0" encoding="UTF-8"?>\n<kml xmlns="">\n<Document>\n';

for file in $*; do
    thumbfile=`basename $file .jpg`_thumb.jpg;
    exiftool -b -ThumbnailImage $file > $thumbfile;
    echo -ne '<Placemark id="'$file'">\n<description>\n<![CDATA[<a href="'$baseurl/$file'"><img src="'$baseurl/$thumbfile'" alt="'$file'"/></a>]]>\n</description>\n<name>'$file'</name>\n<Icon>\n<href>'$baseurl/$thumbfile'</href>\n</Icon>\n<Point>\n<coordinates>';
    exiftool -SpecialInstructions $file | perl -ne 'print "$2,$1" if /Lat (\S+), Lon (\S+) /';
    echo -e '</coordinates>\n</Point>\n</Placemark>';

echo -e "\n</Document>\n</kml>"

Example KML generation script for Windows

This is nearly the same script as above with the exception that it will run in the commandline in windows 2000. It will use the files from an import directory and will extract the embedded thumbnails in an output directory. It asumes that the "exiftool.exe" is in the local path. You can redirect the output to a file to create the KML-file as used by Potlatch.

@echo off

set baseurl=http://mydomain.cno/osm

mkdir "output"
del /Q "output\*.*"

echo ^<?xml version="1.0" encoding="UTF-8"?^>
echo ^<kml xmlns=""^>
echo ^<Document^>

for %%f in ("input\*") do (
    set thumbfile=%%~nf_thumb.jpg
    "exiftool.exe" -b -ThumbnailImage "%%f" >"output\!thumbfile!"
    for /f "tokens=1" %%i in ('exiftool.exe -t -S -exif:gpslatitude -c "%%.10f" "%%f"') do set lat=%%i
    for /f "tokens=1" %%i in ('exiftool.exe -t -S -exif:gpslongitude -c "%%.10f" "%%f"') do set lon=%%i
    echo ^<Placemark id="%%~nf"^>
    echo   ^<description^>
    echo     ^<^^![CDATA[^<a href="!baseurl!/%%~nxf"^>^<img src="!baseurl!/!thumbfile!" alt="%%~nf"/^>^</a^>]]^>
    echo   ^</description^>
    echo   ^<name^>%%~nxf^</name^>
    echo   ^<Icon^>
    echo     ^<href^>!baseurl!/!thumbfile!^</href^>
    echo   ^</Icon^>
    echo   ^<Point^>
    echo     ^<coordinates^>!lon!,!lat!^</coordinates^>
    echo   ^</Point^>
    echo ^</Placemark^>

echo ^</Document^>
echo ^</kml^>