GIS to CAD using ogr2ogr – Part 1 – Shp to DXF with Contour Data

GIS to CAD using ogr2ogr – Part 2 – GML to DXF with OS MasterMap
GIS to CAD using ogr2ogr – Part 3 – Point Annotation to Text in CAD

The power of GDAL, and specifically ogr2ogr is pretty impressive. This conversion is from shp to DXF, which is a somewhat universal CAD format so further conversion should be possible.

This post will cover contour export while maintaining 3D elevation, in addition to contour values as layers in CAD. The data used is OS terrain 50.

OS Terrain 50:

https://www.ordnancesurvey.co.uk/opendatadownload/products.html

In QGIS:

Screenshot[1]

Contours in 3D:

ogr2ogr -f DXF contour_zfield.dxf SX99SW_line.shp -zfield PROP_VALUE

With the -zfield creating the 3d elevation.

Great result:

Screenshot[3]

The alternative is to just store the z-value as layers.

ogr2ogr -f DXF contour_layer.dxf SX99SW_line.shp -sql "SELECT PROP_VALUE AS Layer FROM SX99SW_line"

Layers work great:

Screenshot[2]

With the ogr2ogr DXF driver, if you have an input column called “Layer” then it will be used to group features as a layer in DXF. We use a SQL query to achive this. Prop_Value is the height field in my input data.

And putting them all together:

ogr2ogr -f DXF contour_zfield_layer.dxf SX99SW_line.shp -zfield PROP_VALUE -sql "SELECT PROP_VALUE AS Layer FROM SX99SW_line"

Result not as expected, flat output:

Screenshot[4]

Adding our SQL select statement removes our zfield attribute as such ogr2ogr cannot access it. Lets resolve this:

ogr2ogr -f DXF contour_zfield_2_layer.dxf SX99SW_line.shp -zfield PROP_VALUE -sql "SELECT PROP_VALUE AS Layer, * FROM SX99SW_line"

Excellent:

Screenshot[5]

Layers and height.

GIS to CAD using ogr2ogr – Part 2 – GML to DXF with OS MasterMap
GIS to CAD using ogr2ogr – Part 3 – Point Annotation to Text in CAD

UK Rail Network by Agency and Parent

I created a post of the UK rail network some time ago and have been meaning to return to the subject.

This iteration is in Leaflet and will run weekly. The network is generated direcly from the UK rail network timetable file in GTFS format downloaded from: gbrail.info

The network is still generated using a station to station methodology, so the next step will be to incorporate an actual network and run it trough PGRouting. The logic for ownership can be found at: maps.gisforthought.com/uk_rail_map/ukrail_distinct_agencies_parent.html

If there are any issues or inconsistencies, please let me know, preferrably through the GitHub issues page: GitHub Issues

I am very happy with the overall result and all the hosting is done from scratch using a virtual server from: Digital Ocean

A good learning experience with NGINX and mobile forwarding.

As a final warning, the mobile version is not very good, if viewing on mobile and interested, please try on a desktop. Sincere appologies for that. Leaflet may not be the best mobile platform, although it is probably due to my inexperience with it.

Full Page Link

UK Rail Map by Operator and Owner: