Wolfram Language Paclet Repository
Community-contributed installable additions to the Wolfram Language
Threads a cross-section template along an alignment to design roads, dams, drainage, pads and slope-stability sections alike
Contributed by: Malcolm Woodruff
LineTerra turns the Wolfram Language into an earthworks design and quantification workstation. Its core method threads a cross-section template along an alignment and calculates its intersection with the existing ground; a separate polygon tool handles footprint-based earthworks such as building pads. Although most worked examples design roads -- horizontal alignment with circular or Bezier intersection-point curves, vertical profile with K-value parabolic curves, and cross-section templates carrying carriageway links, cut and fill batters, ditches, walls and bridge or tunnel structures -- the same procedure applies to slope-stability cross-sections, dam design and reservoir volumes, drainage networks, channel or valley section design for flood routing and single-building pads. Output covers cut and fill quantities including a mass-haul diagram, 3D visualization, and export to CSV, true-scale PDF, PNG, DXF and native notebooks.
To install this paclet in your Wolfram Language environment,
evaluate this code:
PacletInstall["MalcolmWoodruff/LineTerra"]
To load the code after installation, evaluate this code:
Needs["MalcolmWoodruff`LineTerra`"]
Open the LineTerra toolbar for a project. This is the entry point to every other window -- Terrain, Plan/Profile, Intersect, Templates, Sections, Earthwork, Export, 3D View and Bake Road. Evaluating it again with the same name reopens that road; with a different name it opens another road on the same terrain:
| In[1]:= |
| Out[1]= | ![]() |
Then the workflow is:
1. Load Terrain
1.1. Terrain can be in Geotiff, LAZ(with PDAL or LASzip), LAS, or XYZ files else defined by Latitude and Longitude or National Grid rectangles or corridors. National Grids for most countries are included together with a coordinate conversion function. Multiple tiles can be loaded and a preview shown.
2. Open Plan
and construct horizontal alignment
2.1. The Plan/Profile window shows the terrain with a choice of backgrounds, contours and grids. Choose the background and then Update Terrain.The plan size is adjustable to fit different displays and a zoom function is available. The intersection points to define the alignment are added by clicking on the plan. Curvature can be added by clicking on the IPs.
3.
and construct vertical alignment
3. 1. Below the plan is the Extract Profile button. This will bring up a longitudinal section along the alignment. Vertical intersection points, VIPs, can be added at will to define the vertical alignment and curvatures can be defined by clicking the vip list.
4. Design or Load cross section template/templates
4. 1. Cross section templates consist of a series of links that exist out from the centreline and define the cross section. Links are either of fixed length or may be curtailed if they intersect with the ground. Split points can be defined after which different paths are followed depending on whether the link is in fill or cutting. Links can be given a thickness which shows on the section and is not included in the calculation of quantities.They can also be given a colour, which shows on the plan. Bridge type sections have no quantities and tunnel sections have a fixed height above the links which is used to calculate the quantities.
5. Assign templates to alignment and calculate sections
5.1. Section templates are assigned to chainages along the alignment. As many section types can be used as required. If gaps are used between different templates then, as long as the number of links are the same, the ground in between is interpolated. The section at any chainage can be calculated and shown.
6. Calculate earthworks and show earthworks on plan
6.1. By clicking the Compute button in the Earthworks window, all sections specified are calculated and the plan is updated to show the ground along the alignment with all its batters and surfaces.
7. Refine as necessary 7.1. Clicking show Chart will bring up charts of quantities along the alignment. With the Auto button clicked moving either the IPs on the plan or the VIPS on the profile will instantly update the charts of quantities and plan, so the amount of fill and excavation can be balanced and the limits of the earthworks to be checked.
8. Export plan, profile and cross sections with quantities
8.1. Export of alignment, profile, earthwork quantities can be as csv or notebook objects and plans and sections can be output to scale as pdf, dxf or notebook items.
9. Optionally
earthworks into plan for further work
9.1.
s can be shown, either before or after baking the proposed earthworks into the terrain.
10. Adding pads
10.1. Pads can be defined with any convex polygon, average levels shown and quantities calculated with vertical or sloping edges defined by templates. Multiple roads or pads can be defined on the same terrain.
Terrain comes from whichever source suits the stage of the project. A GeoTIFF elevation raster, with its.tfw world file or with the georeferencing tags embedded in the file itself:
| In[2]:= |
A LIDAR point cloud, gridded from its ground-classified points. A. laz file needs PDAL or LASzip on the system path; a.las file is read with no external tool:
| In[3]:= |
A synthetic corridor strip following the assumed route centreline, which keeps a very long route's terrain to a workable size. Make the number of cross samples odd, so one falls on the centreline:
| In[4]:= |
Work can be carried out in latitude and longitude or in a national grid, and most countries' grids are supported. Converting to the British National Grid:
| In[5]:= |
| Out[5]= |
Any UTM zone or other supported projection can be named by its EPSG code directly:
| In[6]:= |
| Out[6]= |
Cross-sections export to PDF at an exact drawing scale, to a notebook as named vector graphics, or to true-scale DXF. DXF coordinates are real-world metres -- one drawing unit is one metre -- with geometry separated onto per-section GROUND, DESIGN and SCALE layers:
| In[7]:= |
First, evaluate the following and you will get the main menu. Choose New Project then Terrain:
| In[8]:= |
| Out[8]= | ![]() |
Press LAZ/LAS point Cloud. If it is a LAZ file then you must have PDAL or LASzip on the system path, e. g.: brew install pdal. (See “Read this first). If you have, or if it is, a LAS file the file will be read directly:

The preview can be shown in the normal way:

Pressing Plan and then adding IPs to form a road alignment:

Extracting a profile:

Either open a template library or design new ones. Here we have opened the library so we can use the motorway and bridge templates:

Assign sections to the alignment:

Calculating earthworks we get an updated plan:

And earthwork quantities:

Leaving Earthworks on Auto we can then adjust the profile and/or the planned alignment and the quantities and plan will instantly update:



The road can be baked into the terrain and a 3D image produced. Sections or the plan can be exported to scale:

Wolfram Language Version 13.0