Import / convert raster map (tiff/tfw)

5,092 views
Skip to first unread message

andres pfeifer

unread,
Oct 18, 2012, 5:26:59 AM10/18/12
to osm...@googlegroups.com
Is there a way to import raster Maps to Osmand ?
The format is tiff / tfw 
Is it possible to convert to osmand sqlite or osmand tile storage ?
Is "osmand sqlite" the same sqlite than - for example - sqlite in global mapper ??

Please tell me which software works !

DaveP

unread,
Oct 18, 2012, 5:32:08 AM10/18/12
to osm...@googlegroups.com
Hi Andres,
  I am interested to know about this also. I also have georeferenced tif files (.tif and .tfw), and I would like to view them as an overlay in osmand. I have searched the wiki etc and can't quite figure it out.

 regards, Dave

yvecai

unread,
Oct 18, 2012, 10:37:42 AM10/18/12
to osm...@googlegroups.com
One way to it is to create mercator tiles with gdal (gdal2tiles.py), then create the sqlite with Mobac.

regards, Yves

andres pfeifer

unread,
Oct 18, 2012, 12:55:37 PM10/18/12
to osm...@googlegroups.com
I use mobac only to download. is there at tutorial how to convert with mobac ?

Victor Shcherb

unread,
Oct 18, 2012, 1:38:51 PM10/18/12
to osm...@googlegroups.com
As I see http://mobac.sourceforge.net/ supports convertion to OsmAnd (so must be an option in Mobac).

Victor

2012/10/18 andres pfeifer <luisa...@googlemail.com>

David Pont

unread,
Oct 19, 2012, 5:53:18 AM10/19/12
to osm...@googlegroups.com
thanks for the suggestions,
 
I had a quick look at mobac, it seems to support online map sources, so I do not understand how to make it read 'Mercator tiles', and I have not even looked at details of how to create mercator tiles from tif / tfw with gdal yet.
 
It sounds like this can be done, but some more guidance on details to make it happen would be good.
 
I still hope someone has a more simple procedure?
 
I do have ArcGIS, perhaps this can take care of creating tiles? then convert to sqlite format??
 
  regards, Dave

andre van atten

unread,
Oct 19, 2012, 7:06:43 AM10/19/12
to osm...@googlegroups.com

Hi,

Take a look at GlobalMapper free version, it creates tiles for Osm format or Google format from menu option. Those are two different tiling schemas.
When you have the tiles you can create sqlite package with Mobac or OsmandMapCreator. You have to put the folders and subfolders with tiles in place, and configure to use this 'preloaded' tiles.
You have to find out some howto things yourself, or search the OsmAnd group or Mobac sources.  If you are a GIS user this should be a piece of cake :-)

Andre

Op 19 okt. 2012 11:53 schreef "David Pont" <dave...@gmail.com> het volgende:

S.by

unread,
Oct 19, 2012, 4:56:42 PM10/19/12
to osm...@googlegroups.com
I have created the sqlitedb in "andre.oid" method .

The sqlitedb doesn't show in OsmAnd .

After creating jpg tiles by  "export web" in GlobalMapper  i can see in a pc browser my map in transparency on google map.

Then i copied those folders to to OsmAndMapCreator instead of a source ... say "google maps" ...

Now i have to convert all the tiles from extension jpg to jpg.tile . (still haven't found a good program to batch convert) And convert  the folders names

to only numbers  instead of number+letter so it fits to OsmAndMapCreator method. 

Then when the goggle maps source  is selected i press "create sqlitedb" . 

Before that i erased the .metainfo file (if not erased it gives me an error).   

The sqlitedb is created .... and it seems o.k because it's not a small file and OsmAndMapCreator did took some time to create .

But the sqlitedb file is not o.k in OsmAnd ...it simply doesn't show anything . 


andres pfeifer

unread,
Oct 20, 2012, 2:01:31 AM10/20/12
to osm...@googlegroups.com
S.by  :
I dont know much about sqlite so there is a question :

"andre.oid" - Method ? whats that ? Its directly related to Osmand ?
If not maybe its not compatible ?
I have SQLite files for RMaps. Unfortunatly they are crashing osmand after some time. )))-:
Even if they are realy small.

Is there only one SQLite or several ?
Mobile atlas Creator is able to create about 6 diffrent ones. (RMaps, Osmand, Big Planet, MBtiles, Orux Maps, Osmdroid
Global Mapper 14 is also abel to create a SQLite .
Are they all the same ?

Many Questions ...



S.by

unread,
Oct 20, 2012, 5:43:09 AM10/20/12
to osm...@googlegroups.com
"andres pfeifer " I am not the "expert" here ...

And i am trying to get answers myself since i have  little experience .

One thing i know ... sqlitedb  file extension for OsmAnd fits only OsmAnd.

There are other apps/programs that use the same extension name but they dosn't work with OsmAnd.

OsmAndMapCreator can create sqlitedb file For OsmAnd only.

Beside that in MOBAC there is an option to create sqlitedb for OsmAnd .

I know there are other options in MOBAC to create other sqlitedb for other apps/programs ... but as i said before they don't work with OsmAnd. 

So, now i am going to try with GlobalMapper + mobac , but i doubt if it will work. 




S.by

unread,
Oct 20, 2012, 7:26:10 AM10/20/12
to osm...@googlegroups.com
O.k 

Good news ...

I succeeded with GlobalMapper + OsmAndMapCreator ...

So my map was jpg .... just a plain jpg file that i aligned with GlobalMapper .

Then i inserted all the folders to OsmAndMapCreator instead of a source "google maps" after i zoomed into the only level i am creating .

So, my previous error was that the numbering method on the  "GlobalMapper" folders and files doesn't fit the OsmAndMapCreator foldering and files numbering method .

Putting regular OsmAndMapCreator tiles with the GlobalMapper tiles together are just for making the GlobalMapper tiles numbering o.k . then when it fits the numbering system ... i removed the google map tile and create the sqlitedb 

I still got somthing wrong beacuse the tiles are not in the correct order by i am i almost there .   

It shows in OsmAnd ... that's what's important  .  

andres pfeifer

unread,
Oct 20, 2012, 10:50:51 AM10/20/12
to osm...@googlegroups.com
Thank you very much for sharing your way of creating !
I will give your way a try. As I understand now sqlib is only a db and you can put in it what you want...

S.by

unread,
Oct 20, 2012, 11:47:56 AM10/20/12
to osm...@googlegroups.com
I used bing maps (on chrome) to get the lon lat for map alignment . ( right click on point ) 

first number in bing maps is the second number (y) in GlobalMapper .

About the tiles puzzle ... It appears that global mapper starts with the upper right tile and continuous to the right. 
                                     
                                   And  OsmAndMapCreator starts from the lower right tile and continuous to the left  .

Still didnt make it ... but soon i hope .

yvecai

unread,
Oct 20, 2012, 12:47:07 PM10/20/12
to osm...@googlegroups.com
You are playing with three tile numbering:
TMS : Tile Map service
   Tile 0,0 is on the lower left
   X,Y,Z
OSM, Google, Bing, ... (see https://developers.google.com/maps/documentation/javascript/v2/overlays#Google_Maps_Coordinates)
   Tile 0,0 is on upper-left
    x=X, y=2^Z-y, z=Z
Osmand sqlite, BigPlanet sqlites:
    x=X, y=2^z-y, z=17-Z

Tiles are normally saved on disk in the following directory structure: z/x/y.png

This one is useful to check your numbers: http://www.maptiler.org/google-maps-coordinates-tile-bounds-projection/

Here is how to use custom tile sources in MOBAC (including tiles on disk):
http://sourceforge.net/apps/mediawiki/mobac/index.php?title=Custom_XML_Map_Sources

Yves

yvecai

unread,
Oct 20, 2012, 12:53:11 PM10/20/12
to osm...@googlegroups.com
I should add that if you use gdal2tiles (http://www.gdal.org/gdal2tiles.html), the result would be TMS Z/Y/X.png.


S.by

unread,
Oct 20, 2012, 1:09:07 PM10/20/12
to osm...@googlegroups.com
Thanks for answering yvecai .

Where do i download "gdal2tiles"   ? ...since converting from one tile system to the other seems very hard . 

S.by

unread,
Oct 20, 2012, 6:21:37 PM10/20/12
to osm...@googlegroups.com
I made it with  global mapper + OsmAndMapCreator .

The tiles are not stored on the computer as you suggested "yvecai " .

It would be helpful if someone would tell how to use "gdal2tiles" ... since this was a small map and still it was very difficult .

Where to download it ? Does it have a gui ?  (It's site is very unclear and so the file i was trying to download "osgeo" ) 

For the plugins developers ... it would be very useful ... taking a jpg (from camera or from storage) and aligning it and converting it to sqlitedb .  

S.by

unread,
Oct 21, 2012, 5:21:45 AM10/21/12
to osm...@googlegroups.com
 yvecai , there is a tms option in global mapper .

Beside that that you can't see a preview of your map in a browser...

The tiles are not stored on the computer as they should be for OsmAndMapCreator...

And the numbers of the tiles and folders are also wrong .

For anyone doing it manually like i did : Folders numbers are movement to horizontal (bigger numbers movement to the right)  and files (tiles) numbers are movement up and down (bigger numbers movement down) . 

S.by

unread,
Oct 21, 2012, 5:57:05 AM10/21/12
to osm...@googlegroups.com
After checking it again ...

It's better to select "TMS" in global mapper ... then the tiles ( order ) are stored correctly on the computer ... but the tiles numbers are still needs to be changed according to OsmAndMapCreator.

yvecai

unread,
Oct 21, 2012, 10:53:41 AM10/21/12
to osm...@googlegroups.com
Gdal documentation can be found at http://www.gdal.org ...
It's a library along with various programming language bindings and useful pre-compiled utilities, like gdal2tiles.
It's command-line, for a gdal2tiles GUI check http://www.maptiler.org/, never tried.

S.by

unread,
Oct 21, 2012, 11:37:51 AM10/21/12
to osm...@googlegroups.com
The gui version at  http://www.maptiler.org/        .......

Is not good , it's in beta and it's not functioning correctly . 

With global mapper and OsmMapCreator The only missing software for me now , is a good batch file name and extension changer. 




DaveP

unread,
Jan 23, 2013, 5:37:12 PM1/23/13
to osm...@googlegroups.com
I have been trying again, playing with MapTiler, OsmandMapCreator, mobac...
I downloaded MapTiler 2 days ago, I have found it to be excellent and finally managed to create a set of png tiles from my tif/tfw. MapTiler has the option to display the results as an overlay on online map sources (Microsoft etc) so I could check and see my generated tiles were perfectly georeferenced.
It created a set of folders starting with zoom levels (10 to 20), then below that folders named as 4 digit numbers (eg 16225), then inside that files named eg 6280.png. I added .tile by batch renaming to get eg 6280.png.tile because this is what Osmand seems to expect.
I copied the folder structure to my Android sd card, the root folder shows up in the list of map sources and overlay maps. But if I select it (as map source or overlay) I see nothing :-( The MapTiler folder naming convention looks like the same as Osmand, but perhaps it is wrong?
 
Next I tried using mobac to read the MapTiler tiles but am having trouble figuring out how to setup mobac parameters correctly. I was thinking mobac could be used to convert the tiles to Osmand sqlite which would get around tile naming issues, and save space.
 
Any suggestions on how to configure mobac would be appreciated. I think I have it reading the tiles as the Map source, but the other parameters are confusing me. Time to RTFM I guess.
 
I will post back if I ever get to a solution.
 
  regards, Dave

S.by

unread,
Jan 24, 2013, 9:46:07 AM1/24/13
to osm...@googlegroups.com
Hi DaveP  , 

You say you created i set of png tiles with MapTiler . I didn't succeed creating anything with it , It just never finishes .

Please specify which steps did complete in order to do that . (Write me the exact steps and how much time did it took ) 


Also you say you didn't convert the tiles to sqlitedb with OsmAndMapCreator. 

If you begin doing this by inserting those tiles to an existing OsmAndMapCreator folder source (It doesnt matter which) , then delete the .metainfo file .

Then when you launch the OsmAndMapCreator on this source you see a message that this is not an online souce (or somthing similar)  .

In this stage you are suppose to see your offline source tiles .( In fact you don't have to delete the .metainfo file ... this was just to show you it reads from the disk ).

Try to do this first by switching tiles from different sources to see that it realy works and then try to do it with the problematic tiles . You will have the chance to see the exact tiles folder configuration in the first try 

... So by doing this you don't have to deal with OsmAnd on the phone... you can try it in the convenience of your pc with OsmAndMapCreator. 


pere...@gmail.com

unread,
Jan 26, 2013, 7:12:29 AM1/26/13
to osm...@googlegroups.com


El dimecres 23 de gener de 2013 23:37:12 UTC+1, DaveP va escriure:
I have been trying again, playing with MapTiler, OsmandMapCreator, mobac...
I downloaded MapTiler 2 days ago, I have found it to be excellent and finally managed to create a set of png tiles from my tif/tfw. MapTiler has the option to display the results as an overlay on online map sources (Microsoft etc) so I could check and see my generated tiles were perfectly georeferenced.
It created a set of folders starting with zoom levels (10 to 20), then below that folders named as 4 digit numbers (eg 16225), then inside that files named eg 6280.png. I added .tile by batch renaming to get eg 6280.png.tile because this is what Osmand seems to expect.

You may find the attached script usefull, I use it to rename/rearrange the names of the tiles created with gdal2tiles.py, still not tried to create binary file from the tiles, but they display right in osmand
Hope this helps
renametiles.sh

yvecai

unread,
Jan 26, 2013, 7:43:41 AM1/26/13
to osm...@googlegroups.com
Thing is, transfering tiles like this is a lot of files! You may encounter issues when dealing with a big amount.

One way is to build a sqlite from these tiles with Mobac, here is an example datasource xml file for Mobac:
http://sourceforge.net/apps/mediawiki/mobac/index.php?title=Custom_XML_Map_Sources#Local_Tile_files

Pere Pujal i Carabantes

unread,
Jan 26, 2013, 10:29:44 AM1/26/13
to osm...@googlegroups.com
El ds 26 de 01 de 2013 a les 04:43 -0800, en/na yvecai va escriure:
> Thing is, transfering tiles like this is a lot of files! You may
> encounter issues when dealing with a big amount.
>
> One way is to build a sqlite from these tiles with Mobac, here is an
> example datasource xml file for Mobac:
> http://sourceforge.net/apps/mediawiki/mobac/index.php?title=Custom_XML_Map_Sources#Local_Tile_files

creating the sqlite file with OsmandMapCreator works fine too, what the
script mainly does is invert the index of the files on the deepest
directory, what I haven't managed to do with gdal2tiles.py, so instead
of start numbering at N they start numbering at S(or the inverse, I
don't remember exactly) maybe I missed something with gdal2tiles.py, but
now I am able to use very detailed maps and ortophotos with Osmand

BTW, Thanks for this great software :)
Pere

DaveP

unread,
Feb 1, 2013, 5:15:19 AM2/1/13
to osm...@googlegroups.com
Hi S.by
  I finally got a tif into Osmand. I used MapTiler and MOBAC. I only had a quick attempt using OsmandMapCreator instead of MOBAC, maybe I can try this next.
 
For the record, here are the steps, using MapTiler for the first part, then MOBAC for the second part:
 
Step 1 -------------------------------------------------
 
MapTiler 1.0 beta2
 
Tile Profile:
Google Maps compatible (Spherical Mercator)
Continue
 
Source Data Files:
Add: (single tif file with tfw, got Georeference extent from ArcGIS - must be another way, calculate from tfw and image size?)
Georeference:
5713036.25 5712401.75 1906003.25 1905591.75
Continue
 
Spatial Reference: found correct code using the link on this page to EPSG Registry
Specify the id-number from the EPSG/ESRI database
2193
Set
(Used Preview to confirm projection)
Continue
 
Tile Details:
Zoom levels to generate:
Checked and suggested zoom levels (15 to 17) seemed consistent with the 0.5m pixels in my tif.
Please choose a file format:
PNG - with transparency (no other options available?)
Continue
 
Destination:
Where to save the generated tiles?:
Result directory:
Accepted default
Continue
 
Viewers:
Google Maps and OpenLayers selected
Continue
 
Viewer Details
Title of the map
Accepted default (input file name) but removed .tif extension
The API keys for online maps API viewers:
Google Maps API key: (used link provided on this page to get Google API key)
AIzyZaB3ZqtgMA_z27tYCiYxTv4OE......................
Continue
 
Rendering:
Rendering progress:
Took less than 1 minute, but my extent is very small
Increased max zoom to 19
Took about a minute
Increased max zoom to 21
Rendering the base tiles took much longer (7mins) 
Rendering the overview tiles in the pyramid also took longer (4mins), 11 mins total 

The tilemapresource.xml output by MapTiler tells me:
TileSet href="21" units-per-pixel="0.07464553542137
which indicates 0.7m per pixel? at max zoom 21, so I could go one more zoom level Max zoom 22 ?
Step 2 -------------------------------------------
From MOBAC online help:
MOBAC Local Tile files
Existing atlases or locally rendered tiles can be directly integrated into MOBAC as custom map source without having to set-up a
local web-server.
 Note At the moment the formats used by OSMTracker, AndNav, BackCountry Navigator, Maverick and OSMAND are supported.
<?xml version="1.0" encoding="UTF-8"?>
<localTileFiles>
   <name>MyTIF</name>
   <sourceType>DIR_ZOOM_X_Y</sourceType>
   <sourceFolder>D:\FolderContainingMapTilerTiles</sourceFolder>
   <invertYCoordinate>true</invertYCoordinate> <!-- optional -->
   <backgroundColor>#000000</backgroundColor>
</localTileFiles>
 
adapt the <sourceFolder> entry and place it (the xml file) in the mapsources directory.
 
Yes creating an xml file using the above template makes the MapTiler tiles available in MOBAC

Mobile Atlas Creator (MOBAC) 1.9.9 (2066)
Got extent in lat long from viewing openlayers.html from MapTiler at max zoom and reading off lat long by pointing cursor at extent corners
N -38.67840
W 176.51278
E 176.51779
S -38.68425
After resetting some stuff it ran in 27 seconds:
output sqlite file saved in  \mobac\atlases
in file MyTIF.sqlitedb
 
Osmand guide says copy sqlite file to osmand\tiles, ie the sqlitedb file goes directly in the tiles directory, not a subfolder of that. It then appears in the Map Sources list with the file name, eg MyTIF
The test file was tiny, just over 400 by 600m so 24ha. With the zoom levels I chose this means MapTiler render time is roughly 30 seconds per hectare, this would add up on larger areas. But the big time factor seems (not surprisingly) to be selecting higher zoom levels. So try a test with just low zoom to see if you can make it complete?
 
  cheers Dave

S.by

unread,
Feb 1, 2013, 9:19:12 AM2/1/13
to osm...@googlegroups.com
Thanks very much DaveP for your detailed explanation ...

You could write the instructions manual ;)  , this is ,  until OsmAndMapCreator will have this feature.... hopefully . 

I will try to make a map with your explanations soon ... and hope it will be o.k ...


S.by

unread,
Feb 4, 2013, 1:09:09 PM2/4/13
to osm...@googlegroups.com
DaveP or anyone ... i have taken tiles from OsmAnd and put it in MOBAC like it says in DaveP post .

I didn't change the tiles names.

I have entered a localTileFiles.xml but when  i try to look in this source i see nothing . ( i see the red "X" ) 

I have already made successful sources with mobac like online sources and OsmAnd sqlitedb  source ... but i cant get results with local OsmAnd tiles .  

pdon...@gmail.com

unread,
Jul 1, 2013, 9:27:28 PM7/1/13
to osm...@googlegroups.com
Hi DaveP,
Have similar trouble to S.by  below
Have produced a Maptiler output with numerous .png files in folders and "tilemapresource.xml". Have successfully pointed MOBAC at folder containing this output, but only get red crosses. Could you supply Maptiler files that were successful in MOBAC so I can see where my setup is different?
 
Thanks,
 
Paul

Christof Knu

unread,
Jul 3, 2013, 9:26:19 AM7/3/13
to osm...@googlegroups.com
Hi,
I create sqlite files from tif, jpg, png, ... with the software mapc2mapcnet (http://www.the-thorns.org.uk/mapping/).
Ok, the software cost 10 british pounds (free demo version), but it can do the complete job within few minutes:
- read in the image
- calibrate (with a great number of coordinate-systems; swiss maps and many others use very special coordinate systems...)
- export sqlite.db that can be used with osmand (the command is: file / write map for mobile devices / locus-rmaps-galileo-sqlite.db)
Best regards,
Christof

pdon...@gmail.com

unread,
Jul 4, 2013, 5:41:07 PM7/4/13
to osm...@googlegroups.com
Thanks Christof - this software solves my problem!
Reply all
Reply to author
Forward
0 new messages