Understanding Selection Using Query Procedure

Embed Size (px)

Citation preview

  • 7/27/2019 Understanding Selection Using Query Procedure

    1/7

    UNDERSTANDING SELECTION USING QUERY PROCEDURE

    Selection is a process of filtering data from the existing data set. This process involves screening part of

    data while leaving the rest. While MapInfo allows attaching data to objects on a map, its true analytical

    power is its ability to group and organize data. Once data is broken down into logical groups, it is easy to

    analyze it based on one or more variables. Two different types of selection are available in MapInfo viz:

    Query select Marque select

    Each of these select objects based on a given parameter set by the analyst. Parameter may have one,

    two or multiple, based on one or more variables:

    There are many different ways to classify or group objects or dataset. Some dataset may fall into more

    than one category or class.

    More than one variable are used to group and classify objects. MapInfo can create similar groups with

    different datasets. MapInfo refers to these groups as selections. A selection is a subset of data that has

    been grouped or classified together based on one or more variables. For example a table comprising

    crop production in Nigeria. This can create a subset of a particular type of crop grown across Nigeria and

    the quantity produced by each state. This be displayed as spatial images as thematic layer Or, you could

    create a subset of state producing Maize above 300MT annually or create a subset of states that

    produces cotton up to 0.29MT. The statements above used to create these subsets are known as queries

    a query is just another word for a question in database language.

    Characteristics of Selections

    Selections are temporary tables. When make a selection, MapInfo creates this temporary table to store

    the records that have been selected. Many of the tasks can be perform with a selected item that can

    later be perform with a permanent (base) table such as:

    View it in a Browser, a Map window (if it has graphic objects), a Graph or a Layout window. Cut and copy it into the clipboard and paste it into another table, or even into another

    application.

    Use it to edit a table. Make a further selection from it.

    To convert selected item into permanent tables, use File > Save Copy As, once it is saved the temporary

    selected table became a permanent table, and can be treat as the new table like any other table.

  • 7/27/2019 Understanding Selection Using Query Procedure

    2/7

    Selected tables are totally dependent on the table from which they were created. If the base is close, all

    associated selection tables are deleted before saving.

    Making Selections

    MapInfo gives you a number of commands and tools for making selections. They fall into two categories:

    Selecting from the screen: Select tool, Radius Select tool, Boundary Select tool, Marquee Selecttool, Select All command. To select records with the tools, click on or encircle the associated

    graphic objects. To select records from a layer at the same time, choose Query > Select All.

    Selecting with queries: Select, SQL Select. When you select records with either of thesemethods, you create a logical expression that MapInfo uses to select the records. For example,

    the expression SALES > 20000 means that MapInfo will select only those records with sales

    higher than $20,000. (Select and SQL

    Select will be explained in the next chapter).Selecting from the Screen

    To select objects from the screen, the layer that contains the objects must be Selectable. To make a

    layer Selectable, choose the Layer Control command from the Map menu and check the Selectable box

    for that layer. When you select map objects in a Selectable layer, MapInfo highlights the objects using

    the settings defined in the Highlight Control section of the Preferences dialog (Options menu). When

    you select map objects in an Editable layer, MapInfo places edit handles (little squares) around the

    extents of the object you selected.

    Selecting Tools

    MapInfo includes several tools on the Main Toolbar to allow you to choose records for further viewing

    and analysis, including:

    Selection types

    Select tool Radius Select tool Marquee Select tool

    Polygon Select tool Boundary Select tool Invert Selection tool

    To select an object:

    1. Make the layer that you want to select objects from Selectable (Map > Layer Control).2. Choose the Select button from the Main Toolbar.

  • 7/27/2019 Understanding Selection Using Query Procedure

    3/7

    3. Click on an object in the Map window. If that objects layer is Selectable, MapInfo highlights theobject. If the layer is Editable, MapInfo puts edit handles around the extents of the object. If the

    layer is neither Editable nor Selectable, MapInfo does not allow you to select the object.

    4. Choose Window > New Browser Window to display selected records in a Browser. ChooseSelection from the list of tables. MapInfo creates a Browser of the new temporary table. To

    select records from the Browser, simply click on each record with the Select tool. To select

    multiple objects individually, click on the first object to select it. Hold down the Shift key and

    click on another object. MapInfo selects that object, too. If you select a second object without

    holding down the Shift key, MapInfo unselects the first object and selects the second object.

    When selecting a point object, you generally want to position the Select tool in the center of

    the symbol. However, some symbols have a hot spot that you must hit in order to select it. For

    example, the hot spot on the golf flag symbol is the base of the pole.You can use it to highlight objects in a Map window or a Browser that meet certain criteria. You

    can also create a results table that you can browse, map, or graph like any other table. For

    instance, by formulating queries with Select, you can ask MapInfo to:

    Show only States where the number of farm families are above 65,000. Show only states with extension workers less than 100. Show only states with farm families higher than 500. Show only states producing rice greater than 350Mt in 2012.

    All the above are selection based on specified conditions needed to be satisfied. The table can

    also be saved as a separate table with Save Copy As.

    Creating Expressions

    To perform a Selection with SQL query, you must create an expression. An expression is a

    logical statement that is used to ask your question.

    Maize production < 800 where maize is the column that contains the production in years.The < sign means less than. MapInfo searches the crop production table for all recordsthat satisfy this condition and puts those records in a temporary table that you can map,

    browse, graph or carry out additional queries. Other mathematical operation like addition

    and all basic operations are done with expression. For example, you want to create a

    temporary table of all maize production in states where total cost of less than

  • 7/27/2019 Understanding Selection Using Query Procedure

    4/7

    =N=28000/ha. Total cost is equal to the sum of the inputs used in the production of maize

    in 2012. You could use the expression:

    Cost of Fertilizer + Cost of seed + Cost of labour < 1800 You are telling MapInfo to addthe cost of fertilizer on the fertilizer column and the cost of seed in the seed column and

    the cost of labour in labour column and then compare that number to 1800.

    Hint: There are two ways of creating an expression.

    The first method is to type in the expression directly. When you are creating verysimple expressions, this method is usually faster.

    The second method is to press the Assist button in the Select dialog and build yourexpression using the pop ups in the

    Expression dialog.

    This method is particularly useful when you are just

    learning how to build expressions or when you are

    building very complex expressions. The SQL select

    dialog gives some pop ups that can be use to build

    an expression: Left side are Select columns,

    Location Condition, Parameter for grouping the

    order in which the result is to be displayed while by

    the right side table name, column, operators,aggregation and functions. The screen shot on figure by the side show

    Steps Using Select

    In general the process for selecting objects using Select is:

    Selection using SQL query expression

    Query>SQL>Select column to project>Select table name from which to select>Insert where condition for

    criteria specification>>Used by Operator symbol>select group by Column for aggregation>Select order

    by column to provide the function>verify and click ok. The query will run. The screen shot in figure

    below show the selection using expression

    Hint: If expression is to be used the below concept need to be understood:

    Columns: This lists every column in the table from which you are selecting. If the table contains

    derived columns from previous queries, those columns will also be listed.

  • 7/27/2019 Understanding Selection Using Query Procedure

    5/7

    Operators: This contains mathematical and logical operation symbols. The mathematical

    operators are used for addition, subtraction, multiplication, division, greater than, less than, and

    equal signs. You can use these symbols to create mathematical formula. The Operators also

    includes logical operators conjunctions AND, NOT, OR and LIKE.

    Functions: This contains mathematical functions that take one or more parameters and return a

    value. You use functions to perform basic mathematical functions on the data in that column.

    AVG_DIFF, are functions for difference between two parameters. The following expression:

    AVG_DIFF < 20 Or AVG_DIFF > 20 This expression tells MapInfo to select allrecords that have an average difference less than -20 or greater than +20.

    However, this could also create the following expression:

    abs(AVG_DIFF) >20 This expression tells MapInfo to select all records where theabsolute value of the average difference is greater than twenty. The Functions has many

    other utility, including area, perimeter, sin, cos, and date-related functions.

    Steps in Selection using assist button

    In general the process for selecting objects using select is: Figure above express the screen shot

    of the selection with assist button.

    Query>Select>Select record from table>option>Click

    assist> type an expression by selecting column> Select

    operator>Select function>click a verify>If Good it

    display dialog that syntax is correct>click ok>Click ok.

    The selection is effected

    MapInfo names the table Query1. It will name the next temporary selection table Query2. You can

    override MapInfos default name and give the selection a descriptive name. Type the new name into the

    Store Results in Table box. The table can also be saved as a separate table with Save Copy As.

    Make sure mapinfo/ data is the directory that displays in the Directories list box. If it is not, you may

    need to double click on the data directory in the directories list box.

  • 7/27/2019 Understanding Selection Using Query Procedure

    6/7

    Example: Selecting

    MapInfo makes finding information and locations easy. You can use the Select feature to create subset

    databases of your information. As an example, we will use the sample world table to select particular

    countries with a literacy rate greater than 90%. Open the world.tab table, and choose Query > Select to

    display the Select dialog.

    Do the following:

    1. Complete the Select dialog:

    From the Select records from table drop-down list, choose World. Click on Assist. The Expression dialog

    displays

    2. Complete the Expression dialog as shown in the following figure: From the Columns drop-down list,

    choose Literacy. From the Operators drop-down list, choose > (the greater than sign). Type 90. Click

  • 7/27/2019 Understanding Selection Using Query Procedure

    7/7

    Verify to confirm the syntax of your expression. Click OK to close the Verify dialog. Click OK to close the

    Expression dialog. The Select dialog re-displays. Make sure the Check the Browse results option is

    checked.

    3. Click OK to select the countries. MapInfo creates a Browser that contains the selections. Notice that

    the selections display in both the World map and Browser.