/desCartes

desCartes recognises roads on old maps, and converts them to vector lines that can be used in GIS applications and historical transport network analysis.

Primary LanguagePythonOtherNOASSERTION

desCartes

desCartes recognises roads on old maps, and converts them to vector lines that can be used in GIS applications and historical transport network analysis. It is currently under development, but you can try a limited live demo.


Black & White Maps

For any given map extent (bounding coordinates), desCartes first generates a georeferenced map image (geotiff), and then - using a range of adjustable input parameters - processes the image to extract candidate road lines.

Demonstration of desCartes. The user can select a map area (for the sake of server resources currently limited to a maximum of 10 km² for maps at this scale) and adjust the parameters used to detect likely roads.

Output from desCartes. A range of images is presented to indicate the steps taken in identifying likely roads, and a button is provided for the download of vector data.

This image shows the tests run along the contours of a skeletonized image to determine the presence or otherwise of road boundaries or modern roads (shown in yellow). Shape filtering before running these tests would eliminate most of the false contours in white areas. The modern road tests check not only the presence of a road in the vicinity, but also its orientation relative to the candidate road.

Network analysis aims to group candidate roads into a likely network, patching gaps where necessary. Candidate roads which fail a connectivity test are eliminated. Parameters for tuning the analysis are yet to be properly determined, and in the meantime results range from terrible to impressively good!

Output from desCartes. Areas are shaded by colour to indicate the criteria by which they were rejected as candidate roads. Candidate road vectors are scored based on their adherence to map contours and their similarity to modern roads, and their score is reflected in the opacity of the yellow lines. Blue lines are un-scored gap-fillers.

Coloured Maps

Extracting road vectors from coloured maps poses a different set of challenges.

In this map, the roads of interest are coloured red, brown, and yellow. Complications arise because parts of the roads are obliterated by text and map features, and these colours are also used for things like elevation contours, road numbering, and railway stations.

In the demo, an area up to 40 km² can be selected by the user. Results include images showing the colours extracted from the map, an edited, "skeletonized", and vectorised version of the colour map, and another version in which the gaps have been patched.

Extracted colours, with configured shapes removed (in this case, the railway station). Road numbering remains, and there are some quite large gaps where roads were obliterated by other features.

The coloured shapes are then thinned down to a single-pixel width, and then traced (by processing contours) to produce gappy vector lines.

Gaps are closed by a variety of techniques, which include extending each line a pixel at a time to see if it meets another extending line within a given distance, linking unconnected endpoints to nearest lines, and snapping near-coincident endpoints.

Flowchart

This gives a very broad overview of the sequencing of processes for different types of map. Each process takes a customisable set of parameters which have a significant impact on the quality of results. The sequencing and parameters need to be adjusted depending on the style of the map.

  flowchart LR
    A((Load Map))-->B{Is it coloured?}
    B-->|Yes|B1[Extract Colours]
    B-->|No|C2[Contour Cleaning]
    subgraph coloured [Coloured Map]
    B1-->C1[Remove Shapes]
    C1-->D1[Morphological Cleaning]
    D1-->E1[Skeletonization]
    E1-->F1[Cleaning]
    F1-->G1[Patching]
    G1-->H1[Reprojecting]
    end
    subgraph bw [Black & White Map]
    C2-->D2[Morphological Cleaning]
    D2-->E2[Shape Filtering]
    E2-->F2[Skeletonization]
    F2-->G2[Road Detection]
    G2-->H2[Patching]
    H2-->I2[Network Analysis]
    end
    H1-->C((Output Vectors & Visualisation))
    I2-->C
Loading

Development Roadmap

  • Improve 1890s B&W vectorisation by reference to vectorised 1950s coloured map framework (Issue #11).
  • Publish code as configurable, executable pipeline components using Google Colab-flavoured Jupyter notebooks.
  • Enable upload of georeferenced maps or plain map images in lieu of map tiles (Issue #12).
  • Create a national "#GB1900" road vector dataset (Issue #13).
  • Refine processing parameters through machine learning (Issue #4), using TensorFlow Keras in Colab.
  • Pre-processing to remove road-name text in urban areas using Discrete Cosine Transformation (DCT) techniques. The aim for GB1900 is to train a classifier to separate character pixels from other black pixels (including road lines): training data might very easily be generated programmatically, tailored to the specific font and line widths of the OS 6” map series. Generalisation of such pre-processing might be preferable to the currently-implemented Otsu image thresholding.
  • For GB1900, eliminate footpaths using Ramblers’ Association crowd-sourced data.
  • Use refined system to generate training data for machine categorisation of image contours, with minimal manual cleaning. Input variables for training would include contour area, convexity, and aspect ratio, the maximum, mean, and standard deviation of enclosed pixels of the Euclidian distance matrix, and the maximum, mean, and standard deviation of the size of enclosed contours.
  • Use of the Euclidian distance matrix and A* pathfinding algorithm to clean up the intersection distortion of skeletonised junctions.
  • Gap closure using least cost path through the Euclidian distance matrix.

Live Demo

Click here for a limited live demonstration of desCartes in your browser, where you can select a small area on a map and see the results of image processing, and download a GeoPackage of the predicted road network for use in GIS software. Choose from several preconfigured map tilesets, or experiment with your own.

Map Tile Sources

desCartes might be adapted to suit other maps, but is pre-configured for use with:


Customisation & Funding

You are free to share and adapt this software yourself, subject to proper attribution as detailed in the license, but commissions for customised development are very welcome!

Development and server costs are otherwise entirely self-funded. Please donate if you can.

Follow @docuracy on Twitter or @stephengadd@mstdn.social on Mastodon for updates.