This is an old version of LandSerf. For the latest release please visit

Chapter 3. Creating, Editing and Transforming Data

3.1 Creating New Raster Data

It is possible to create new raster surfaces by selecting New Raster... from the File menu, by pressing the button button, or by using the shortcut key Ctrl-N. You will be presented with a dialogue window allowing the bounds, resolution and map projection of the new raster to be changed. The default settings create a raster with 100 rows and 100 columns. The new raster can be either a polynomial expression or a fractal surface with a user-defined fractal dimension.

New raster window New raster window using polynomial expression and metadata.

For modelling and simulation purposes it is sometimes useful to create artificial surfaces with known characteristics. By selecting Polynomial from the Create New Raster window, you can define surfaces with the following variables and functions.

xthe x position of each raster cell. x is scaled to be +- nCols/2, where nCols is the number of columns in the raster
ythe y position of each raster cell. y is scaled to be +- nRows/2, where nRows is the number of rows in the raster
z1the value of any given cell in the primary raster.
z2the value of any given cell in the secondary raster. This will only be meaningful if a secondary raster has been selected; if it does not, z2 will always return 0.
pi, eThe constants PI (3.1459) and e (2.7183)
+, -, *, /, ^Addition, subtraction, multiplication, division and power operators.
cos(), sin(), tan()trigonometrical functions. Expects angles to be given in radians (to convert from degrees into radians multiply by pi/180 or 0.01745329). Values of infinity (e.g. tan(pi/2)) are returned as 0.
acos(), asin(), atan()inverse trigonometrical functions. Returns values in radians (to convert from radians into degrees multiply by 180/pi or 57.2957795). Values outside of the range of +-1 supplied to these functions will return a value of 0.
sqrt()Square root. If the value given to the function is negative, the function will return a 0.
ln()Natural logarithm (to base e). If the value given to the function is <=0, the function will return a zero.
randRandom value with 'rectangular' distribution between 0 and 1.
gaussRandom value with Gaussian (normal) distribution with mean of 0 and standard deviation of 1.
()Brackets to control the order of evaluation.
x+y Creates a plane sloping from bottom right to top left.
0 - (x^2 + y^2) Creates a convex-up dome.
z1-z2 Creates a difference map of the differences between the primary and secondary rasters.
100 - sqrt((x*y*sin(x*y/200) * cos(y/30))+(x^2+y^2)) Complex polynomial (peak with 8 radial valleys).
z1 + (gauss*10) Adds a random gaussian value with mean of 0 and standard deviation of 10 to each cell in the primary raster.

Expressions that are incorrectly specified (e.g. using unknown functions, or failure to close brackets), are highlighted in the edit window and preventing it from being closed.

Polynomial and combined polynomial and fractal surfaces Polynomial and combined polynomial and fractal surfaces

By selecting Fractal from the Create New Raster window, more realistic terrain surfaces may be created for modelling and simulation purposes. The roughness of such surfaces can be controlled by entering a fractal dimension between 2.0 (smooth) and 3.0 (very rough). Typical landscapes have fractal dimensions of around 2.1.

These may also be combined with smoother polynomial surfaces, as shown in the figure above. This can be achieved by creating a fractal surface and a separate a polynomial surface and finally creating a new polynomial as z1+z2, thus combining the two simulated fields.

3.1.1 Combing Raster Data

It is possible to combine the primary and secondary raster into a single raster layer by selecting the Edit->Combine rasters... menu option. This allows rasters that do not have the same spatial extent to be merged into a single object. This can be particularly useful for assembling 'tiled' datasets. Assuming a primary and a secondary raster have been selected in the thumbnail view, selecting the Combine Rasters option will bring up a window similar to the one shown below. If the spatial extents of both rasters are overlapping but not identical, you will have the option of either selecting the intersection of the two layers, or their union. For cell locations that are present in both rasters, you can select the output value for those locations to be the primary raster cell value, the secondary raster cell value, or the average of the two. Additionally, you can choose to override this selection for cells where the chosen raster value is null but would be a numeric value if selected from the other raster.

Raster combination options Raster combination options.

3.2 Creating New Vector Data

New vector maps can be created either by selecting New Vector... from the File menu or by pressing the button button. You will be presented with a dialogue window allowing the bounds of the new map to be changed. Initially this vector map will be 'empty', but it is possible to add vector objects through on-screen digitizing.

To digitize new data, make sure a vector map is selected (either an empty vector map as described above, or an existing one to which manually digitized objects are to be added), then select either the Edit->Digitize Mode menu option or the button button.

Vector digitizing Digitizing new vector objects.

You will then be presented with a small window (see the figure above) that provides you with the option of creating vector points, lines or areas. By clicking in the main LandSerf window with the left mouse button, coordinates can be added to a new vector object. The numeric attribute to be associated with that object can also be defined at this stage. If the auto-increment option is selected, the numeric attribute associated with the object will be increased by one every time an object is digitized. This can be particularly useful if you wish to digitize a series of waypoints. To store the digitized points, press the Store object button.

To make the process of digitizing easier and more precise, any raster data can be displayed on screen while digitizing, and the main display can be panned with the right mouse button (or <shift> left-click). If you wish to zoom in or out, you can temporarily toggle between digitize mode and zoom mode by selecting the button and button buttons or the appropriate menu options.

It is often easier to digitize if before selecting the digitize option, you set the Display->Vector appearance... to display point labels, a point size of about 3.0, and line width of about 2.0. This will make it easier to see the objects you have already digitized along with their attribute values.

3.2.1 Combing Vector Data

Vector maps can be combined in much the same way as raster data. Select the two maps to be combined as primary and secondary vector maps, then choose the Edit->Combine vector maps... menu option. As with raster combination, if the two vector map areas overlap you will have the option of either selecting the intersection of the two maps, or their union. You will also have the option of using the intersection/union of the bounding rectangle of the entire map, or the combination of the vector objects. This second option is useful if you wish to select all objects that fall within a given set of polygons for example.

Vector combination options Vector combination options.

3.3 Creating New Attribute Data

Both raster and vector data are associated with numeric attribute values. However, this can be limiting for data that have non-numeric or multiple attributes. In order to overcome this, any raster or vector map in LandSerf can be linked to an attribute table that defines the relations between numeric attributes (the 'ID' or 'key') and any other numeric or textual attribute values.

To create an attribute table, select either Edit Raster or Edit Vector as appropriate and then click the Edit button in the Attributes area (adjacent to the minimum/maximum attribute values). This should open a new attribute table editor that allows you to add rows and columns to the attribute table as well as load or save them from/to disk. Any attribute can be edited by clicking on the appropriate cell in the table. Attribute type names (column headings) can be changed by clicking the relevant column header.

Attributes can be either numeric or textual. Textual attributes have the advantage of allowing meaningful descriptions to be attached to objects, while numeric attributes can be manipulated analytically, for example, by calculating their average. By default, if you add a new attribute to a table, it is assumed to be textual. If all rows in the table of a textual attribute happen to be numbers, they can be converted to numeric attributes by pressing the Validate button.

All attribute tables have an active attribute associated with them. This attribute is indicated in bold in the editor window (see figure below for an example). The active attribute is the one that is displayed when querying a raster or vector. To make any attribute active, simply click one of the values in the relevant table column.

Attribute table Attribute table.

3.4 Editing Spatial Objects

All spatial objects (raster and vectors) can be associated with metadata describing the spatial properties of the object (bounds, resolution and map projection). They can also be classified into different object types (e.g. elevation, slope, features, fuzzy membership, image, contours, TINs etc.) that determine the type of operations that can be performed on them and the way in which they are displayed.

To edit either a raster or vector object, select it then choose the Edit->Edit Raster or Edit->Edit Vector menu item. Bounds, resolution (raster only), map projection, type, colour table and supplementary notes can all be changed from this window. Bounds can be changed either by typing new coordinates for each of the four edges of the object, or by dragging the mouse in the main display window to identify a sub-area of the object. To 'cut out' a subset of an object, make sure the Extract subset option is selected. To change the resolution of a raster object, ensure the Interpolate to new resolution option is selected and appropriate values are entered in the N-S Res and E-W Res fields. This technique can be used to remove 'steps' in a coarse DEM, or to provide an optimal sampling strategy for DEMs that are too large for effective processing.

If you know the map projection system used to represent a spatial object, this can be set by clicking the Edit button in the Map projection section of the edit window. You can choose between a limited set of projections and ellipsoids. Note that changing the projection information here does not reproject the spatial data. To transform the data from one projection system to another, select an appropriate option from the Transform->Reproject menu (see Section 3.6.1 below).

Projection information Projection information.

To commit changes made in the edit window, press the OK button. If there is an inconsistency between the new raster bounds and the resolution and neither the resampling or subset options are selected, the relevant fields will be highlighted when you attempt to exit the window.

3.5 Removing Data

Rasters and vectors can be removed by selecting the relevant thumbnail view and then selecting either the Edit->Delete raster or Edit->Delete vector menu option. You can also remove all spatial objects by selecting the Edit->Delete all... option.

3.6 Transforming Data

LandSerf allows you to perform three types of transformation. Coordinate transformations change the locational representation of rasters and vectors and include map projection and rectification. Model transformations include the conversion of vector to raster models, and the generation of contours and TINs (Triangulated Irregular Networks) from raster surfaces. Raster Value Transformations allow the values of individual raster cells to be changed through scaling, reclassification, translation etc. All are accessible through the Transform menu.

3.6.1 Coordinate Transformations

Map Projections

Both rasters and vectors may be reprojected from global latitude/longitude to Universal Transverse Mercator (UTM), Ordnance Survey National Grid (OSGB) or Swiss National Grid and back again. All reprojections are selected from the Transform->Reproject menu item. Note that in order to reproject a raster or vector map, it must first have some defined map projection information. If necessary this can be identified by editing the spatial object (see Section 3.4 above).

Lat/long and OSGB coordinate projections Lat/long (left) and OSGB (right) coordinate projections

When rasters are reprojected you are given the option of setting the new resolution and bounds of the projected raster. This allows allows square pixels to be created in UTM, OSGB and Swiss systems by setting identical x and y resolutions. You are also given the option to control whether or not to interpolate new values. Interpolation is suitable for continuous measurement data such as elevation. For categorical data, make sure this option is not selected so that new raster values are resampled from the original raster.

Image Rectification

Many raster objects that need to be referenced to some spatial units can be georeferenced simply by editing the bounds of the four edges (see Section 3.4 above). However for some data, more sophisticated transformations are required. Rectification allows a number of 'before' and 'after' points (known as transformation control points) to be defined. LandSerf will then attempt to find an appropriate transformation that will convert the georeferenced locations of the 'before' points into appropriate 'after' locations. This transformation can then be applied to the entire raster.

To perform image rectification, display the raster that will be transformed in the main LandSerf window and then select the Transform->Rectify... menu option. A new window similar to that shown below will appear. Making sure the Add points option is selected, click on the main raster display at a point at which you know the true georeferenced location. The untransformed raster coordinates will appear in the rectification window in columns 2 and 3. Enter the georeferenced coordinates in columns 4 and 5. Repeat this process for other points on the raster. You should aim to create a spread of typically 10-20 points over the entire raster. To make this process easier, you may also use zoom mode to zoom into particular parts of the raster (making sure the Add points is not selected when using the mouse to zoom and pan).

Rectification control point editor Rectification control point editor

You can control the complexity of the transformation to be applied by selecting one of the linear, quadratic or cubic transformation options. To calculate the transformation, press the Calculate transformation button. This will display the coefficients of the transform along with a measure of Root Mean Squared Error (RMSE) which should be as small as possible. The error associated each point is also displayed, and this can give a clue as to which of the control points should be changed in order to reduce the error. It is often worth trying different linear/quadratic/cubic options and examining their effect on the overall RMSE. The figure below shows the degree of flexibility each of these has on the transformation process. Higher order transformations require progressively more points in order to model the transformation (linear - 3, quadratic - 6 and cubic - 10).

Linear, quadratic and cubic rectification Linear (left), quadratic (middle) and cubic (right) rectification

When you are happy with an appropriate set of control points and transformation type, these can be saved as a separate file for later use using the Save points button. To transform the raster itself, press the Rectify map button. You will then be presented with the option of changing the new bounds and resolution of the new raster before applying the rectification.

3.6.2 Model Transformations

A raster DEM can be converted into a vector Triangulated Irregular Network (TIN) by selecting the Transform->DEM to TIN... menu item. You will then be presented with a dialogue window asking for various triangulation options (see figure below). To control the number of triangles produced by the process, either specify the number explicitly and select the relevant check box, or specify some error criterion. The error (either average as specified by the Root Mean Squared Error, or the maximum error) represents the difference in elevation between any point on the original DEM and its elevation in the TIN. The smaller the error specified, the greater the number of triangles required in the network. A representation of the spatial pattern of errors can be produced by selecting Create Error Surface from the dialogue box.

TIN creation options TIN creation options

In common with other LandSerf processing options, the DEM to TIN transformation can be interrupted at any stage by clicking on the progress bar in the bottom-right corner. Once interrupted, LandSerf will create a new TIN based on the number of triangles created at the point of interruption.

The triangulation process works by successively adding triangles to the network until either any of the selected error criteria are met, or the maximum number of triangles is reached (if specified). Alternatively, any set of point values can be triangulated by selecting Points to TIN from the Transform menu. This allow TINs to be created from points sets such as surface features (pits, passes and peaks) or spot heights.

It is also possible to convert a given TIN back into a DEM. This is achieved by selecting the Transform->TIN to DEM... menu option. LandSerf will apply a planar interpolation of the triangle network that tends to produce a surface composed of flat facets. If necessary, these can be smoothed using Quadratic Interpolation (see the Analysis chapter for details).

TIN over 'TIN to DEM' surface TIN over 'TIN to DEM' surface

It is possible to create a contour representation of a given DEM by selecting the Transform->DEM to contours... menu option. Once selected, you can control the contour interval and the elevation of the lowest contour. For DEMs with large flat areas (e.g. sea around an island), more useful results are produced when a contours do not coincide with the elevation of the extended flat region. Alternatively, flat areas can be reclassified as null values and be excluded from the transformation. The Grid width option controls the resolution at which DEM cells are sampled in order to thread contour lines. A value of 1 will sample every DEM cell and produce the most detailed contour lines; larger values will be faster and will generalise the resulting contours.

Contour creation options Contour creation options

By default, generated contour vectors are given the same colour scheme as the DEM from which they were derived. This can make them difficult to see when overlaid on the same DEM, so it can useful to change the colour scheme of one of the two models (e.g. grey contours shown in the figure below).

DEM with countour overlay DEM with contour overlay

More general vector to raster transformations can be made by selecting the Transform->Vector to raster... menu option. This will attempt to rasterize the currently selected vector map to a given resolution specified. Point data can be rasterized in this way, or they can be converted rasters of point density by selecting Transform->Point to density surface.... On selecting this menu option, a new dialogue window is shown requesting the raster resolution required and the size of the local window used to calculate density values. This can range from 1 to the size of the raster, but should be an odd number. The larger the number, the smoother and more generalised the resulting density surface will be.

3.6.3 Transforming Raster Values

A series of simple transformations can be applied to the values of a raster's cells by selecting the Transform->Raster Values... menu item. Raster values are scaled by the value in the Scale field, translated 'up' or 'down' by the Translate value or rounded to the nearest Round value. The elevation model can also be 'flooded' such that all values below that in the Flood field will be assigned that value. Transformations are only applied if the relevant check box is selected.

Raster value transformation Raster value transformation replacing zeros with null values

Additionally, you can replace given raster values by entering appropriate figures in the Replace ... with fields. If the two numeric values here are different, then all occurences of the number in the first field will be replaced with that in the second. This can be useful for simple reclassifications of categorical information. Rasters can also contain null values that are not displayed and are removed from processing operations. This is particularly useful for representing missing data, for water bodies and for excluding raster edges from processing. To replace numeric values with a null, or a null value with a numeric equivalent, enter an n in the relevant field (see figure above).