|Platforms:||Windows, Linux, macOS|
OsmAnd data file parser and creator
OsmAndMapCreator is a program that accompanies OsmAnd for making offline-usable data files. The most important feature is the creation of OBF files out of OSM data. Other functions allow the user to create POI, address, transit, and routing indexes from OSM files (.osm, .bz2, .pbf). OBF format is the output format and used by OsmAnd for offline rendering, routing, and search on a mobile device.
- 1 Process of Map Creation
- 2 Downloading OsmAndMapCreator
- 3 Creating Single OBF Files using the Graphical User Interface
- 4 Regular Creation of OBF Files (via Command Line)
- 5 RAM requirement
- 6 Copy OBF File(s) to mobile phone
- 7 See also
Process of Map Creation
- Download an OSM data extract (PBF format from Geofabrik for the area you want to convert to OBF. Please pay attention to the high RAM consumption of OsmAndMapCreator (see below).
- If the extract is too large, you have to clip a smaller area out of it using Osmconvert.
- Create the OBF file with OsmAndMapCreator.
- Copy the resulting OBF file to your smartphone.
OsmAndMapCreator does not need to be installed at your computer, just Java (Windows) or OpenJDK (Linux, OSX) has to be installed. You do not need administrative/root access if Java is installed already. If you do not know if Java is installed, just open a command line window and run the command java. If the output describes some arguments for starting Java and does not show a simple "file not found" (or something like this), Java is installed. More recent versions of OsmAndMapCreator need at least Java 7 to run, otherwise you will get error messages like Unsupported major.minor version 51.0. You can find out the current Java Version by calling java -version.
OsmAndMapCreator can be downloaded from developers' website. Afterwards extract the download zip-archive at any directory. If you use a Unix-like operating system (OS X, Linux) you have to make the .sh file excutable.
Creating Single OBF Files using the Graphical User Interface
Starting OsmAndMapCreator by a simple double-click is not the right way. You should assign OsmAndMapCreator more RAM than usually Java does in order that OsmAndMapCreator does not abort of lack of memory.
- Users with command line experience: Open a command line window, change directory (cd) to the directory where OsmAndMapCreator.jar is and run the command java -jar -Xms1G -Xmx6G OsmAndMapCreator.jar. The numbers following -Xms and -Xmx declare the amount of RAM you assign to OsmAndMapCreator/Java. M stands for megabyte, G for gigabyte. The amount depends on the amount of RAM your computer has and the size of the PBF file. Details see below.
- Users without command line experience: Open a file manager window (Windows Explorer, Nautilus etc.), change to the directory where OsmAndMapCreator.jar is and double-click OsmAndMapCreator.bat (Windows) / OsmAndMapCreator.sh (OS X/Linux). The bat or sh file starts OsmAndMapCreator and asserts a defined amount of memory as the command above. You should adapt the amount of memory in the bat/sh file. Details see below.
After starting OsmAndMapCreator, click on File, then on Create .obf from OSM file and select the downloaded/clipped PBF file. Wait until OsmAndMapCreator has finished. If you want to create a second OBF file, you should restart OsmAndMapCreator because OsmAndMapCreator does not free the used RAM.
Regular Creation of OBF Files (via Command Line)
If you use OBF files periodically you would like to automate this process. Even if it does not seem so, OBF files can be created via command line (and therefore via cronjobs)
On Debian-like Linux distributions you also have to install libcommons-logging-java (other distributions not tested)
- Download raw data (e.g. at Geofabrik) or update existing extracts using Osmconvert or Osmosis.
- Clip raw data if necessary.
- Rename raw data files to COUNTRY.osm.pbf and move them to /home/$user/mapbuild/osmand-pbf
- Start OsmAndMapCreator, all extracts will be converted to OBF and saved at /home/$user/mapbuild/osmand-obf
If you use other directories than those called above, you have to change them in batch.xml (see below).
Before you start OsmAndMapCreator you have to adapt the settings inside batch.xml in your OsmAndMapCreator directory.
Replace $user by your local user name.
<?xml version="1.0" encoding="utf-8"?> <batch_process> <process_attributes mapZooms="" renderingTypesFile="" zoomWaySmoothness="" osmDbDialect="sqlite" mapDbDialect="sqlite" /> <process directory_for_osm_files="/home/$user/mapbuild/osmand-pbf" directory_for_index_files="/home/$user/mapbuild/osmand-obf" directory_for_generation="/home/$user/mapbuild/osmand-gen" skipExistingIndexesAt="/home/$user/mapbuild/osmand" indexPOI="true" indexRouting="true" indexMap="true" indexTransport="true" indexAddress="true"/> </batch_process>
The XML element process_attributes describes the settings for creation of OBF files. You can just use the example batch.xml above without editing apart from adapting the paths.
If you have a large amount of RAM available, you can store the temporary SQLite databases in RAM instead at the working directory (see attribut directory_for_generation in batch.xml). Storing the temporary databases in RAM speeds up the creation of OBF files about 10–50 %. If you do not have enough RAM, you should not store the temporary databases in RAM because then the operating systems has to swap. To store the temporary databases in RAM replace
<process_attributes mapZooms="" renderingTypesFile="" zoomWaySmoothness="" osmDbDialect="sqlite" mapDbDialect="sqlite" />
<process_attributes mapZooms="" renderingTypesFile="" zoomWaySmoothness="" osmDbDialect="sqlite_in_memory" mapDbDialect="sqlite_in_memory"/>
'Warning: OsmAndMapCreator needs a very large amout of RAM. For a 230 MB PBF file you should have at least 12 GB RAM if you do not want to store the databases at HDD/SSD.
The other settings in batch.xml are:
|directory_for_osm_files||directory where downloaded/updated and clipped PBF files are|
|directory_for_index_files||directory where the final OBF files will be saved|
|directory_for_generation||directory where the temporary SQLite databases are saved|
|indexPOI||make POI index (true/false)|
|indexRouting||make routing index (true/false)|
|indexMap||make map index for rendering (true/false)|
|indexTransport||make public transport index (true/false)|
|indexAddresses||make address index for address search (true/false)|
Starting OBF creation
OsmAndMapCreator does only convert the PBF files if they are name as LAND.osm.pbf and stored at directory_for_osm_files! To start OsmAndMapCreator, change to the directory where you have unzipped OsmAndMapCreator and run the following command (adapt the memory assignment if necessary):
java -Djava.util.logging.config.file=logging.properties -Xms64M -Xmx6300M -cp "./OsmAndMapCreator.jar:lib/OsmAnd-core.jar:./lib/*.jar" net.osmand.data.index.IndexBatchCreator batch.xml
OsmAndMapCreator needs a multiple of the size of the OBF file. You should only make OBF files of large areas if your computer has enough RAM. Please remember that the operating system also needs some RAM. Just have a look at task manager in idle state. Remember that 32-Bit systems can only use 3.3 GB RAM.
The following table lists the example file size and memory consumption. Please bear in mind that OSM contains more and more data. That's why PBF files increase day by day.
Annotation: This table is not finish. You can add your values if you created an OBF file. Please only add your RAM and time consumption if you have not run any other programs with high RAM consumption at the same time. (similar test conditions)
|region||size of PBF file||RAM consumption||RAM assigned at starting OsmAndMapCreator||time consumption||output size of obf file|
|Baden-Württemberg, Germany||220 MB||ca, 3 h 15 min (Linux 64 Bit, Intel Core i5-460M, 8 GB RAM)|
|Bavaria, Germany||300 MB||aborted by user after more than 7 h (Linux 64 Bit, Intel Core i5-460M, 8 GB RAM)|
|Bielefeld||19 MB||281 MB||5,5 min (Linux 32, Intel(R) Pentium(R) 4 CPU 2.66GHz, 2 GB RAM)|
|Sachsen-Anhalt, Germany||46 MB||ca. 15–20 min (Linux 64 Bit, Intel Core i5-460M, 8 GB RAM)z|
|Germany||2.5 GB||less than 6 GB||14GB + Harddrive||~54 hours (Linux 64 Bit, Intel Core i7-4700MQ @ 2.40GHz, 16 GB RAM, mostly idle the complete time of conversion)|
|Berlin||43 MB||14 GB||~4 minutes (Linux 64 Bit, Intel Core i7-4700MQ @ 2.40GHz, 16 GB RAM, mostly idle the complete time of conversion)||98 MB|
|Lower Saxony, Germany||214 MB||less than 6 GB||14G B||~40 minutes (Linux 64 Bit, Intel Core i7-4700MQ @ 2.40GHz, 16 GB RAM, mostly idle the complete time of conversion)||414 MB|
|Munich, Germany||27 MB||~4 GB||2 GB (+ 2 GB swap)||~60 minutes (Linux 64 Bit, Intel Core 2 Duo CPU T8300 @ 2.40GHz, 2GB RAM + 2GB swap, at the begin nothing else worked due to high ram- and hdd-use)||58 MB|
|Rhineland-Platinate, Germany||157 MB||4,1 GB||1–12 GB||15 min (Win 7 64bit, AMD FX-8350 4 GHz, 16 GB RAM)|
|Brandenburg, Germany||129 MB||2,5 GB||1–4 GB||ca. 1 h, (openSUSE 13.1 64, AMD Athlon(tm) 64 X2 Dual Core Processor 4600+, 7 GB RAM|
|Baden-Württemberg, Germany||386 MB||15,2 GB (including swap)||64 MB–11,8 GB||4:41 (Linux, Intel Core i5-6400, SSD Crucial BX100 500GB (CT500BX100SSD1), 16 GB RAM), sqlite_in_memory||562 MB|
|Georgia, United States||174 MB||~5 GB (plus some swap)||512 MB–6 GB (-Xms512M -Xmx6144M)||2.5 h (Windows, Intel Core i7-3612QM @ 2.1GHz, 8 GB RAM)||265 MB|
Areas at the size of 300 MB PBF file size and more cannot be converted into OBF format at a stretch without using
sqlite_in_memory. You have to split this areas and convert each parts. That's why the OsmAnd developers do not provide whole Germany as OBF for download.
Adapt amount of assigned RAM
There is the string -Xms64M -Xmx512M in OsmAndMapCreator.bat and OsmAndMapCreator.sh file. Replace this values (64M and 512M) by values from the table above. You should leave at least 1.3 GB for the operating system if you use Windows. Under Linux this amount depends on your desktop environment, e.g. 800 MB for the RAM-hungry Unity.
|(1)||installed RAM||4 GB|
|(2)||RAM consumption in idle state (depends on operating system, see task manager)||1.3 GB|
|(3)||difference between (1) and (2)||2.7 GB|
|(4)||minimal RAM assignation (value after -Xms)||200 MB|
|(5)||maximum RAM assignation (Wert after -Xmx)||2.5 GB (Do not use a decimal separator, write -Xmx2500M instead.)|
There must not be a space between -Xms or -Xmx and the numerical value.
Copy OBF File(s) to mobile phone
The finished OBF file(s) are stored in OsmAnd's app directory on the mobile device; this may be:
The folder for OsmAnd may be changed in the General settings of Osmand. The mount point of the SD card may be different /mnt/sdcard.) Note that on Android, paths and files are case-sensitive: e.g. /mnt/extSdCard and /mnt/extsdcard are two different directories.