QGIS training class 1
-
Upload
hiroaki-sengoku -
Category
Education
-
view
2.683 -
download
1
description
Transcript of QGIS training class 1
Copyright (C) 2013 microbase.LLC All Rights Reserved.
Geographic Information SystemQGIS Introduction(1)
microbase.LLChttp://microgeodata.com/
Copyright (C) 2013 microbase.LLC All Rights Reserved.
Agenda
1st
2nd
3rd
W h a t ’s Q G I S ? B a s i c u s a g e B a s i c d a t a m a n a g e m e n t
S p a t i a l d a t a h a n d l i n g S p a t i a l A n a l y s i s
G e o c o rd i n g C re a t e Ve c t o r d a t a A b o u t c o o rd i n a t e s y s t e m C re a t e K M L d a t a U t i l i z e O S M d a t a
Copyright (C) 2013 microbase.LLC All Rights Reserved.
Contents Today
1st session
1 What’s QGIS?
2 Basic usage
3 Basic data management
4 Map design
Homework
Copyright (C) 2013 microbase.LLC All Rights Reserved.
What’s Quantum GIS (QGIS)?
• One of open source GIS software named FOSS4G (Free and Open Source Software for Geospatial)
• a user friendly GUI
• Multi-platform(Win, Mac OS X, Linux)
• Multi-language
• Rich functions for a function enhancement
Copyright (C) 2013 microbase.LLC All Rights Reserved.
What QGIS can do?
Create and edit GIS data
Display GIS data
(overlay, thematic map...)
Select / Join data GIS data analysis
Copyright (C) 2013 microbase.LLC All Rights Reserved.
Bas ic usage
Copyright (C) 2013 microbase.LLC All Rights Reserved.
2.1 Launch QGIS
• Double click the QGIS shortcut icon on desktop
• The window will open.
Copyright (C) 2013 microbase.LLC All Rights Reserved.
QGIS window will open like below.
Copyright (C) 2013 microbase.LLC All Rights Reserved.
toolbar menu
map viewLayer
map info / settings
topmenu
Copyright (C) 2013 microbase.LLC All Rights Reserved.
Ins ta l l P lug in
• Choose “Fetch Python Plugins...” from “Plugins” on the top menu and search “Table Manager” from Filter form in “Plugins” tab.
• “Table Manager” is a database management tool.
• Choose and install “Table Manager”.
• When installing plugin, internet environment is necessary.
Copyright (C) 2013 microbase.LLC All Rights Reserved.
• Choose “Manage Plugins...” from “Plugins” on the top menu and click the “Add Delimited Text Layer”.• “Add Delimited Text Layer” function is used for importing CSV format data.
• Checked function will be visible on the main menu and able to be used.
“Add Delimited Text Layer” will be visible.
Plugin Management
Copyright (C) 2013 microbase.LLC All Rights Reserved.
2.2 Add data
GIS data can be devided into 2 types..
• Raster type ex) JPEG, PNG, TIFF
• Vector type ex) Shape file(.shp)
For instance, imagine a river and bridge,
Raster typeaggregate of colored dots
Vector typeline data connecting starting points and end points
Copyright (C) 2013 microbase.LLC All Rights Reserved.
Exercise data
lecture1_data
tokyo23
homework1
Copyright (C) 2013 microbase.LLC All Rights Reserved.
About Shape f i le
• Vector type data mostly used in the world.
• Available in most GIS softwares.
• “Shape file” format is composed of more than 3 files as follows.
*.shp (geometry type and geographical coordinates)
*.dbf (attributes of features such as name and figure)
*.shx (relationship between shp and dbf)
*.prj (the coordinate system and projection info)
Shape file
same file name
These files must be put in same folder.
Copyright (C) 2013 microbase.LLC All Rights Reserved.
NAME AREA PERIMETER
0
1
2
3
4
5
AAA 18352 644
BBB 22496 756
CCC 22050 602
DDD 7548 352
EEE NA NA
FFF NA NA
*.shp *.dbf *.shx
CCC
AAA
DDD
BBB
Point Data ex) amedas data, shop data
Line Data ex) road data, railway data, river data
Polygon Data ex) city shape, building data
<Feature type>
Copyright (C) 2013 microbase.LLC All Rights Reserved.
1) Click “Add vector layer”
2) Browse file
3) Open
Add “ku.shp” in “tokyo23” folder.
Copyright (C) 2013 microbase.LLC All Rights Reserved.
※ Caut ion ※
• Japanese GIS data by Government such as National Land Numerical Information and census data tend to be recorded in Shift-JIS. If you use Mac OS or Unix, Check that the encoding is Shift-JIS before adding the data.
• Shift-JIS can be converted to UTF-8 later.
Copyright (C) 2013 microbase.LLC All Rights Reserved.
Tokyo special districts are displayed.
Copyright (C) 2013 microbase.LLC All Rights Reserved.
Disp lay a feature
1) Click “Identify Feature”
2) Click a feature
Copyright (C) 2013 microbase.LLC All Rights Reserved.
Shibuya info can be shown in a new window.
Copyright (C) 2013 microbase.LLC All Rights Reserved.
1) Click “Save Project” (Ctrl + S or Command + S) 2) You can save it any name in any folder.
3) save a project as “.qgs” type
2 .3 Save a pro ject
Copyright (C) 2013 microbase.LLC All Rights Reserved.
Exerc ise1
Add following data in the folder “tokyo23”.
subway.shp (Line data: a subway in Tokyo Special district)
station.shp (Point data: a station in Tokyo Special district)
convenience.shp (Point data: a convenience store in Tokyo Special district)
elevation.shp (Polygon data: an terrain data in Tokyo special
district)
Copyright (C) 2013 microbase.LLC All Rights Reserved.
Hint
You can select plural files while pushing Ctrl key ( or Command key).
Copyright (C) 2013 microbase.LLC All Rights Reserved.
Answer
Copyright (C) 2013 microbase.LLC All Rights Reserved.
The order of layer on TOC can be altered by drag and drop.
Front
Back
2.4 Change an order of each layer
Copyright (C) 2013 microbase.LLC All Rights Reserved.
A layer can be h idden without check ing a check box of layer.
Only subway and station layer can be seen on map view.
Copyright (C) 2013 microbase.LLC All Rights Reserved.
Delete a layer
Delete other than “ku” layer.
# This function doesn’t delete a file itself in the file directories.
Copyright (C) 2013 microbase.LLC All Rights Reserved.
Bas ic data management
Copyright (C) 2013 microbase.LLC All Rights Reserved.
What ’s an “at t r ibute”?
NAME AREA PERIMETER
0
1
2
3
4
5
A棟 18352 644
B棟 22496 756
中庭 22050 602
生協購買 7548 352
ポスト NA NA
道路 NA NA
中庭
A棟生協購買
B棟
・ポスト
attribute table
“Attribute” means an property of each feature such as a name and an area. In case a shape file is used, the attribute is saved into a dbf file and can be edited.
The feature “0” has a name of “A building” and an area of 18,352 square meters, perimeter of 644 meters.
Copyright (C) 2013 microbase.LLC All Rights Reserved.
Open Attr ibute table
See an attribute table of “ku” layer.
• Add “ku.shp” on layer and open its attribute table.
field
Each line links to vecoter on map.
Click “ku” layer on the right mouse and choose “Open Attribute Table”.
Copyright (C) 2013 microbase.LLC All Rights Reserved.
If you choose a line from attributes, the linked map feature also be chosen.
If you choose a map feature on map view, the linked line also be chosen in the similar way.
click a line number which you’d like to choose.
Choose “Select Single Feature” and click a map feature on map view.
Copyright (C) 2013 microbase.LLC All Rights Reserved.
Se lect layer by at t r ibute
Select a city which has more than 20 km2 in area from attribute table.
About fields
• KU : city id
• NAME : city name
• PERIMETER [ m]
• AREA [m2]
1) Click “Advanced Search”.
Copyright (C) 2013 microbase.LLC All Rights Reserved.
Input a condition expression on “SQL where clause”.
If you click, item will be added to “SQL where clause”.
“Test” show you whether the condition expression is correct or not, and the number of matched features
Input “AREA >= 20,000,000”( m2 -> km2 )
Copyright (C) 2013 microbase.LLC All Rights Reserved.
12 cities are selected.
Deselect
Copyright (C) 2013 microbase.LLC All Rights Reserved.
Se lect features under p lur a l condi t ions
AND and OR enable to se lect features under p lur a l condi t ions .
case1 : ku which has more than 10 km2 and less than 20km2 in area
AREA >= 10000000 AND AREA < 20000000
AREA < 10000000 OR AREA >= 20000000
Also, NOT i s use fu l when you ’d l i ke to se lect features under
oppos i te condi t ions .
case3 : ku which doesn ’ t have not less than 20km2
NOT AREA < 20000000
case2 : ku which has less than 10 km2 or more than 20 km2
Copyright (C) 2013 microbase.LLC All Rights Reserved.
Exerc ise 2
1) Select city features which has more than 50km in “PERIMETER” and doesn’t have less than 50km2 in “AREA”
2) Save the selected features as “large_wards.shp” in “tokyo23” folder.
3) Open “large_wards.shp” in QGIS
Copyright (C) 2013 microbase.LLC All Rights Reserved.
Answer
PERIMETER >= 50000 AND NOT AREA < 50000000
Copyright (C) 2013 microbase.LLC All Rights Reserved.
Jo in table
“Join table” is to combine different table based on a key field in common.
This function is very useful when you combine GIS data with others or external data such as csv and dbf data.
NAME AREA
0
1
2
Hokkaido 83456.38
Aomori 8918.45
Iwate 15278.85
PREF POP
0
1
2
Hokkaido 5506419
Aomori 1373339
Iwate 1330147
NAME AREA PREF POP
0
1
2
Hokkaido 83456.38 Hokkaido 5506419
Aomori 8918.45 Aomori 1373339
Iwate 15278.85 Iwate 1330147
name, area name,population
add pop field into the target table based on the prefecture name.
Copyright (C) 2013 microbase.LLC All Rights Reserved.
The column “pop” has population data in Tokyo in 2010.
Load “ku_pop.csv” in “tokyo23” into QGIS.
“Layer” > “add vector” > import csv
Copyright (C) 2013 microbase.LLC All Rights Reserved.
CSV data has been added.
Copyright (C) 2013 microbase.LLC All Rights Reserved.
Join population data in Tokyo special districts into “ku” layer.
Choose a “join” tab above menu of the layer property “ku” layer
csv layer
Use city name as a key field
shp csv
Copyright (C) 2013 microbase.LLC All Rights Reserved.
You can join / unjoin other data more.
“ku_pop” layer is joined to “ku” layer.
Copyright (C) 2013 microbase.LLC All Rights Reserved.
“ku_pop” at t r ibutes has been jo ined .
Attributes of “ku” Attributes of “ku_pop”
Copyright (C) 2013 microbase.LLC All Rights Reserved.
Decide where one wants to save the files.
Save the joined layer as “ku_pop.shp” in “tokyo23”.
Copyright (C) 2013 microbase.LLC All Rights Reserved.
Open “ku_pop.shp” and check that the attribute table is joined one or not.
Copyright (C) 2013 microbase.LLC All Rights Reserved.
Calcu late f ie ld
“Calculate field” enable to handle field values at once.
Calculate a population density in each area using “pop” and “AREA” fields in the attribute of “ku”.
Population density = Population / Area [pop / km2]
Copyright (C) 2013 microbase.LLC All Rights Reserved.
Togg le ed i t mode
Toggle edit mode before calculate field.
Copyright (C) 2013 microbase.LLC All Rights Reserved.
Click “calculate field”.
Ca lcu late f ie ld
“pop” field is loaded as string. the field in CSV are all regarded as string.
Caution:“calculate field can’t be conducted when string and figure data coexist together.
Copyright (C) 2013 microbase.LLC All Rights Reserved.
to int ( ) = ( ) 内のフィールド値を整数に変換
Fill as above
Copyright (C) 2013 microbase.LLC All Rights Reserved.
Jo ined ! !
Copyright (C) 2013 microbase.LLC All Rights Reserved.
Map Des ign
Copyright (C) 2013 microbase.LLC All Rights Reserved.
Exerc ise1
Add following data in the folder “tokyo23”.
subway.shp (Line data: a subway in Tokyo Special district)
station.shp (Point data: a station in Tokyo Special district)
convenience.shp (Point data: a convenience store in Tokyo Special district)
elevation.shp (Polygon data: an terrain data in Tokyo special
district)
Again
Copyright (C) 2013 microbase.LLC All Rights Reserved.
Change point s ty les
Click “Property” on the right mouse button station(or double click the layer).
Copyright (C) 2013 microbase.LLC All Rights Reserved.
Open the window “ layer proper ty” and choose “sty le” tab.
Copyright (C) 2013 microbase.LLC All Rights Reserved.
“Symbol proper t ies” window wi l l open .
1) Change symbol layer type to “SVG mar ker”
2) Choose a mar k of “ t r a in” f rom the image l i s t .
Copyright (C) 2013 microbase.LLC All Rights Reserved.
The stat ion symbol has changed .
Copyright (C) 2013 microbase.LLC All Rights Reserved.
Uncheck the check box other than “elevation” layer and open its properties(or double click the layer).
Change polygon sty les
Copyright (C) 2013 microbase.LLC All Rights Reserved.
Change a co lor of “e levat ion layer” accord ing to e levat ion va lue .
Low High
Genera l ly, h igher area co lor s warm color(ex . red ,ye l low) . Lower area co lor s co ld co lor(ex . blue ,green) .
Copyright (C) 2013 microbase.LLC All Rights Reserved.
1) Choose “Graduated”. 2) Choose a column “ELEV” which has elevation value.
3) Choose any color ramp. An original color ramp can be made.
4) Choose a number of classed and a classification mode.
5) Finally, click “Classify”. Then the classification result will be displayed above.
If you’d like to arrange your way, just click “Symbol color”, “Range” and “Label”.
Copyright (C) 2013 microbase.LLC All Rights Reserved.
Resu l t
Copyright (C) 2013 microbase.LLC All Rights Reserved.
Change par t ia l symbol s ty les
show different markers depending on attributes.
Copyright (C) 2013 microbase.LLC All Rights Reserved.
1) Choose “Graduated”.
2) Choose and double click a rule row which you’d like to change. Then the rule property will open.(Default setting has no rule)
Copyright (C) 2013 microbase.LLC All Rights Reserved.
4) Input “CNAME LIKE ‘Circle%’ on “Expression” form. (or “CNAME = “circleK”)
‘LIKE’ : partial matching‘=‘ : perfect matching
3)Input any name in “Label” form. Click “...” next to “Filter” form.
5) Marker type can be chosen as mentioned before.
A filter rule can be input from “Expression string builder”.
Copyright (C) 2013 microbase.LLC All Rights Reserved.
Existing rule has been edited.
If you’d like to add an another rule or delete
Copyright (C) 2013 microbase.LLC All Rights Reserved.
Only “Circ leK” has been d isp layed .
Copyright (C) 2013 microbase.LLC All Rights Reserved.
Disp lay a labe l
1) Choose “Label” tab from tab menu in Properties “ku”
2) check the checkbox of “Display labels”.
3) Choose “NAME” in “Field containing label” form.
Copyright (C) 2013 microbase.LLC All Rights Reserved.
The name of “ku” has been d isp layed as a labe l on the polygon data .
Copyright (C) 2013 microbase.LLC All Rights Reserved.
Exerc ise 2
1) Delete the label “ku”.
2) Add pop.shp(population on street scale).
3) Classify poplation in 1995(“P1995”) into 4 categories as follows.
class 1 : 0 ~ 1000 (blue)
class 2 : 1001 ~ 2500 (green)
class 3 : 2501 ~ 5000 (yellow)
class 4 : 5001 ~ (red)
Copyright (C) 2013 microbase.LLC All Rights Reserved.
Hint
Copyright (C) 2013 microbase.LLC All Rights Reserved.
Answer
Copyright (C) 2013 microbase.LLC All Rights Reserved.
Map Expor t
Export your map an imagery file for printing. QGIS has an additional function such as adding a direction symbol and a scale bar for printing.
Click “New print composer” icon from toolbars.
Add a map, symbols and others to Initial screen from the menu.
Copyright (C) 2013 microbase.LLC All Rights Reserved.
1) Click “Add new map” icon
Add a map into composer screen
2) Drag at any place on the composer screen while choosing “Add new map” icon
map size and other settings can be adjusted freely.
Copyright (C) 2013 microbase.LLC All Rights Reserved.
Those elements can be modified from “Item Properties” at the right side
Add icon and pictures.
Add Label
Add legend
Export as an imagery, PDF, SVG.
Copyright (C) 2013 microbase.LLC All Rights Reserved.
Contents Today
1st session
1 What’s QGIS?
2 Basic usage
3 Basic data management
4 Map Design
Copyright (C) 2013 microbase.LLC All Rights Reserved.
HOMEWORK
Copyright (C) 2013 microbase.LLC All Rights Reserved.
DATA
homework1
pref_pop.csv
Japan_pref.shp
Copyright (C) 2013 microbase.LLC All Rights Reserved.
(1) Add “Japan_pref.shp” and “pref_pop.csv” on layer.
(2) Join “Japan_pref” layer with “pref_pop” and save it as “Japan_pref_new.shp”.
(3) Calculate population density in all prefecture using both “pop2010” and “pop2035” field.
(4) Classify the poplation density in 2010 and 2035 into 5 categories.