- Review last weeks
- different strategies for Digitizing (Different Extensions)
- Web page implementation and Windows integration
- Layers from text again
- Polygons from lines; lines from points
- Creating polygons without building
- Final Questions
Last week in the lab and in tutorial we looked at polygon, line and point features and the attribute data that describe them. We loaded boundary files form the Open Data portal for the city of Prince George into your canvas. We then reviewed how spatial features can be created from a textual format using add delimited text layer. We reviewed how descriptive data is joined to a spatial table by maintaining a common item field. We finished off by reminding ourselves that the user of GIS data and software is part of the System in GIS and that we should take care in planning how we implement our models and research schemes. We accomplished this by joining locational data from Prince George (Postal information) to a crime data layer (in that order).
More creating data from text
Point generate file
We created point feature type layer that could be converted to a shapefile. This file did not have a unique ID for each location associated with each row’s x,y coordinates, but rather postal codes (that are not necessarily unique). In tutorial we will be looking at this dataset in greater detail in regards to its unique ID. The data we used were stored in a text format using deliminators such as commas and is often called a generate file. In the case of the postal code data – we were generating a point layer (one feature per row of text). This concept can be extended to creating lines and polygons from text using the Simple Features Model.
Line generate file
Creating lines from Points.
It is possible to create lines from digitizing (connecting points) points, but it is also possible to generate them from points (or vertices).
generate file for lines:
This file type is the same as a generate file for points but for lines. The first number indicates the start of each individual line by giving it an unique ID (i.e “12″ is the unique ID for the first line). The rows of numbers after the ID represent , are x,y coordinates (in this case UTM coordinates – we will learn about this later) and the END statement defines the termination of each line as well as the completion of the layer (end of the field). These numbers can be brought into GIS software to make shapes (the campus buildings actually). Instead of generating these features we are going to use the bear data to create a graphical line that expresses the movement of a bear.
Last lecture we learned what the start and end points on a line are called as well as the points along the line. Nodes for for the end points (dangling) and vertices for changes in direction along the line.
Can you determine what feature type(s) can be created when the starting and ending coordinates are the same (such as the first feature in the text file above)? Explain in in terms of simple features.
Bear movement from points
Open QGIS and load the bears95 layer from /home/labs/geog204/tutlab2/. You can also load the roads shape file from the same directory.
Add the Toolbox to the project
You do this by right clicking on the grey part of the tool panel (where all the icons are below the top menus) and click on Toolbox to add the panel to your project (shows up on the right).
You should have a view like this:
If we inspect some of the points in the bear layer we may guess as to the probability of there being one bear in several areas over a period of time. Aita or Scott will illustrate picking out several points of interest to build a line from. We will also install the plugin “points to path” This is done by
- Click on the plugins menu –> Manage and Install Plugins
- Click on the Settings Tab and activate (turn on) all the checkboxes –> Check for updates –> Show experimental –> Show depricated
- Click back on the ALL Tab and search for “path“
- Click on the checkbox for “PointsToPath” –> install plugin (lower right)
- Click close
Making lines from points:
- Add bears95 and roads layers – as shape files
- zoom to an area of interest
- use the select tool (Select menu –> select by rectangle)
- save selection as a shape file and load the new file into your project
- go to plugins –> manage and install plugins –> settings –> click to turn on all three boxes (turn them orange)
- install the plugin “PointsToPath” (search for it under the “All” tab – as explained above)
- use the plugin with
- “group by Activity_c”
- “order by date_path” – NOT DATE
- use “%Y/%m/%d: as date format”
For more information about QGIS and the plugins, you can chase down the links at plugins.qgis.org. Aita or Scott will do a quick intro to using the plugins.
You can play around with grouping and ordering the creation of the line as you see fit. You could even try to group by DATE and order by Date_path. Too bad we do not have the time of day the data was collected.
Digitizing – Points to Lines to Polygons
As the use of GIS and related fields have become more common place, there has been a great amount of data created or collected. For instance the road layer we are using could have come from municipal CAD drawings or digitized directly using GIS. This means that at one time, all data had to be digitized (drawn using digital means – a computer) by applying similar techniques as we are about to use.
Make sure you have a place to put the data we are about to create. In other words create a directory called “lab2″ in your geog204 directory. If you did not create a directory for the above exercise, do it now and move the layer (shape file) you created by joining the bear points into this directory.
Steps for digitizing
Using the bear95 layer lets trace some points in approximating where a bear’s (or several bears) cruising ground is. We want the this new layer to be clean so we need to apply the concepts of threshold and snapping. Scott/Michael/Aseem
- Go to settings –> options –> digitizing
- use map units for snapping at 15 metres
- map units for search 20 metres
- Go to Settings –> snapping options and click on the point layer you want to snap to (Optional – kind of)
- Add a new “line” shape file layer (layer –> New –> New shapefile layer)
- Start editing by applying the “yellow pencil” (can be done by right clicking the layer or hitting the menu button)
- Draw some lines – three or four that connect (try to snap to bear location points).
- Save your edits to your new layer
- Under the Vector emenu use use the lines to polygon function to create polygons.
- Repeat the polygon building by using the polygonize tool (It can be found in the toolbox you added earlier)
Question2. By referencing this weeks lecture, what have we done. Using terms such as cleaning and building, tolerance and snapping describe the steps you just undertook to make different features, layers and feature types. Use terminology from the lecture (i.e fuzzy tolerance). Explain why we also turned on the snapping options to make use of the bear point layer below our line digitizing.
Below we have 3 images.
- The first illustrates the lines that were digitized from following the point layers – (i.e. turning on the snapping options to make use of the bear point layer below our line that is digitized).
- The lines were drawn in the following order:
- red (it is underneath the lines the yellow and orange lines share with it)
- yellow (it has common lines with red and grey)
- orange (sharing with red)
- grey (sharing with yellow)
- blue (is shares with no other lines and has only two vertices)
- The second is the polygons created using the the “create polygon from lines” feature standard under the Vector menu
- The third illustrates the polygons created using the Polygonize Tool.
Question3. Try to explain why the two polygon layers are different. Can you determine the process used to create the polygon features? (HINT: the standard tool follows the lines in the order they are drawn to see if they form a polygon, the polygonize tool reviews all lines to see what combinations can be used to form areas) .
Create polygons directly
You can create polygons without having to build them from lines in most GIS software. We will do so with QGIS by creating a new polygon shape file layer and playing around with the snapping options for regular and topological editing. Try the following steps to digitize polygons:
- Create a new “polygon” shape file layer
- Activate editing of that layer
- Go to settings –> snapping options
- Click to activate the bears95 and your new polygon layers
- Set the snapping tolerances to 20 map units
- Set to both “Vertex and Segment”
- Draw some polygons
- Draw features without them touching
- Draw features that are clean and touch
- Draw features that overlap
- Draw some holes in some feature (you will have to find your advanced editing tool bar)
- Add vertices to features
- move vertices within features
- In the snapping options – click on the “avoid int” button for the polygon layer
- Try to digitize overlapping features now
- Save your edits
Question 4 2 Marks: Regard the following illustration.
What type of nodes are represented in the drawing? How may lines are there?
If we cleaned and built the shape by digitizing another line to connect the two nodes together, would this be a proper tological feature. How many nodes would it have? How many polygons?
For fun, GIS fun that is, see if you can digitize the drawing above to see if you can create an improper feature. This feature would be one polygon that crosses itself. You will find that clean, or data that can be used to create topology, is a users responsibility – not a the file type (shape) or the software’s duty.
Bonus Question 2 Marks: The layer below has one polygon in it (drawn in the manner mentioned above whereby the polygon tool is used to create a layer with crossing lines. Describe a method that can be used to create a layer with the proper three polygons created. You do not have to add any more plugins than we have already used.