# Creating maps

## GpsDrive tile format

#### File format

• Common image format (Tiff, PNG, JPEG, ...) of size 1280x1024

#### Map registration

The map name, center coordinate, and map scaling parameter are saved in the map index file: ~/.gpsdrive/map_koord.txt

• map_* maps
• top_* maps
Important! The maps must be named "map_*" for UTM-like projections
(lat:lon = 1:cos(lat)) and "top_*" for lat/lon Plate carree projection
(lat:lon = 1:1). The prefix is given so that gpsdrive knows how to
scale the maps correctly. Alternatively the maps can be stored without
prefix in subdirectories of \$HOME/.gpsdrive/ which end in "_map" or
"_top".

##### How to calculate the scaling factor
meters_per_pixel * 2817.947378

• Where does 2817.947378 come from?
Perhaps 2817 was someone's monitor DPI converted to pixels/meter??

For a 21" monitor with aspect ratio of 4:3, monitor width is given by

$\sqrt{width^2 + height^2} = 21^2$
$\sqrt{(4c)^2 + (3c)^2} = 21^2$
$\sqrt{16c^2 + 9c^2} = 21^2$
$\sqrt{25c^2} = 21^2$
$c = 21/\sqrt{25} = 4.2\ inch$
$width = 4*c = 16.8\ inch = 0.42672m$

so that constant in the GpsDrive code assumes that monitor resolution setting is fixed at $2817.947378\frac{px}{m} * 0.42672m = 1202.5 px$

thus for correct scaling it assumes monitor resolution is set with width 1202 pixels. Mine is set at 1280 wide, so not too far off. If I switch resolutions it gets worse though.

The GIMP offers a calibration option to overcome this problem of everyone's monitors being different:

File → Preferences → Display → dpi [Calibrate]

Currently NASA OnEarth LANDSAT global mosaic and OpenStreetMap.org Tiles are available.

## Using gpsfetchmap.pl

• You can automatically download a set of map tiles along a route using GpsDrive's gpsfetchmap.pl script.
• TODO

#### Example

TODO


## Using gdal_slice.sh

gdal_slice lets you create map tiles from a wide range of data formats using the GDAL software.

Misc. data formats will will have to be processed with a tool like gdal_translate.

• Get the gdal_slice.sh script (in the scripts/ dir in the source code)
• Make sure that GDAL can read the format,
gdalinfo filename.ext


Check installed GDAL supported formats:

gdalinfo --formats


If the GDAL webpage says that the format is supported but you can't seem to access it, check that your copy of GDAL was built with support for it. You may have to rebuild GDAL yourself with the switch for that format enabled.

• If GDAL can read the format, but it is not georeferenced, you will have to take care of that first. You should see some information about the coordinate system used and the lat/lon coordinates of the four corners of the map. See the #Georefencing section of this page.
• edit the filename information at the top of the script
• run the script (make sure you have execute permission set on the file)
./gdal_slice.sh

• move the files into your ~/.gpsdrive/maps/ directory and merge in the registration information into the ~/.gpsdrive/map_koord.txt file.

### Common inputs

#### BSB Softcharts

GpsDrive with downloaded NOAA BSB Navigation Chart #12326, "Approaches to NY Harbor", processed with gdalwarp and gdal_slice.sh

• NOAA BSB rasterized nautical charts (Requires GDAL support)
• Check with gdalinfo
• Modify gdal_slice.sh
• Run gdal_slice.sh
• move tiles and map registration info into ~/.gpsdrive
##### Example
TODO


## Using GRASS GIS's d.out.gpsdrive

You can render and export a custom scene from the GRASS GIS software using the GRASS GIS d.out.gpsdrive module.

### Procedure

• Import BSB raster RNC chart scan with r.in.gdal
• Display selected layers and overlays in an xmon (d.* modules) and zoom to desired area
• Export with d.out.gpsdrive

### Example

d.out.gpsdrive output=tile_name


## Online map servers

1. For Program select (*) gpsDrive
2. To prevent problems with overlapping tiles choose an Overlap (%) of more than 25%.
3. In the map box drag and zoom the map to your overall area of interest.
4. Zoom out slightly so the map box shows the bounding box of the area you wish to fetch entirely.
5. Set the east,west,south,north values using the buttons (you may have to vary the order of pressing the buttons, keep at it until all values are updated, the this order first).
6. Zoom in on the map to your desired detail level and click on the [Set zoom] button. Write down this zoom level.
7. If you changed the overlap percent after setting the bounds you'll want to recalculate.
8. Ensure that GpsDrive is ticked and press [Generate Wget].
9. Follow the instructions given by the result, cut and paste the wget commands into a terminal window.

If the map scale seems to be somewhat off, take the zoom level number you wrote down earlier and plug in the central latitude value from the map_koord.txt entry. A more correct scale factor can be calculated with the following equation:

DEG_TO_RAD = pi/180
# GpsDrive's hardcoded pixels per meter ratio:
PixelFact = 2817.947378
# WGS84 major axis radius for Earth
a = 6378137.0
dynscale = ( a * 2*pi * cos(lat * DEG_TO_RAD) * PixelFact ) / ( 256*pow(2,zoom) )


### OpenStreetMap (non-Mapnik)

(old & out of date??)

• Fetch OpenStreetMap data with gpsdrive-generate-mapnik-tiles.py
You will also have to set up mapnik for OSM

## Blue Marble mosaic

You can automatically create map tiles from the NASA Blue Marble 2002 dataset. See Documentation/README.nasamaps in the source code.