1. Searches, Queries and Spatial Analysis – Introduction
Most of this course relates to using spatial data or using data spatially, in order to gain extra insights which non-GIS data cannot provide. This is an introduction to try to explain some of the basic concepts of spatial analysis.
Let’s begin at the beginning. The type of query you will need will depend on where you are starting from. Let’s use some examples to illustrate this.
Example 1:
We need to find things based on what they are.
This could be all the businesses which sell food; all the applications received this year; or all the houses with 3 bedrooms.
This is a Database Query, which we will look at in Chapters 2, 3 and 4. A database query starts by searching the data attributes you have entered against the overlay features.
We will include how to amend the data on just those things we find (Chapter 3) and how to manage the queries and share them (Chapter 4).
Example 2:
We have found things based on what they are, but also need to see where they are by showing the results on the map.
This could be to show all the Band D Council Tax addresses on a map.
This is a Display Query, which we will look at in Chapter 5. We will also look at labelling the map display from the information found.
Example 3:
We need to find things, based on where they are.
This could be all addresses within 200 metres of a planning application boundary, or all schools within a 2 km evacuation circle from a hazardous site.
This is a Spatial Query, which we will look at in Chapter 6. A spatial query starts by defining a search area on the map, and then looking inside the search area for features. We will look at using this information in consultations for example.
Now let’s mix things up a bit.
Example 4:
We need to find things, based on where they are in relation to some locations we already know.
This could be all addresses within predefined consultation zones; or all crime incidents within existing ward boundaries.
This is using the queries to compare two sets of spatial data, which we will look at in Chapter 7. We will look at combining both database and spatial searches, and will also look at updating the data on just the records found by the queries.
Example 5:
We have different quantities of things recorded in different areas, and need to display this on the map to demonstrate the differences between those areas.
This could be parishes graded by the number of new-build houses; wards graded by the number of fire incidents; or addresses graded by where Council Tax has been outstanding the longest.
This is a Thematic Query, which we will look at in Chapter 8. A thematic query compares the data within the search areas and turns this into a display, usually by colouring the areas according to the quantities.
Example 6:
We have different quantities of things recorded about different places but first need to analyse or count these and then display the results
This could be streets graded according to accident statistics; or housing estates graded according to anti-social behaviour complaints.
This covers what we call Hotspot Analysis and Cluster Analysis, and we will look at a few methods for doing this in Chapter 9. This includes displaying symbols, the size of which reflects the quantities discovered by the counting.
The remainder of the course then looks at –
- how queries may be denoted on the map through the Key
- an introduction to using Reporting tools
- an introduction to sharing information externally
2. Database Searching
To search an overlay database for the information you require first set the overlay as the Foreground Overlay in GGP and then select Search|Database.
The Database Query dialog provides a number of options for data analysis.
From here you can build, modify, run and save a Database Query.
Build a New Database Query
A Database Query is a list of records that match a specified set of criteria and displayed in a table. To build a Database Query click the Add button and select DB Query.
This will display a form that has the fields from the current foreground overlay in the left hand Field list. The other list boxes contain query ‘Functions’, ‘Operators’ and ‘Joiners’ which you can use to construct your query.
Simple examples of query syntax could be:
FIELDNAME='ABC' (for character fields) or FIELDNAME<>'ABC' FIELDNAME=20 (for numeric fields) or FIELDNAME>20
You can use the functions to build much more complex queries and can look at several fields at the same time. The functions are fully detailed in the Appendix for reference.
Double-click on the required field from the field list. The field will now be placed in the current query box at the bottom of the form, ready for you to add an operator such as =, <=, >=, etc.
Keep adding fields, operators, and joiners until the query string is complete.
When you have finished creating your query, click on the Test Syntax button to check that the query is OK. When the query has been tested click on the OK button.
You will then be asked to type in a description and category, so that you will recognise the new query in the list of available queries.
You will then be returned to the query management window where you can execute the query.
The Database Query will appear in the list of queries and will be identified by the database icon.
Database Search Examples
Here are some examples of common syntax requirements:
String Querying (Character Fields) Exact Search CHARACTERFIELD='value'
Anywhere in the field
'value'$CHARACTERFIELD
Searching from the left
left(CHARACTERFIELD,number of characters)='value'
Searching from the right
right(ALLTRIM(CHARACTERFIELD),number of characters)='value'
Removing all trailing spaces
ALLTRIM(CHARACTERFIELD)='value'
Searching for empty fields
EMPTY(CHARACTERFIELD)
Numeric Searching Exact Search NUMERICFIELD=value
Greater than a certain value
NUMERICFIELD>value
Less than a certain value
NUMERICFIELD<value
Between two values
NUMERICFIELD>value1.AND. NUMERICFIELD<value2
Date Searching Exact Search
DATEFIELD=CTOD('date value')
Before a certain date
DATEFIELD<CTOD('date value')
After a certain date
DATEFIELD>CTOD('date value')
Between two dates
DATEFIELD>CTOD('date value1').AND. DATEFIELD<CTOD('date value2')
Search by month
Month(DATEFIELD)=value
Search by year
Year(DATEFIELD)=value
Executing (Running) the Query
From the Search Database dialog, highlight the query you wish to run and select the
Execute Query button.
The results of the query are displayed in table form, with the overlay and query details shown in the top bar of the window.
Notice it tells you the number of records found for your database search.
You can also scroll around the list of queried records by using the vertical and horizontal scrollbars and the navigation buttons on the grid.
What you can do with the Results
Centre
The Centre button allows you to centre the map window on the record you selected from the table list. First select the record, then click on Centre to relocate the map, then Display to return control to the map window.
Display
The Display button converts the selected records to a display list. The map will then only display the selected records. You can only Export or Report on the selected records after you have clicked on the Display button.
Edit
You can perform record editing directly on the record display grid. Highlight the record you are interested in and click on the Edit button. You will then be able to edit that row.
Save the change by moving to another row or by clicking Save (green tick) which will have become enabled.
Modify
The Modify button allows you to change one of the fields with a new value or expression. This function could be used to change a road name for example.
See the Chapter 3 ‘Update Query’ for further details.
Filter
You can refine your selection using the Filter functions.
A filter will be built which can comprise multiple conditions. Simply click on the button to add a query into the filter.
There are three main elements - the fieldname, a function/operator and a value, and these work in much the same way as the query you built in the original database query.
Select the field you wish to examine through the filter, and then use the other elements to define your filter.
For example you may wish to select records which have been updated recently, so you would select UPDDATE, ‘is greater than’, and a date.
To make this sort of filter easier there are some ready-made functions available to select from, such as yesterday or last seven days.
Depending on the type of field there are drop down tools to help you if you click on the drop- down arrow.
If you select a numerical field, a calculator will be displayed and if you select a date field you will see a calendar.
You can build more complex filters by combining queries.
Click on Filter or the [...] boxes and select the Add Group or Add Filter menu items to expand the tree.
This allows you for instance to examine records which have been updated in a certain timeframe and also relate to specific field contents.
Calculate
If the database you are searching on contains a numerical field then a Calculate function is available for this field. Click anywhere in the numerical field column and a Calculate button is revealed. Clicking on the Calculate button displays simple Sum, Average, Minimum and Maximum values for that particular column.
View Memo
If the database you are searching on contains a memo field there will be a column with the entry [MEMO] listed for each record. To view the information contained in this Memo field double-click in the entry for the required record. A new window will be presented showing this information. Press the [Close] button to return to the previous window.
Zoom | Zoom Extents | Zoom Query Extents
The Zoom Query Extents menu item in GGP will zoom in or out until the full extent of the query is visible. This option is particularly useful if the overlay was not set up with a gazetteer. The map window zooms to the minimum area required to show all records in the query.
To Delete the Records determined by a Query
The Search|Delete menu item in GGP deletes the query records from the Foreground overlay. Database records with no graphics are also deleted. The table may have to be Packed afterwards (in Setup Application).
To Clear a Query
To clear an active database query, Search|Clear All Queries de-activates all active database queries and deletes the result set file.
3. An Update Query
You may need to modify a set of records in an overlay by replacing or editing the value or expression in one of the fields, and do so for all the records. Examples of this would be to change a street name in the ‘Thorofare’ field of Addresspoint or Local Gazetteer, replace a person’s name in an ‘Officer Responsible’ field, or increase values in a numeric field by a set amount.
After running a Database Query (as described in Chapter 2) a Modify button is displayed.
Click on this button, and select the field you wish to modify from the list of fields.
Click OK.
The normal Database Query form will be presented.
Remove the field entry in the query string and type in the replacement expression or value. Test your string by clicking on the Test Syntax button (remember single quote marks for a character field).
Click OK and you are given the choice of updating the current record or all records in the query. The result is shown applied to the currently selected record for corroboration.
Examples
- Update Street Name:
‘London Road’ has been renamed ‘High Street’ and the AddressPoint database needs to be updated:
- Bring up a map and add the AddressPoint overlay in the foreground
- Select Search|Database and run a query where the search expression is THOROFARE=’London Road’
- From the table results, click on Modify.
- In the Select Fields window, select the THOROFARE field
- Clear the Query String entry completely and type ‘High Street’. The field must contain just the replacement value, so replace the whole line THOROFARE=’Cornwall Close’ with High Street (not by changing it to read THOROFARE=’High Street’). Click OK.
- Select All Records
2. Update Numerical Field:
A numeric field called VALUE is to be increased by 100 for each selected record.
- Follow the approach shown in Example 1 above
- After selecting the field to modify and clearing the Query String box, type the expression: VALUE+100
This function allows you to use GGP like a calculator. It could be used for instance to calculate the cost of maintenance based on area. Remember you can run a query first to select a certain group of records, then amend the figures in relation to that set of data.
4. Sharing and Managing the Queries
When overlays are created it is possible to define a set of queries for them. These queries are initially unique to each user. However, it is also possible to attach them to the overlay, making them overlay-specific and not unique to the user. This allows other users who have access to the overlay to access the same queries without having to define them first.
When several queries have been created, you will see a list of queries in the Database Query dialogue in respect of the selected overlay. The list shows all the overlays which you as a user can apply to the overlay and will contain your personal queries for the overlay, plus overall-specific queries created by anyone.
The key to both types of query is that you must have the correct overlay set to the foreground first, in order to see the relevant list of available queries. You cannot think of a query and then find it in some overall list - you must decide on the overlay first.
Personal Queries and Overlay Queries
By default a new query which you create will be a Personal query.
To change the setting, select Overlay from the Ownership menu button.
The query will then become an overlay query and available for anyone who can use the overlay. The Personal query will be removed in the process. You will be able to see which is which as the ownership is denoted by the small icons on the list.
Conversely, if you change the current setting of a selected saved query from Overlay to Personal in the Database Query dialogue, this does not remove the overlay query. Instead it creates a Personal copy.
Query Categories
The category is purely descriptive to allow grouping of queries within an overlay, for your own or possibly departmental purposes. The category setting does not affect where queries are saved, and relates specifically to the overlay. If you use the same category name in a different overlay, the two will not be related in any way.
You can create a category while you are creating a query, or you can use the Create Category and Delete Category buttons independently from the toolbar.
These categories will then be available for selection in order to execute or enable multiple queries. You can therefore allow filtering by category or activate/deactivate all queries in a category.
Once you have a list of several existing queries and
categories, you can use the left-hand pane of the display to select which categories to display in the list.
Drag-and-drop functions are also available to assign queries to Categories. You can also set categories on or off by right button clicking on the category.
Managing Queries
Most functions can be controlled directly from the Database Query toolbar.
From here you can create or delete queries, categorise them, turn them on or off, and control ownership in terms of personal or overlay.
If you need several queries which are distinct but similar, you can Copy and Edit a query, then Save it with a different Description and Category, and so build up a list of available queries to pick from.
You can change the sequence of the list with the up/down arrows.
You can multiple-select queries using the CTRL key, for instance if changing ownership.
You must use the Save button to save the actual query.
The other options relate to the save states of the query, for example to save to the script or as a personal overlay query, or neither and use it as personal for the session only.
For the Database Query which we have looked at so far, only Execute is available to run the query.
The Activate options apply to Display Queries which we will look at in the next Chapter The small icons on each line indicate the status of each query.
The first ‘Execute’ column shows the order in the list.
The second ‘Owner’ column shows whether the query is currently set to Personal or Overlay.
The third column indicates the type of query (Database or Display) The fourth ‘Activate’ column shows which display queries are activated.
Unsurprisingly there are more controls available about how display queries should be shown on the map, and we will look at these next.
Copying Queries
From GGP5 there is a function available in the Tools menu of Setup Application's main Details page. Under Manage Queries you can select Copy Overlay Queries to...
This function allows you to clone queries between layers as long as both layers have the same fields referenced by the queries.
This functionality means you can recreate different variations of layers very easily.
Select the destination overlays from the list using the normal overlay selection arrows.
5. Display Queries
The intention here is to draw attention to selected data by amending the display characteristics of the data you have isolated using your query.
Start with Search|Database again, but this time select Add and Display Query.
Enter a description and click on the Build Query button to take you to the query design dialog you saw before.
Build your query as previously by entering a string containing a field, a function and a value. Test the Syntax and then click OK.
You can select a Category, and decide what level of Visibility you would like to attach to the query ie whether it will be personal or go with the overlay.
At the bottom of the window there is an extra option available. If you wish the display to change only at particular scales, you can enter scale thresholds. The thresholds will then also be displayed on the list of stored queries.
Under Rendering Style (Symbolizers) you can set the graphic attributes for each geometry type which you wish to use to identify the results of the query on the map. Obviously you will wish to choose attributes which are distinct from the usual ones for this overlay.
Until you define them here the default styles for the overlay will be shown.
You will also see whether any geometry type has been disabled, but you can’t disable them here. Any which are already disabled you will see greyed out and you can't use that type in the query.
So unless you need the Display Label option, the query is now complete.
Display Labels
Display Queries can also be used to display a label against the object you want to show, using the Display Label option.
These provide a drop down a list of available field names from the foreground overlay. By picking one of the fields, GGP will then display the contents of that field as a label on the map, generally alongside the symbol for Point overlays and at polygon centroids for Area overlays (but see Display Position below).
A typical example of this is to display a reference number alongside the symbol or within the polygon.
In the example below we have selected the database field ‘Reference' and will create labels in purple.
The text attribute dialog box is shown which enables you to select the font, size and colour of the label to be displayed.
All the usual styles and size/scale definitions can be applied, including text boxes, halos and borders to emphasise the label.
Label Display Position
Labels are positioned alongside symbols for Point overlays and at polygon centroids for Area overlays. However, if a record contains both polygon and symbol graphics then the position of the text will depend on the number and order of graphics. In an Area overlay with both polygons and symbols, as in Tree Preservation Orders for instance, there are a few cases to consider:
By default –
| Just a symbol in a geometry | displays the field against the symbol |
| Many symbols in a geometry collection | displays the same value against each symbol |
| Just a polygon in a geometry | displays the field at the centroid position |
| Many polygons in a geometry collection | displays the same value at each centroid position |
| Symbol followed by a polygon | displays the field for both symbol and polygon |
| Polygon followed by a symbol | displays the field against the symbol |
| Multiples of above case | displays the same field against each symbol |
Repositioning the displayed text
When undertaking Display Queries, any text label drawn from the contents of a database field will be displayed at a default position based on the type of graphic feature. Sometimes this might conflict with text features on the base map or with other graphic features displayed, or be position within a hole in a polygon feature.
There are several ways of changing this location.
Firstly you can amend the anchor point of the text label using the Text Attributes dialogue shown above. This will move the text so that the text is placed in a different position relative to the placement point.
The cursor is by default attached to the bottom left corner of the text label. This ‘anchor point’ can be amended by selecting a different position using the radio buttons on the text dialogue form.
Note that when you click a position button, you are selecting the position of the anchor point relative to the text, not the other way round – see the preview in the Anchor Point section of the dialogue.
Alternatively, you can relocate the position of the text display to a unique position by changing the geographic seed point away from its default co-ordinates.
Use Edit Graphics to select the feature, and using the right button pop-up menu, select
Change geocoded seed point.
The current seed point will be displayed (as a point in a small circle). Simply move the cursor to the intended position of the seed point and click.
You can continue in edit mode to select another feature, or exit.
Saving and Activating the Display Query
Once you have specified all the details as required, click OK to save the query. When you click OK, the new display query will be added to the query list.
Note the map display will not yet have been changed.
The new query can be identified as a display query by the small icon.
The thresholds and graphic attributes you selected will also be shown on the query line if you scroll across
Highlight the display query you wish to run and click the Activate button to turn on the display query.
You will also see that the query is now shown as activated in the query list.
You can also activate and deactivate display queries directly on the list. Select Save to store the query with its current settings.
Click Close on the Database Query dialogue to view the results of the Display Query on the map.
Above are two examples, the first without the query enabled, and the second with the display query active (and Display Non-Selected Records ticked).
Display Non Selected Records
Setting this option means that as well as the query results being displayed in the attributes you select, the other records which do not match the data query will be displayed with their normal attributes. If unchecked, non-matching records will not be displayed at all.
Display Query in Key
If the key is displayed it will contain details of the display query (and non-selected) records for the overlay.
Scale Thresholds
When the Display Query is activated, the scale thresholds will control when the display change is implemented.
For instance in the following queries (a) the query has no effect when it is below a minimum threshold and (b) is effective when the display scale is within the range of thresholds set for the query.
(a) (b)
Highlight Selected Records
Highlight Selected Records gives the selected records a different highlight colour, while still displaying the records not in the query.
To Save the Query
You must explicitly click on the toolbar Save button to confirm any changes to overlay queries and persist these to the next session. There are options available to save to the script or as a personal overlay query, or neither and use it as personal for the session only.
To Copy or Edit a Query
Highlight an existing query and then click Edit or Copy buttons to amend or create an another separate version.
Clear a Query
To clear an active Display Query, launch the Query dialogue again (you can use CTRL Q for quick access) and De-activate the Display Query.
6. Spatial Queries
A Spatial query is one based not on a logical equation, as you might construct with
Search|Database, but one created by first drawing a search boundary on the basemap.
For example, you might wish to calculate an evacuation zone around a particular site, so drawing a circle over the address point overlay would allow you to decide who needed to be evacuated. Perhaps you wish to see who needs to be notified about a planning application, in which case an appropriate polygon on the address point overlay could be drawn.
To enable the search and query options the overlay needs to be selected as the foreground overlay. If you want to perform a combined database query and spatial query, apply the database search first and display the result on the map. This will limit the records on the map to those complying with the first query. Then perform the spatial query to limit the results geographically.
There are several different ways in which you can run a spatial search. We will look at a few in this chapter and some more in the later chapters, for instance where some types of analysis uses background overlays to constrain the search or to place the results.
Defining the Search Area
Search|Draw Circle
Draw out a circle on the map. As you are drawing, the radius of the circle is displayed in the status bar. You can draw more than one circle to search on at any one time, so you could find things within a radius of say two points.
Search|Draw Polygon
Draw out a polygon. All the menu options are available for drawing a search polygon like snapping, undo and scroll. You can draw more than one polygon to search on at any one time.
Search|Draw Buffer
Snap to a feature and draw a buffer. You can draw more than one buffer to search on at any one time. This may typically be used to snap to a road centre line and select all the addresses within 20m of the road centre line.
You can search on a combination of the above in any single query.
Running the Query
After drawing a Search Circle, Search Polygon or a Search Buffer on the map, you will see that the Run Query menu option is now enabled in the Search menu.
Select Search|Run Query and a dialogue box will appear called ‘Begin Spatial Search’. This dialogue box enables you to specify in detail how the query should run, before actually initiating the spatial search.
Click on Begin to run the query.
You will see a results box displayed with a summary of what has been found by the Spatial Search.
Let’s examine how the options in the previous dialogue would control the query.
Overlays to Search
This defines which overlays the spatial search will check.
| All displayed overlays | All the overlays selected in Overlay, including the Foreground overlay |
| Foreground | Just the Foreground overlay (name highlighted) |
| Select From List | Choose from the list of currently added overlays |
Search Operators
This defines how the search will work for instance where you have drawn more than one search object
| And | This only applies if you have multiple queries (e.g. two circles or a circle and a polygon). Only records which are contained in (or overlap) all the query objects will be selected. The query objects must overlap for this search operator to take effect. An example of this is a two-polygon query where information is in the first polygon AND the second polygon, i.e. theoverlapping region. |
| Or |
This only applies if you have multiple queries (e.g. two polygons or a polygon and a buffer). Records which are contained in (or overlap) any of the query objects will be selected. An example of this is a two-circle query where information is in the first circle OR the second circle. |
| Exclude | If this box is checked, the selected list is inverted, i.e. all the records that would otherwise not be selected are selected |
‘Exclude’ is a powerful tool as it can be used to split overlay data to show every feature inside or outside a defined area. By default, with the Exclude box unchecked, the search will be for features inside the search area. The ‘Match Record If..’ options are extensions to this to further define what should happen at the boundaries of the search area.
Match Record If..
This defines very precise settings for running the search
| One Geometry Inside |
This only applies if you have multiple geometries for one database record. If any geometry of that record is contained in (or overlaps) the query object, the record will be selected. |
| All Geometries Inside |
This alternative only applies if you have multiple geometries for one database record. The record will only be selected if all its geometries are contained in (or overlap) the query object. |
| Geometries Overlap | If a polyline or polygon crosses the boundary of the query object, the record will only be selected if 'Geometries Overlap' is checked. In the case of symbols, if the centre of the symbol is outside the boundary of the query object but the symbol overlaps the boundary, the record will only be selected if the Geometries Overlap' is checked.If this is unchecked only those geometries completely inside the query object will be selected. |
| Geometries Touch | This only applies to overlays defined as type Area or Link. If the polyline or polygon is outside but part of it just touches the boundary of the query object, the record will only be selected if'Geometries Touch' is checked. |
Output Options
View Results
Checking this option will cause GGP to output all the records from the foreground overlay (and from all the active background overlays if ‘All displayed overlays’ is checked) into a temporary file QRYDATA.TMP in the Home directory.
By default, the View Results and Send List options are disabled, and you should set the default text editor, typically Notepad as described below, so that the results will be supplied in a tabular format for viewing and printing when the query has completed.
You can set the default text editor by Choosing Options|General and clicking on the [Support Programs] button, or just for the current script by choosing Options|Current Script Settings|Support Programs. Expand the ‘General’ group if necessary, and select the ‘Editor Program Path’ item.
You can browse to select another program if you do not wish to use Notepad. This is useful in Search|Run Query [View Results] because the result file QRYDATA.TMP can be too big for NotePad, or if you want the information directly in another word processor. Remember that the selected program should be available for all users of the overlay. If you select a word processor such as Microsoft Word, you can then run a macro which formats the results for you to give an enhanced presentation.
A typical application for this feature is to generate a site constraints list or site history report for planning application processing.
Show Empty Overlays
Checking this option ensures that a reference is written to the QYRDATA.TMP file for each of the selected overlays currently displayed, even if the overlay has no records that match the current query. If the overlay has no records that match the current query, only the field names are written to the QYRDATA.TMP file.
Processing Lists
As described above, the View Results checkbox on Search|Run Query provides a means of viewing a formatted set of spatially selected records in a text editor (NotePad by default).
However for linked third party applications which want to process such records programmatically, a Send List checkbox provides an alternative. It operates in exactly the same fashion as the View Results function except that the output is formatted differently. Instead of running a text editor, a small background program (e.g. in Visual Basic or Delphi - provided by the supplier of the linked application) can be run automatically to pass the list to the linked application.
Examples:
For consultation processing:
You would normally select AddressPoint (or another Property based overlay) to the foreground. Define the search area, eg a circle for neighbours within a given distance of a site. In Run Query, check on Foreground Overlay [Address Point or other as appropriate], check on Send List and click Begin. The list file will then just contain address records from the foreground overlay.
For constraint processing:
Switch on all background overlays that relate to constraint processing. In Run Query, select ‘All displayed overlays’ and check on Send List. Optionally check on Show Empty overlays (if you want overlays with no records within your geographical area included in the list) and click Begin. The list file will then contain all background overlay records.
Adjusting the Selection
Note you can add to the search results manually if you wish to deliberately add other specific addresses to the list. Use <Shift> Right-click to select additional graphic features. For instance you may wish to include specific addresses in a consultation list. You can also remove specific addresses from the list, such as the address at the centre of the search, perhaps the applicant’s address. Again <SHIFT> Right-click on the feature to be removed. You can repeat these as many times as you wish in order to achieve the list you need.
Enabling the function
The Send List checkbox is enabled by specifying a Send List Program in the Support Programs dialog (See ‘View Results’ above).
At run-time, the support program is executed and passed the full pathname of the list file as a command line. If the background program cannot read command line arguments, the list file is always called QRYDATA.TMP and is always located in the Home directory. Once the background program finishes, control returns to GGP. GGP then deletes the list file.
Send List can be set up for an XML file eg ‘Notepad WriteQueryFile=Output.XML’ See example files below.
List file format
| Contents of Text file | Meaning: |
| [Green Belt Areas] | Overlay 1 name |
| "Alpha1","Number","Alpha2" | Field names of Overlay 1 |
| "ABC",345,"XYZ" | Record 1 |
| "EFG",234,"UVW" | Record 2 etc |
| Blank line to separate overlays | |
| [Conservation Areas] | Overlay 2 name |
| "TYPE","LOCATION","DATE" | Field names of Overlay 2 |
| Blank line here signifies this overlay has no records | |
| [SSSI] etc | Overlay 3 name, etc |
XML File
| Contents of XML file | Comments - not part of text file |
| <?xml version="1.0" ?> | |
| <OUTPUT | |
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
| xsi:noNamespaceSchemaLocation="OUTPUT.XSD"> | (Schema name) |
| <Green_belt> | (Start of Overlay 1 ) |
| <row> | (Beginning of 1st record) |
| <NAME>Greenbelt Area</NAME> | field name 1 + data |
| <DATE>12/07/2002</DATE> | field name 2 + data |
| <APGRECNO>1</APGRECNO> | field name 3 + data |
| </row> | (End of 1st record) |
| </Green_belt> | (Finish of Overlay 1) |
| <Conservation_Areas> | (Start of Overlay 2 ) |
| <row> | (Beginning of 1st record) |
| <TYPE>Designated</TYPE> | field name 1 + data |
| <NAME>Hospital</NAME> | field name 2 + data |
| <ARTICLE4>N</ARTICLE4> | field name 3 + data |
| <AMENDATE>Feb 2000</AMENDATE> | field name 4 + data |
| <SSCALE>Landline</SSCALE> | field name 5 + data |
| <APGRECNO>38</APGRECNO> | field name 6 + data |
| </row> | (End of 1st record) |
| </Conservation_Areas> | (Finish of Overlay 2 ) |
| <Chemical_Stores> | (Start of Overlay 3 ) |
| <row> | (Beginning of 1st record) |
| <DESC>Explosive Store 1</DESC> | field name 1 + data |
| <FIELD002>AMMONIUM NITRATE FERTILISER</FIELD002> | field name 2 + data |
| <FIELD003>HSE Ref: xxx/93</FIELD003> | field name 3 + data |
| <APGRECNO>5</APGRECNO> | field name 4 + data |
| </row> | (End of 1st record) |
| <row> | (Beginning of 2nd record) |
| <DESC>Explosive Store 2</DESC> | field name 1 + data |
| <FIELD002>AMMONIUM NITRATE FERTILISER</FIELD002> | field name 2 + data |
| <FIELD003>HSE Ref: xxx/93</FIELD003> | field name 3 + data |
| <APGRECNO>6</APGRECNO> | field name 4 + data |
| </row> | (End of 2nd record) |
| </Chemical_Stores> | (Finish of Overlay 3 |
| </OUTPUT> | (End of File) |
Spatial Code
An extra field SPATIALCDE will be output as the last field in the QRYDATA.TMP file if the ‘Include Spatial Code’ checkbox in the Support Programs ‘SendList Program Path’ panel has been checked.
The spatial code is based on the spatial intersection relationship between the spatial search object and the graphic feature of the overlay record.
This numeric reference can then be used to differentiate records for the purposes of the supporting application.
Possible values for SPATIALCDE are:
| 1 | OUTSIDE | Feature is distinct and completely outside the search boundary |
| 2 | TOUCHING | One or more lines of the feature coincide with those of the search boundary but the feature is otherwise outside the search area. |
| 4 | OVERLAPPING | One or more lines of the feature cross those of the search boundary ( ie for polygons, part of the feature forms part of the search area, and may or may not share boundaries which touch) |
| 8 | CONTAINED | Feature completely encloses the search area (and may or may not share boundaries which touch) |
| 16 | INSIDE | Feature lies completely inside the search area (and may or may not share boundaries which touch) |
| 32 | EQUAL | Feature is exactly the same as the search boundary (eg derived from a search area defined by snapping to an entire polygon) |
Examples: (The search area is the circle):
Fix Spatial Properties
This checkbox is used to disable the changing of many of the options that are available, i.e. once checked, most of the other checkboxes cannot be altered. The state of this checkbox will be saved if you save your current script.
7. Working with Multiple Overlays
We have now looked at the different components available for searching. Now we will look at more complex situations.
Search against a Background Overlay
In Chapter 6 we looked at defining the search area by drawing an object like a circle. Now we will use alternative methods of selecting the spatial search areas.
The Search|Select Search Overlay menu item allows you to search the Foreground overlay but restrict the search to polygons in one of your background Area type overlays. You can select either a Point or Area type overlay as the Foreground overlay but there must be an Area type overlay in the background.
With this function you are carrying out spatial analysis by using a background Area overlay to define your spatial extents. In other words you are searching in Foreground overlay for data which is located within a collection of search polygons that already exist as features in Background overlay.
Note that background overlays can be selected for these purposes even if they have been set as hidden from normal view using Options|Overlays.
Set the target overlay to the Foreground then go to Search|Select Search Overlay to select the background overlay for the search areas.
Selecting a search overlay and clicking on OK automatically enables Run Query and disables other types of spatial query on the foreground overlay.
You can broaden the search area by defining a buffer around the selected features. This will create buffers around point features in the Area overlay as well as polygons, so extending the search options. To do this check the Construct Buffers box and enter the offset distance.
Select Run Query and look at the dialogue box. New ‘Spatial Overlay Options’ are now available.
Select the required search and match options and click Begin to run the query.
This query will perform in exactly the same way as the simple search where you draw the search extents yourself, but this time will utilise the background features and see where they intersect with the foreground feature.
Restricting the Background Overlay search
By default the search will run based on all the features in the background overlay, subject to the controls you have added.
However you can restrict that by working on the background overlay first.
You could run a database query on the background data which will restrict the search polygons to those meeting your database criteria, eg just features in a given parish.
You could run a spatial query on the background features, eg just features within a circle of a 2km radius.
Make sure you do this before bringing the correct overlay to the foreground and selecting Search|Select Search Overlay to select the background overlay which has the query in place.
The Search|Select Search Overlay function can also be utilised to update a set of records (see below) or to count records for hotspot analysis (which we will cover in chapter 9).
Updating data between Overlays
GGP can select a background overlay and then update a foreground overlay field with a field value based on data taken from a background overlay field.
For example, using this feature we can update the field ‘District’ in the Street Gazetteer (a foreground overlay) with the field value of ‘Ward Name’ (from Ward, the background area overlay).
Steps Required
To update a number of records with a background area overlay field name, you would need to do the following:
Set the overlay you want to update to the Foreground, as this is the one you are amending. Add the background overlay whose field value will update the Foreground overlay (using
Options|Overlays).
Choose Search|Select Search Overlay.
Select the background area overlay you are going to use.
Select Run Query.
Now you have to state which field from the background overlay is to be used to update which field in the foreground overlay.
Make sure the Update checkbox is checked and click on the Change button to the right of it.
Click on the field from the background overlay (left hand list) that will be used for the update, click on the field in the foreground overlay to be updated (right hand pane).
The fields and direction of update will be shown at the base of the box. If there are any potential problems such as field widths this will be indicated.
The proposed change will also be summarised in red highlights at the foot of the Run Query dialogue box, for additional confirmation.
When absolutely certain, click OK.
Click on Begin to run the search and update process. A confirmation message will be displayed.
Note there is also an element of spatial comparison in the advanced polygon editing functions, whereby you can construct polygons derived from existing objects selected spatially from a background layer. However this is covered in the Intermediate Drawing Course and we will not be repeating that here.
8. Spatial Analysis - Thematic Queries
A thematic map (the most common form being a Choropleth map, which is what we mean here) is simply a map made to reflect a particular theme about a geographic area using different colours or symbols. The areas or symbols on the thematic map will be coloured or shaded according to the values within the data, so that you can quickly observe the locations of for instance the highest or lowest values, or a distribution pattern in terms of values.
Typically you might display statistical data by census areas etc, so it is worth thinking ahead about the areas you may wish to report on, such as parishes, wards, or postcodes, and then setting up an overlay with appropriate boundary polygons to which you can attach the data.
You will always be working on the current foreground overlay. You must ensure that the data layer from which you wish to create the thematic map is in the foreground. Remember that at this stage you will be working with one overlay - the one containing the data - and displaying its data thematically. So you will need a relevant structure within the overlay itself.
In GGP, select Search | Thematic mapping.
A list of thematic queries related to the selected overlay will be displayed. Initially of course this will be empty.
Creating a new thematic map
If you select Add on the Thematic Queries list, you will be able to set up a display query and associated symbology for the new thematic map.
Enter a Description for the new thematic map. This description will be shown as a heading in the Key. The default is ‘New Thematic Map’. If you are going to create more than one map, it is recommended you use unique names for each thematic map.
Select the Field to report on from the dropdown list. This list is created automatically from the foreground layer. You must select a field as the query will be built from the values in this field.
Now let’s look at Number of Bands and Data Classification.
Select the number of bands to create using the up down arrows. For instance, if you are looking at a numerical field and select four bands, the query could divide the data into four equal levels and the display could distinguish features in 25% bands (0-25%, 26-50% etc)
To divide the records up, you can choose between ‘Equal Interval’ and ‘Quantile Classification’.
'Equal bands' takes the maximum and minimum values and divides the intervening items into bands based on a division of that intervening range (eg if lowest item is 100 and highest item is 500, then 4 equal bands will give 100-199, 200-299, etc, regardless of the number of objects in each band, so you could find you have 90% of the data in the top band). In other words you are dividing strictly on values, regardless of the number of items in each band.
‘Quantile Classification’ works on the number (quantity) of items found, and divides that number into, say, 4 quartile bands or 5 quintile bands. So each colour will have the same number of items in it, and the lowest band might have values of 100 to 300 and the top band values from 450 to 500, depending on the spread of the data. In other words you are dividing up the cases equally but the values may not be spread evenly.
Here are examples of the two approaches, derived from the same data.
|
Example 1 – with 4 Equal Bands
|
Example 2 - with 3 quantile divisions
|
The ‘Band Description’ is used as a sub heading in the key.
As you can see from the examples, the query when run will set new colours for each band in the display.
The Polyline attributes and Symbol attributes on the dialogue box show the standard overlay attributes by default, with additional colours suggested for the bands.
Click on the Edit buttons if you wish to define a new starting style for the first band and a more meaningful colour scheme. Each band can subsequently be edited if you wish a specific pattern, symbol or colour to represent a particular band.
If the data you are interested in is Symbol data only then you can ignore the Line Style and Fill Style. If the data you are interested in is Line or Polygon data, then you can ignore the Symbol Attributes. For overlays that contain
both Area and Point data, then Point records that match the criteria will be displayed to match the polygon records in the same band.
To have a smooth colour transition from one end of the range to the other, tick the Use Gradient checkbox.
This will create a transition from the colour you select in the Start box to the colour you select in the End box. The number of colour grades actually used will of course depend on the number of bands you have selected.
Click on the Change button to amend either or both of these from the default red and yellow.
You may sometimes like ‘traffic light’ colours, or hot to cold, or dark to light, depending on what you wish to demonstrate.
You can combine gradient colours with amended fill or symbol styles, as in this example.
Click on the Edit button for the geometry type if you wish to define a new style for the object The attribute dialogue windows will be familiar to you.
You can always edit the query later if you wish to show a particular colour for a particular band on the results so this stands out more.
On the attribute dialog there is also a ‘No Polygon’ (or equivalent) checkbox. If you tick this, you can turn off that geometry type, so for example the query will just look at the points in the overlay and the other types will not be displayed when the query is active. Again this can be used to better highlight whatever you are trying to demonstrate.
If you are using an overlay where some types are already disabled, the thematic query dialog will not give you access to these at all, as shown in this example.
37 Once you have completed the form press OK. The new query will have been added to the list.
To enable the query and view the thematic map, check the box next to the map title and press OK.
The application will generate a series of Theme Items based on your choices and the map will re-display showing the graphics in the symbology applied by the query.
If the field chosen is a numeric field, then the application will create a maximum number of thematic items as specified. If there are fewer values than the chosen number of bands, the application will create as many as is possible.
A thematic map can also be based on non-numeric data. The application will first check to see if the data is suitable for a thematic map. If the data contains more than 20 unique values in a text field, then the selected field can’t be used, and you will have to select a different field for the thematic map.
To see the bands in the key, press CTRL K or check the box in Options|Current Script Settings|Display to turn on the Key in the normal way (See below and Chapter 10)
Managing Thematic Queries
To enable all the other functions in the Thematic Queries dialogue, you must disable (uncheck) the thematic query in the list
In the same way as other queries, you can control ownership of the thematic query by attaching it to the overlay or keeping it as a personal query.
Some of the other functions will only be enabled if you have taken the query into personal ownership.
If you wish to have several thematic queries which are very similar, you can Copy the query and give it a new description. You can then change the bands and colours, but not the source field. If you need to study a different field you will have to create a new query.
If you find your list of queries is getting complex, you can use the Rename function to clarify the list without affecting the queries.
Editing an existing thematic map
If you select Edit from the Thematic Queries list, you will be able to amend the display query and the associated symbology for an existing thematic map. This is also an easy way of checking the value ranges and attributes styles being applied to the map.
You can only use the edit button if the map in question is unchecked (disabled).
Click on the query to highlight it (but do not click the checkbox as this re-enables the query).
Generally, the equal bandings calculated automatically will be the most appropriate. However, you can alter the numeric values if you wish to show unequal bands or to exclude bands where there are no issues to report.
It is recommended that you practice setting different targets for your thematic query and see how you can amend the display.
Having calculated a thematic map, you may choose not to display one of the bands as it is not relevant to your presentation, or because you just wish to show the best and worse cases. You can delete a band completely by highlighting it and pressing the Delete key.
You may wish to ‘fine tune’ the boundaries of the bands. You can also change the colours and symbols for the selected query.
To amend any contents, double click in the cell.
Here are two examples, the first with a random selection of attribute colours, and the second with a selected gradation from red to yellow.
In addition we have chosen to highlight one band in blue, by selecting that one line and changing its attributes, so we can draw specific attention to it
Configuring the Key
For numeric queries, you can choose to show the numeric range or the descriptive bands in the key, or both, depending on whether you have checked the box ‘Append band or value to description’.
This works as follows:
| Unchecked, the values are not appended to the description | Checked, the values are appended to the description |
To have just the values, leave the description fields blank, and then check the Append box |
Note that the key will also reflect whether you have turned off any geometry types in the query or whether any have been disabled for the overlay generally.
9. Spatial Analysis - Hotspot and Cluster Analysis
There are three types of querying and reporting covered here.
- Cluster Analysis looks for concentration patterns by counting numbers of points within grid squares and tabulating the results.
- Aggregation to Points reports coincidence by representing within the symbology the number of occurrences at each location. (This is also known as ‘Proportional Symbol thematic mapping’)
- Aggregation to Polygons is a thematic mapping approach where one set of data is aggregated by reference to the areas described in another.
These methods allow you to calculate, summarise, report and present spatial data by analysing distribution.
They do not provide statistical analysis such as modelling, dispersion, deviation, or the question of probabilities.
Cluster Analysis
The identification of concentrations of the same type of record across a district or area can help focus projects and planning initiatives. The function is typically used to accumulate statistical point based data into a presentation format. Crime analysis and Road Traffic Accident analysis are examples. It can also be used as a means of aggregating property based statistics into a format unlikely to contravene the Data Protection Act.
The results are reported on the basis of record counts within square grid cells (identified by co-ordinates). Cluster analysis can be used in conjunction with the scaling and thematic methods described in previous chapters.
Select the required overlay (Accident statistics, for example) to the foreground. If you want a description for each cluster matched to the nearest road (for example OSCAR data), make sure you select the appropriate road overlay in the background. It is recommended that you save these overlay selections in a suitably named script for convenient repetitive use.
The process groups records in the foreground overlay into clusters and writes out cluster records into a table called CLUSTER.DBF in the Export folder. The Cluster layer is a scratch layer which is updated each time the cluster analysis process is run. It can use existing thematic queries or it can create a new one. GGP automatically formats a report using the default report generator, normally now Fast Report.
To perform the analysis, on the Search Menu select the Cluster Analysis option.
You will see this dialog:
Cell Size
Specifies the size in metres of each square cell in which to construct the cluster.
Tolerance
Specifies how much larger the square search cell should be to add to the cluster. For example, if you have a 50-metre cell size and a 50-metre tolerance, records will be clustered in effect from a 100-metre search cell.
Min Cluster Count
Cells with a cluster count of less than 'Min Cluster Count' will not be included in the results and therefore not reported.
The Description Field Options allow for the addition of information from a selected field in the foreground overlay. Alternatively, the Description Field may be taken from a field in a record in another (background) overlay nearest to each cluster. An example would be to include the STREET_NAM field in OSCAR data to find the road or street closest to the identified cluster.
Overlay Name
This is the overlay from which the Description field in the cluster table will be extracted.
Use the Change button to select from the current background overlays.
Field Name
This is the field which will be copied into the Description field of the Cluster table. A field must be selected.
Use the Change button to select a field.
When the above variables have been set as required, click OK on the main Cluster Analysis dialog to start the analysis. Press the [Esc] key at any point to cancel the process.
The Cluster Analysis process will group records from the foreground overlay into clusters and write out cluster records into a table (CLUSTER.DBF) in the Export directory. The records are pre-sorted in the table in descending cluster count order. The cluster table includes Eastings and Northings, Cluster Count and a Description.
When the table is written, the GGP Report Generator is automatically started with a standard (user configurable) report.
Aggregation to a Point
The scaling of co-incident symbols in Point overlays is provided in GGP. Where there are multiple occurrences of the same type of record at the same location, the symbol can be enlarged by a specified amount. A simple example of this is to be able to easily identify multiple occupancy (i.e. flats or maisonettes, and blocks of flats) using the AddressPoint overlay. Other uses of this function are to graphically represent the presence of more than one record of a crime, incident or complaint at the same location.
The symbol scaling operates independently of any Database or Display Queries. You do not build the scaling as part of any other query - rather you simply select the scaling you want GGP to operate, either on its own, or in addition to any Display or Database Query.
Note that records are considered to be at the same location if the co-ordinates are the same when rounded to the nearest metre.
Use Search | Database to display the Database Query form. Select Range Query under the Add Query button.
You can then set the enlargement factor.
The Set Ranges dialogue box enables you to Count 'From' (>= Greater than or equal to) and 'To' (< less than) so that numbers of records at the same location within that range are scaled in size by the specified factor.
You can also define a Category for the query.
To specify a range without an upper limit you can leave the 'And <' range blank in which case all records greater than or equal to the 'From' count will be scaled by the factor.
If you wish to show single incidences you must have a range that includes 1 and is less than 2
To display the scaled symbols, you must have some active ranges, and have the Enable Range Queries checked on.
Displaying an overlay with one or more active ranges will take longer to redraw and it is recommended that you only display these when necessary.
To clear the query, go back to the Database Query form and Deactivate the query. Clear all queries on the Search menu does not deactivate it.
Select Save to store the query with the current settings.
Aggregation to a Polygon
A further form of Hotspot Analysis is to count the number of Foreground overlay records (typically a point overlay) in the search boundaries stored in a background area overlay and thematically map that area. The count from the foreground overlay can then be added to the background overlay as a field value.
To be able to do this you must have a numeric field pre-defined in the background area overlay into which the count will accumulate. The reserved User Defined Field DISPLAYFLG is recommended for this purpose although alternative numeric fields may be selected.
To count the number of a foreground overlay records lying inside a background area overlay boundary:
Steps Required:
Set the overlay you are counting from to the Foreground.
Add the area overlay whose field value you are updating to the background.
Choose Search|Select Search Overlay.
Select the background area overlay.
(You will see the ‘Search, Count or Update’ options is preselected.)
Select Run Query from the Search menu.
This time check the Count checkbox.
Click on Change and pick a numeric field from the background overlay to Update (eg Displayflg)
The optional Reset checkbox can be used to reset all record values of the selected numeric field to zero prior to the count.
Click Begin to run the query.
This will update the background overlay fields with the count.
Change that to the foreground to view the results. You can right click on the overlay form to see any record or run a thematic map against the whole overlay.
10. Geocoding Tools
Introduction
Data existing in non-GIS systems may well not have a spatial component - no ‘awareness of place’. If used in a GIS, such data will need 'geo-referencing' or 'geocoding' to attach spatial attributes to that data.
In the Intermediate Course we looked at using GGP to geocode imported data directly. In this Course we will look at using secondary sets of data to geocode the data as it is imported.
Post Code and Property GeoCoder
From GGP5 there is a tool in Setup Application’s Import function which allows you to import non-geocoded data and at the same time use an already geocoded dataset as a lookup reference. You can map the fields between the sets of data, and then as you import one set of data, the process will look up the relevant geometries from the other set where they already exist.
As an example you will probably have a set of postcode data which have polygons attached to them. If you import a dataset which contains postcodes as text items but doesn’t have any geometries, you can use the postcode as the common factor and use the postcode polygons to attach to the new data.
Assuming you have already created a suitable overlay, use Setup Application and select
Overlay | Import.
Select the Source and the Source Type for the import.
Your source may be a spatial database, a GIS format file, or a simple text file.
If the import is already geocoded, the import will proceed.
However if the source data has no geometries included (eg if importing a DBF file) you will be presented with a geometry lookup dialog.
You can select any existing lookup source from the list, or create a new one.
Click on the Plus icon at the top to add a new source.
This will open the Lookup Modifier Settings dialog, where you can define the lookup
Enter a suitable description and then click on Lookup Connection to specify where the lookup data is held.
The connection dialog will appear, where you can select the source eg GeoSpatial DB, SQL Server, and all the connection details for that database.
On the Modifier form the next line is the Lookup Query. Select or create a query to extract the correct details from the lookup.
The next step is to link the two datasets using Result Field Map.
Select the field in the imported data which you wish to map to the field in the lookup.
50 The mapped properties will be listed in the right hand column after selection.
When complete, click OK and the new query will be added to the list.
Next time you can simply select it (or edit it). You can also add it to a list of lookups which the process would run through in turn.
When you select a lookup and click OK, the import process will continue, and the geometries will be extracted from the lookup datasource and attached to the imported records in the new overlay.
Note you can utilise any data source you wish, but typically you may find that NLPG Property Points may be suitable for data already matched to the gazetteer and for data needing polygons then PostCodes, Parishes or Wards may be useful. Property polygons would require BLPU polygonisation to have been completed.
Importing Geo-Tagged Images
It is often the case that photographs taken on digital cameras or smartphones have already captured ‘Location’ automatically, and this information is attached as a GPS metadata tag in the image details which contains the co-ordinates of that location.
It follows that if you can utilise that location data, the photo images can automatically be located on the map in terms of the places they were taken, which is particularly useful for any kind of regulatory or enforcement purposes, or for presentation of any kind of photographic reports.
The same technique can be used to geo-reference images submitted by the public, and may be a more accurate way of knowing the location than mere description allows.
From GGP5 you can create a new GGP Tool to do this for .jpg images. This will then be available on the GGP toolbar menu. (You can also create a Windows Scheduled Task to do the same thing if you wish)
The import process will automatically extract the tags from the images, and store the co- ordinates as point geometries. This in effect geocodes the overlay data which corresponds to the image files.
On the overlay being used for the import, create suitable symbol graphics to represent the photo locations.
After import, the photo locations will be displayed as points representing the imported co-ordinates
Add a process field in the overlay structure and form designer, so that when you click on the map object the relevant image will be displayed.
Configuration and Setup The Overlay:
Create a Point overlay with these specific fields
| Field Name | Type | Width | Indexed |
| UNIQUEKEY | Character | 12 | Unique |
| EAST | Numeric | 6 | |
| NORTH | Numeric | 6 | |
| LATITUDE | Character | 12 | |
| LONGITUDE | Character | 12 | |
| MAPDATUM | Character | 12 | |
| DATESTAMP | Character | 12 | |
| TIMESTAMP | Character | 12 | |
| IMAGENAME | Process | 50 |
The Process Field:
Using Form Designer, open the GFM and point the IMAGENAME field to the location of the images. This should be a shared folder to hold the photos
Using Edit Process Name, simply enter the path to the folder (include quotes “ and percents % at both ends)
This will then utilise the default Windows image viewer.
If you wish to use a different viewer include that in the path -
eg C:\Programs\ImageViewer\ImageViewer.exe “%\\server\Folder\Photos%”
The Import Tool (using GGP’s ODBUP32):
Add a script into Tools with Support Programs, on the basis of
Program Path: <Path to ODBUP32>< Path to Overlay GFM> P <Path to Image Folder\Files>
eg
“C:\GGPWIN\Programs\ODBUP32.exe” “\\Server\Dept\Layer.gfm” P “\\server\Folder\Photos\*.jpg”
So place your images into the shared folder and then run the tool from the Tools Menu. Whenever you do this the image details will be imported to keep the overlay up to date.
11. Web Mapping and Routing Tools
From GGP5 there is a Tool which allows you to directly access Web Services from the viewport. This does not need any other configuration as the settings will depend on the browser and the service being accessed.
This function will interact with Google Maps, Bing Maps or OpenRouteService, and can be used in two principal ways –
- As a Routing Tool, to allow you to create routes using the routing functions, such as quickest route, selected mode of transport etc.
- As a Mapping Tool, to give you direct access to web mapping and thereby to additional publicly available map data such as satellite imagery or Google Street View.
Click on Internet Routing in the Tools Menu
This brings up a dialog to select the Routing Web Service from the drop down list.
On the dialogue you first select the Start point, various Way Points
and then the End Point.
Then depending on whether or not you are using Bing Maps or Google Maps you can select various variables on what mode of transport you are using, what you would like to avoid and what measurement you want to use to make it the Shortest Time or Shortest Distance.
Then click Show Route.
This dialog will stay open on the GGP map while you use the tool and you can scroll around in GGP to locate the end points. You don’t have to stay in the same viewport.
Click Show Route to display the map in the selected Web Service. These websites will calculate the route that best fits your route. It will then place a geometry on top of your map using a Polyline that fits that route.
You can also utilise the web service options directly, as this may have additional parameters such as fastest, cheapest route etc
When you enable saving, the parameters will be saved into the GGP script so you can use them again without having to enter all the details or define the route points again.
If you do not need to calculate routes, but simply wish to use the web services for additional map data, select the service and use the dialog to connect the location of the GGP viewport to the web map. You can then select the layers available in the browser, or look directly at photo images, business data or Street View imagery which relate to that location. This is therefore an easy tool to use to immediately compare overlay data with real world imagery and data, particularly valuable in a customer service setting.
12. Key Display
To add a key to your script select Options|Current Script Settings|Display and check the ‘Display Key’ checkbox. The key form lists each active background overlay and the foreground overlay within the current session. You can also use a CTRL K keyboard shortcut.
In the simplest case where there are no queries involved, a single entry appears in the key for each overlay - with a symbol for a Point overlay, a point/line for a Link overlay and a point/line/circle for an Area overlay. The graphic attributes (e.g. size and colour) of the symbols, lines or rectangles depend on the current attribute setting for each of those overlays.
The default Standard Graphics overlay (called STDGRAPH) is automatically excluded from the list.
Restricting the Overlays shown in the Key
The key can be made more selective, which is useful where you have many overlays displaying data with the same symbology (eg different years’ overlays of planning applications, which may all look the same).
Background overlays displayed can be manually removed from the key from Options|Overlays by selecting [More Options] and unchecking ‘In Key’. If you check ‘Hide’ to hide the overlay, the key will be hidden as well, regardless of the key setting.
For example these settings would result in the key shown.
Note it is also possible when setting up an overlay to deliberately restrict the display of selected types of geometry. The key will incorporate only those types of geometry which have been left ‘switched on’.
Key Display
So even if an overlay is an Area type where you would expect polygons, polylines and symbols, you may only see certain types in the key.
In this example, Planning Constraints has ‘No Symbols’ ticked on the overlay attributes, and Conservation Areas has both ‘No Polylines’ and No Symbols’
Showing Queries in the Key
If there are active Display Queries, including Thematic Queries, the key will also reflect this, and display the graphic attributes and names of any active display queries.
Normal Key
Key with Display Query
Key with Display Query, with ‘Display Non-Selected Records’ checked in the Database Query Form.
The text for those is set in Key Default Text in Options|Current Script Settings|Display. You can also set the Key Title there too.
Key with Thematic Query
If you have a thematic map running, the key will reflect the themes you have defined, including the thematic map
descriptions and/or values (shown in Thematic Queries earlier)
Key options
When you have a key displayed, you can perform some additional functions.
Right click on a highlighted overlay gives you a Set to Foreground function. You can use this directly from the key instead of using Options|Overlays or the Set to Foreground speed button.
Right click on the form header to see a popup sub-menu
Multi Column
If checked, each overlay has its own column. This is useful if there are many display queries active.
Autosize
If checked, the form will automatically adjust its size depending on the number of overlays to display. If not checked, you can reduce the size of the form (which automatically shows scroll bars) to suit. The form will not resize larger than its calculated maximum size.
Alignment
Align your key left, right, top or bottom, or click and ‘drag’ to a suitable position in the map area.
Set Order
This allows you to move items around the key to achieve the desired effect.
Move a highlighted item using the arrow keys
The
position of the key is saved with the Script, so it will appear in the same place in the map window next time you use the overlay.
Printing a Key
When printing a map you must first add the key to your print template if a key is required. Go to Print Template Manager to design or edit a print template. (See Basic Course)
If a key exists on the template it will be incorporated into the plot when printed, in the position shown on the template.
13. An Introduction to Reporting
The Fast Report report generator is the default reporting tool in GGP, but the previous
Shazam report generator remains available in certain situations.
Setting up Fast Report
A COM interface is provided so that the report generator can be controlled by a VB script or other COM compatible language. The first time that Search | Report is used, GGP will attempt to register the COM interface. If this is unsuccessful you may need to register it manually, in which case you will need to use Windows Start|Run and enter a command line:
regsvr32 %pathto%\GGPReportGenerator.dll
where %pathto% is the location of this dll file, typically in ..\ggpwin\programs\
You will also need to check the support program settings in GGP. Go to Options|General and select Support Programs.
Under the General settings, the Default Report Generator Path must be changed exactly to
‘GGPREPORTGENERATOR.DLL’.
Repeat this for the relevant script using Options|Current Script Settings|Support Programs.
A detailed Fast Report User Guide is provided with GGP and a demo is included within the Examples folder.
The previous SHAZAM report generator may be called If you do not have sufficient access rights for the Fast Report interface or if you have already saved a SHAZAM report config file with the same name and location as the overlay you are working with.
Using the Report Generator
When you now click on Search|Report, Fast Report will be launched, using the current foreground overlay data. This can be looking at the results of a query in GGP, or the data within the current viewport.
The screen will be similar to the following:
Layout of the Report Generator
The central pane represents the report page. The top left hand pane show a tree of the report elements and the lower left hand pane shows the properties of each of those report elements.
For instance if you click on 'Report' in the top pane, you will see the properties of the overall report in the lower pane.
If you click on 'Report title' or 'Page Header' in the top pane, you will see the properties of the title or header bars in the lower pane.
You can click on and expand each property to examine details more closely or to change any selected aspect. Most of the properties have drop down lists to select from.
If you click on an individual field, you will see the properties of that
field displayed in the lower pane. You will also see the box handles for that field highlighted in the central page display pane.
Editing the properties of a particular field allows you to control the display characteristics, such as colour or font, in the final report.
You can also drag and drop database fields into the report, and use the graphics on the central report pane to adjust the location or properties of the text boxes.
The toolbars around the screen relate to the functions of the Fast Report Designer. See the separate Fast Report User Guide for technical details.
Using the Fast Report Wizard
There is a wizard provided to make reporting easier in the early days of using Fast Report. The following is an example:
Having launched fast Reports, click on File|New. A list of wizards will be displayed.
Select Standard Report Wizard.
The Report Wizard shows five tabs for the five stages of
creating a report.
The first tab is Data, which be default will show the standard Fast Reports dataset called 'frxDBDataset1'. This will have picked up the GGP overlay data so you will not need to make any selection.
Click on the Next button or the Fields tab.
The fields within the overlay database will be listed in the left hand pane.
In this example, from a BLPU overlay, we can select a few fields by highlighting and clicking on the Add > button. This will transfer the fields we wish to include in the report across to the right hand pane.
At this point you can amend the order of the fields using the up/down arrows above the Selected Fields list.
Click on the Next button or the Groups tab, if you wish to apply a group function within the report.
In this example we have selected Postcode as the field with which to group the results.
The two remaining tabs are concerned with presentation.
Click on the Next button or the Layout tab.
Adjust if necessary, then click on the Next button or the Style tab.
Four preset styles are available for selection. Click on these to display the different options in the preview pane.
You can easily adjust any part of these at a later stage by editing individual properties in the main Fast Reports screen.
Click Finish to return to Fast Report.
The report will now appear in the central report pane, with the selected elements comprising the report,
You can amend any of the properties, for instance in the example above we have changed the font colour in the (BLPU:PAON) field to blue.
Click the Preview icon to run the report to screen.
You will now see the report as it will appear.
You can resize or scroll through the report using the icons at the top of the Preview window.
When finished, use the appropriate icons on the top of the Preview window to print or export the output report file.
A range of export options are available so that you can utilise the report in other applications. This includes image files and web-relevant formats.
14. Data Exchange
After running a Database Query or Spatial Search you may want to export the results to other packages. You could export your query results to an external database, another GIS application or AutoCAD for example. You may even need to export the entire overlay dataset.
Typical uses of this function include:
- Microsoft Word (for Mail Merge)
- Microsoft Excel (for Graphs)
- Microsoft Access (for Reports)
Go to Search | Export and select a filename and the required format.
You will then be able to select a variety of export options, including which fields to export from the available fields in the GGP overlay (select fields from the Properties tab) and which types of feature (points, polygons etc) to include in the export file (select from the types available on the overlay on the Geometries tab)
For certain types of data, eg TXT or CSV files, you can also define the field widths and delimiters. If there are options available to be set, you will see an extra tab relating to that type of format.
Selecting OK will export the data into the export file which you can then use in other applications.
Note this is a one-off export process not a permanent link between applications.
Replacing a queried set of records with a new set of records
Select Search | Import to replace records from the current query with a new set of records. This is used typically to keep two databases in sync with each other. The new set of records is typically an updated set of records from an external database.
This process can also be automated so as to keep synchronised at all times, and if this would help you would need to discuss this with GGP.
Using external GIS files without importing
GGP can access external GIS files without the need to import the data.
GGP can work on data stored natively in third-party formats, eg in ESRI Shapefile, MapInfo Tab and MapInfo Mid/Mif files. You will not have to use Import/Export commands but merely register external files in GGP using Setup Application. Then third-party overlays can be treated as any other GGP overlays and can be displayed, queried and printed.
To use file integration connect to the source data by using Setup Application’s External Source Settings function to select the source file.
By default you will then be able to select an overlay created from an external file or database, using Options | Overlays, but not be able to amend the data. By using the Edit | External Source function in GGP, this allows you to gain edit rights over external data which has already been connected to GGP.
Using external database records
Another way of sharing data is to have all the data in a central repository.
GGP can also have its own overlay data, including spatial data and the display graphics, stored in industry standard relational databases like Oracle or Microsoft SQLServer. These are called spatial database overlays, and allow those databases to be used directly for GIS functions.
To set up a spatial database overlay, first a database must have been created for the purpose in the database system such as Oracle or SQL Server, and tables set up in the database for the purposes required. You can also migrate a file-based overlay into a spatial database form using GGP tools.
The overlay will work in the same way as an internal GGP overlay, with the exception of the display style characteristics.
15. APPENDIX : Database Query Functions
Operators
String Operators
+ Joins two strings. Trailing spaces in the strings are placed at the end of each string.
- Joins two strings and removes trailing spaces from the string preceding the operator and places them at the end of the string following the minus sign operator.
Numeric Operators
+ Addition
- Subtraction
* Multiplication
/ Division
^ Exponentiation (or **)
Relational Operators
= Equal to
== Exactly equal to
<> Not equal to
# Not equal to
!= Not equal to
< Less than
> Greater than
<= Less than or equal to
>= Greater than or equal to
$ Is contained in
Logical Operators
.AND. both expressions are true
.OR. either expression is true
.NOT. either expression is false
Note: Notice the periods (dots) surrounding the logical operators
Evaluation Order
When more than one type of operator appears in an expression, the order of evaluation is as follows:
- alias name
- string
- numeric
- relational
- logical
Expressions containing more than one operator are evaluated from left to right. Parentheses are used to change the evaluation order. If parentheses are nested, the innermost set is evaluated first.
Numeric operators are evaluated according to accepted arithmetic principles:
- operators contained in parentheses
- exponentiation
- multiplication and division
- addition and subtraction
Order of evaluation may be altered with parentheses: 3+4*5+6 = 29
(3+4)*5+6 = 41
(3+4)*(5+6) = 77
Logical operators are evaluated as .NOT. first, .AND. second, and .OR. last. Logical evaluation order may also be altered with parentheses. In multiple conditional expressions that contain the
.NOT. operator, always use parentheses to enclose the .NOT. operator with the expression to which it applies.
Functions Supported
ALLTRIM(string)
Trims both leading and trailing spaces from a string. The string may be derived from any valid xBase expression.
ALLTRIM(' NoSpaces ') returns 'NoSpaces'.
AT(SearchString, TargetString)
Determine whether a search string is contained within a target. If found, the function returns the position of the search string within the target string (relative to 1). If not found, the function returns 0 (zero).
AT('gh', 'defghij') returns 4.
CTOD(string)
Converts a character string into an xBase date. The string must be formatted according to the settings of SetDateFormat and SetCentury.
IF(DATE() - CTOD('12/31/93') > 0, 'This Year', 'Last Year')
DATE()
Returns the system date (today). Use DTOC(DATE()) to retrieve today's date formatted according to Windows International settings. If the date format is American, DTOC(DATE()) returns '03/21/95' if today is March 21, 1995.
DAY(DateField)
Returns the day portion of an xBase date as an integer.
DELETED()
Returns True if the record is deleted and False if not deleted.
DESCEND(string)
A function for use with SIXNTX indexes that inverts a key value using 2's complement arithmetic. The result of the operation is the arithmetic inverse of the key value. When inverted keys are sorted in ascending sequence, the result is in descending order.
To create a search key for an index built with this function, you must use the Descend method. An index expression could be:
'DESCEND(DTOS(billdate)) + CUSTNO'
This function is included for consistency but is not relevant to GGP.
DTOC(DateField)
Converts an xBase date into a character string formatted according to the settings of SetDateFormat and SetCentury. For example, if the date format was American and SetCentury was True, and the date field contained March 21, 1995, DTOC(datefield) would return '03/21/1995'.
DTOS(DateField)
Converts xBase date into a string formatted according to standard xBase storage conventions (CCYYMMDD). For example, December 21, 1993 would be returned as '19931221'. Indexes that contain date elements should use the DTOS() function, which naturally collates into oldest date first.
EMPTY(Field)
Reports the empty status of any xBase field. Character and date fields are empty if they consist entirely of spaces. Numeric fields are empty if they evaluate to zero. Logical fields are empty if they evaluate to False. Memo fields that contain no reference to a memo block in the associated memo file are empty.
IF(Logical, True Result, False Result)
This is the immediate if function. If the Logical expression is true, return the True result, otherwise return the False result. The types of the True Result and the False Result must be the same (i.e., both numeric, or both strings, etc.) The logical expression must of course evaluate as True or False.
IF(DATE() - CTOD('12/31/93') > 0, 'This Year', 'Last Year')
LEFT(string, length)
Returns the leftmost characters of the expression for the defined length.
LEFT('xyzabc', 3) returns 'xyz'.
LEN(expression)
Returns the length of the expression result as an integer.
LOWER(string)
Converts the string expression into lower case.
MONTH(DateField)
Returns the month portion of an xBase date as an integer.
RECNO()
Returns the current physical record number as a long integer.
RIGHT(string, length)
Returns the rightmost characters of the expression for the defined length.
RIGHT('xyzabc', 3) returns 'abc'.
SPACE(length)
Returns a string consisting entirely of spaces for the defined length.
STR(number, length, decimals)
Converts a number into a right justified string with decimal digits following the decimal point. The total length of the string is defined by the length parameter. STR(RECNO(), 5, 0) is a common indexing element that ensures creation of unique keys if appended to another field element. An index key using this expression could be built with NAME + STR(RECNO(),5,0). If the decimals’ parameter is omitted, the function defaults to zero decimals. If the length parameter is omitted as well, the length of the result is 10 characters under SIXFOX. Under SIXNSX and SIXNTX the default is the length of the field.
SUBSTR(string, start, length)
Returns a portion of the string expression starting at the defined start location for the defined length..
SUBSTR('xyzabcd', 3, 4) returns 'zabc'.
TIME()
Returns the system time as a string in the form HH:MM:SS.
TRIM(string)
Removes trailing spaces from the string expression.
UPPER(string)
Converts the string expression into upper case. Character fields used in index expressions should always be converted to upper case to insure correct collating sequence.
VAL(string)
Converts a string of numeric characters into its equivalent numeric value. The conversion stops at the first non-numeric character encountered (or the end of the string).
VAL('123ABC') returns a value of 123.
YEAR(DateField)
Returns the year portion of the xBase date as an integer.
TRANSFORM(expression, picture)
Transform converts strings and numeric values into formatted character strings. The function transforms the result of the first expression in accordance with the second picture string.
The picture string is made up of two parts. The first part is the Function string and it is optional for both strings and numeric values (as long as the second Template string is present).
- A character string transformation picture may consist of only a Function string or only a Template or both.
- A numeric picture must contain a Template string; the Function string is optional.
- A logical value must contain only a Template string with Template characters L or Y.
The Function string consists of a leading @ character followed by one or more formatting characters. If the Function string is present, the @ character must be the first character in the picture string with its formatting characters immediately following and it may not contain spaces. If a Template string exists as well, it follows the Function string. A single space separates the Function string and the Template string.
Function string characters allowed for numeric values are:
B - left justify;
C - display CR after positive numbers;
X - display DR after negative numbers;
Z - blank a zero value;
( - encloses negative numbers in parentheses.
Function string characters allowed for strings are:
R - inserts unassigned template characters;
! - converts all alpha characters to upper case.
The @R Function requires a Template; the ! Function does not.
The Template string describes the format on a character by character basis. The Template string is made up of special characters which have specific results and optional unassigned characters which either replace characters or are inserted in the formatted string depending upon the absence or presence of the @R Function string.
Template assigned characters are as follows:
A,N,X,(,# are place holders and are interchangeable;
L displays logical values as T or F;
Y displays logical values as Y or N;
! converts the corresponding character to upper case;
, (comma) or a space (in Europe) in a numeric template separate the elements of a number;
. (period) or , (comma - in Europe) in a numeric template specify the decimal position;
* fills leading spaces with asterisks in a numeric template;
$ as the leading character in a numeric template results in a floating dollar sign being placed in front of the formatted number.
Comments
0 comments
Article is closed for comments.