LogoMap Lines Overview

Map Lines is a C# application that primarily allows you to digitalize points on images by drawing lines between them. It saves the pixel coordinates of points on the line in a file. It was originally designed to trace old railroad beds in Northern Wisconsin that had been drawn by hand on USGS geologic maps by James P. Kaysen with the purpose in mind to display these digitally in an application such as Google Maps. It can more generally be used to draw GPS tracks or other data on an image of a map, such as one with hiking trails.

The digitizing capability in Map Lines does not require a coordinate system other than the x, y pixel coordinates of the image. However, it is necessary to convert the pixel coordinates to latitude and longitude coordinates in order to display GPS data if those are used. To do this a calibration file is needed. The calibration file must be created outside of Map Lines, typically in a text editor. See Calibration Files for more details.

Map Lines can also be used to digitize graphs, that is, get the x, y pixel coordinates of the points of the lines in the graph..

To use Map Lines you would typically load an image file and a calibration file (if GPS data is to be used). You can then draw lines or generate them from GPX files. You can start and end lines using the right-click Context Menu. You can save the lines as a Map Lines .lines file (one line for each point consisting of the x and y pixel values), a transparent PNG file consisting of only the lines, a PNG file of the original image including the lines, a GPX file, or a CSV file. The PNG files can be used in MapImage provided you have the corresponding calibration file.

Note that most of the user interface elements, such as buttons, text entries, checkboxes, etc., have tool tips which should appear when you hold the cursor over them. This is the easiest way to get help on what these controls do.

Acknowledgements are at the end of the page.

The Interface

This is a screen shot of the Map Lines interface. Lines from many GPX files have been loaded, and the Calibration Lines between the calibration points are also shown. In this case the calibration points are at the corners, but that is not necessary.

MapLinesScreenshot.jpg

 

Installation

If you are installing from a download, just unzip the files into a directory somewhere convenient. Then run it from there. If you are installing from a build, copy all the files and directories from the bin/Release directory into a directory somewhere convenient.

To uninstall, just delete these files.

MapImage (Android Application)

Note that there is an open-source Android application MapImage that displays your current location on a map that has been calibrated in this way.You can use this to show where you have been before as well as where you are now. The following is a screen dump from MapImage showing the current location and assorted previous GPS tracks on a map of hiking trails. The GPS tracks were added to the original image of the map using Map Lines.

Highland State Recreation Area

Calibration Files

The calibration is specified in a text file with extension .calib consisting of lines of the form:

integer x, white space, integer y, white space, decimal longitude, white space, decimal latitude.

These can optionally be followed by:

white space, then a comment.

x and y are the pixel coordinates in the image, starting at (0, 0) in the upper left and ending at (width-1, height-1) in the lower right. There must be at least three such lines, but there can be as many over this as you like. Map Lines (and also MapImage) will find the best fit to all the values specified using a matrix method known as Singular Value Decomposition. The points specified must be sufficient to determine the latitude and longitude. Three co-linear points will not work.

This is an example of a calibration file corresponding to an image of width 832 and height 1079. (The calibration points are at the corners in this case):

   0     0   -83.603411    42.642879 NW
 831     0   -83.568607    42.643245 NE
 831  1078   -83.568255    42.609770 SE
   0  1078   -83.603059    42.609404 SW

An image manipulation program, such as Photoshop, can be used to find the pixel values of points for which you know the latitude and longitude. These could be known latitude and longitude for some landmark or the corners of the map.

Another way to determine the corner values is by placing the image as an overlay in Google Earth (Add | Image Overlay) then adjusting it to match up with what is displayed in Google Earth. You can then put placemarks on the corners and get the latitude and longitude from the placemarks. Use Add Placemark and move the pushpin icon so the point is at each corner in turn.

Note that the calibration is not limited to GPS latitude and longitude. It can be calibrated to any 2D coordinate system, for example, the x and y axes of a graph.

Shortcut Keys

Plus key : Zooms in. (Can also be Ctrl+Plus as it does not check for modifier keys.)

Minus key : Zooms in. (Can also be Ctrl+Plus as it does not check for modifier keys.)

Spacebar : Cursor changes to a hand and you can pan the image by dragging.

Ctrl+0: Centers the image.

Ctrl+1: Resets the image to the starting position (not zoomed, top left corner at the top left).

Edit Mode

There are several ways to edit the lines you draw. There is the Edit Lines dialog, where you can edit the properties of all the lines in one place. There is an item in the Context Menu to delete the last point in case you did not like it. And there is Edit mode, also in the Context Menu, where you can edit the points in the line. When Edit Mode is enabled, when you click on a line it becomes highlighted, and the end points are represented by circles. If you click on an end point, that endpoint is selected. You can move the endpoints points by dragging them. If you Shift-click on a line it will add a point where you clicked. If you Alt-click an endpoint it will delete it.

Menus

File Menu

Open Image

Open an image. Most common image formats are supported.

Open Calibration

Opens a calibration file. These typically have a .calib extension.

Exit

Quits Map Lines.

Lines Menu

Edit Lines

Brings up a dialog where you can manage the existing lines, including deleting, renaming, changing the color, and moving them up and down in the order. Use this dialog to manage the lines you created if necessary.

Open Lines

Opens a lines file. These typically have a .lines extension. They consist of one line for each point consisting of the x and y pixel coordinates separated by a space. Blank lines and lines starting with # are ignored.

Lines from GPX

Generate lines from a GPX file or files. More than one file can be chosen.

Lines from GPX File Set

Generate lines from the GPX files in a file set. A file set is a text file with the full path name of a GPX file on each line. Files sets can be created in GPX Viewer (https://github.com/KennethEvans/VS-GpxViewer) or manually. The default extension is .gpxfs. Blank lines and lines starting with # are ignored.

Save Lines

Save the existing lines as a lines file.

Save Lines as CSV

Save the lines in CSV format. For each there will be a description line and a line for each point with the x and y pixel coordinates, comma separated.

Save Lines as GPX

Save the lines in GPX format. The resulting files can be loaded into Google Earth, for example. There must be a calibration file loaded.

Save Lines as PNG

Save the existing lines as a PNG file. It will be transparent except for the lines and can be pasted or added as a layer in most image manipulation programs.

Save Lines with Image as PNG

Saves the current image along with the lines as a PNG file. This is typically used to generate an image from the original image but with GPS tracks.

Help Menu

Overview

Brings up a window with this HTML file. It works as a rudimentary browser with links and Back and Forward buttons.

About

Gives information about this application including the version.

Context Menu

You get the context menu by right clicking on the image.

Zoom

Has options to zoom 200%, 100%, 50%, and 25%. Zooming is also available with the Mouse Wheel.

Pan

Toggles Panning mode. When Panning mode is on, the cursor is a Hand, and moving the mouse pans the image. Panning mode can also be initiated temporarily by holding the Space key down.

Reset

Resets the view to the initial state (not zoomed, top left corner at the top left).

Start Line

Start a new line. The next click on the image will be the starting point (nothing will show), and with each successive click a line is drawn from the previous point.

End Line

Stop adding points to the current line. The next Start Line with be a new, disconnected line.

Delete Last Point

Deletes the last point. Usually used when you did not get the point in the right place.

Clear Lines

Clears all of the lines. Use Edit Lines for more individual control.

Calibration Lines

Generate lines from the calibration file. If you are using the corners of the image as calibration points, this allows you to check that they are, in fact, on the edges of the image, as they should be if your calibration is correct.

Acknowledgements

Map Lines is available from GitHub at https://github.com/KennethEvans/VS-MapLines.

It is a replacement for https://github.com/KennethEvans/maplines which is a Java application.

It uses the NuGet package Math.NET Numerics and uses Utils.dll from https://github.com/KennethEvans/VS-Utils.