Getting Mercator crop of Iceland map (with known extremes of longitude and latitude)

  1. Go to https://planet.openstreetmap.org/ and download the latest openstreetmap .pbf file. It’s big so you will have to wait a while.

2) Download OSMConvert – we need this software to crop out our area of Europe.

3) On openstreetmap, click on EXPORT [1] below and click on ‘Manually select a different layer’ [2], this text dissapears once you select it. Then drag a box on the map showng the area you are interested in. In this example it’s Iceland.

4) Note down the Longitude and Latitude numbers in the box above. Now using OSMconvert, you can crop out the area you are interested in.

From the OSMconvert site, we are to define a rectangle as follows: “To define this limiting quasi rectangle you need to supply the coordinates of its southwestern and northeastern corners (WSEN). (Bottom Left / Top Right)”

The area I wish to crop is

Longitude min -25.049
Longitude max -12.814
Latitude min 63.192
Latitude max 66.775

Bottom left corder: West, South
Top right corner: East, North

So the bottom left corner of the area I’m interested in can be defined as (Longitude minimum) -25.049, (Latitude minimum) 63.192.

and the top right corner can be defined as (Longitude maximum) -12.814, (Latitude maximum) 66.775

Exectute the following in OSMConvert by navigation in the Command prompt to the location where the .exe file is, and execute the following command

osmconvert64-0.8.8p.exe /Users/james/Downloads/planet-191230.osm.pbf -b=-25.049,63.192,-12.814,66.775 -o=/Users/james/Downloads/planet-191230.osm.jamesicelandcrop.pbf

This will now crop the original .pbf file to the specified area – which hopefully should be Iceland

5) Once this is completed, we can verify it’s cropped the correct area by dragging the new .pbf file into QGIS. I am currently using version 3.1.

6) This is still a massive file, but in QGIS, this does now show Iceland.

The above is created when just the ‘lines’ layer is selected on the left and the projection (black arrow) is set to Mercator-pseudo EPSG:3857

We now want to reduce the file size as much as possible and just keep the outlines of Iceland, and perhaps a few large places there. To do this we need to use Osmfilter.

In order to filter the data, we need to convert the .pbf file to .o5m

This format will process faster in the filter program.

So back to the command prompt of Osmconvert first of all. Type:

osmconvert64-0.8.8p.exe /Users/james/Downloads/planet-191230.osm.jamesicelandcrop.pbf -o=/Users/james/Downloads/planet-191230.osm.jamesicelandcrop05m.o5m

This should happen quickly.

7) In Osmfilter, type

osmfilter.exe planet-191230.osm.jamesicelandcrop05m.o5m –out-key

This will list all the editable features on the map.

To list them by most occurences use:

osmfilter.exe planet-191230.osm.jamesicelandcrop05m.o5m –out-count

Attempt 1 : Delete everything apart boundaires and big cities and towns

osmfilter.exe /Users/james/Downloads/planet-191230.osm.jamesicelandcrop-Copy.o5m –keep=”place=city or ( place=town and population>=10000 )” –keep=”natural= coastline”  -o=/Users/james/Downloads/out.o5m

osmconvert64-0.8.8p.exe /Users/james/Downloads/out.o5m -o=/Users/james/Downloads/out.pbf

Attempt 2 : Delete everything apart boundaires and big cities and towns

osmfilter.exe /Users/james/Downloads/planet-191230.osm.jamesicelandcrop-Copy.o5m –keep=”admin_level=2″ –drop=”admin_level=3 =4 =5 =6″ -o=/Users/james/Downloads/out.o5m

osmconvert64-0.8.8p.exe /Users/james/Downloads/out.o5m -o=/Users/james/Downloads/out.pbf

Attempt 3 : Delete everything apart boundaires and big cities and towns

osmfilter.exe /Users/james/Downloads/planet-191230.osm.jamesicelandcrop-Copy.o5m –keep=”admin_level=2 =3 =4 =5″ –drop=”admin_level=6″ -o=/Users/james/Downloads/out.o5m

osmconvert64-0.8.8p.exe /Users/james/Downloads/out.o5m -o=/Users/james/Downloads/out.pbf

Not bad, but not perfect

Attempt 4 : Delete everything apart boundaires and big cities and towns

osmfilter.exe /Users/james/Downloads/planet-191230.osm.jamesicelandcrop-Copy.o5m –keep=”allboundary=administrative” –keep=”admin_level=2 =3 =4 =5″ -o=/Users/james/Downloads/out.o5m

osmconvert64-0.8.8p.exe /Users/james/Downloads/out.o5m -o=/Users/james/Downloads/out.pbf

More or less the same as attempt 3

Attempt 5 : Delete everything apart boundaires and big cities and towns

osmfilter.exe /Users/james/Downloads/planet-191230.osm.jamesicelandcrop-Copy.o5m –keep-nodes= –keep-ways-relations=”boundary=administrative =postal_code postal_code=” -o=/Users/james/Downloads/out.o5m

osmconvert64-0.8.8p.exe /Users/james/Downloads/out.o5m -o=/Users/james/Downloads/out.pbf

Attempt 6 : Delete everything apart boundaires and big cities and towns

osmfilter.exe /Users/james/Downloads/planet-191230.osm.jamesicelandcrop-Copy.o5m –verbose –keep=”( boundary=administrative and ( admin_level=2 or admin_level=3 or admin_level=4 or admin_level=5 ) ) or highway=motorway or highway=trunk or highway=primary or place=state” -o=/Users/james/Downloads/out.o5m

osmconvert64-0.8.8p.exe /Users/james/Downloads/out.o5m -o=/Users/james/Downloads/out.pbf

Filtering this is a big pain the the ass, I’m going to try a different method.

osmconvert64-0.8.8p.exe /Users/james/Downloads/planet-191230.osm.jamesicelandcrop.pbf –verbose -o=/Users/james/Downloads/JamesIceland.o5m

osmfilter.exe /Users/james/Downloads/JamesIceland.o5m –verbose –keep=”( boundary=administrative and ( admin_level=2 or admin_level=3 or admin_level=4 or admin_level=5 ) ) or highway=motorway or highway=trunk or highway=primary or place=state” -o=/Users/james/Downloads/JamesIcelandosm.osm

makemap.exe /largefile=yes JamesIcelandosm.osm world_base_mapIceland.ctm1

Leave a Reply