77
Copyright (C) 2013 microbase.LLC All Rights Reserved. Geographic Information System QGIS Introduction(1) microbase.LLC http://microgeodata.com/

QGIS training class 1

Embed Size (px)

DESCRIPTION

合同会社マイクロベースのQGIS演習資料(ver.1.8)です。ご希望にしたがって研修内容を構成します。研修のご依頼をご希望の方は弊社ホームページよりお問い合わせください。 http://microgeodata.com/ 製作・協力: 仙石裕明・東郷直子・秋山祐樹

Citation preview

Page 1: QGIS training class 1

Copyright (C) 2013 microbase.LLC All Rights Reserved.

Geographic Information SystemQGIS Introduction(1)

microbase.LLChttp://microgeodata.com/

Page 2: QGIS training class 1

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

Page 3: QGIS training class 1

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

Page 4: QGIS training class 1

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

Page 5: QGIS training class 1

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

Page 6: QGIS training class 1

Copyright (C) 2013 microbase.LLC All Rights Reserved.

Bas ic usage

Page 7: QGIS training class 1

Copyright (C) 2013 microbase.LLC All Rights Reserved.

2.1 Launch QGIS

• Double click the QGIS shortcut icon on desktop

• The window will open.

Page 8: QGIS training class 1

Copyright (C) 2013 microbase.LLC All Rights Reserved.

QGIS window will open like below.

Page 9: QGIS training class 1

Copyright (C) 2013 microbase.LLC All Rights Reserved.

toolbar menu

map viewLayer

map info / settings

topmenu

Page 10: QGIS training class 1

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.

Page 11: QGIS training class 1

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

Page 12: QGIS training class 1

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

Page 13: QGIS training class 1

Copyright (C) 2013 microbase.LLC All Rights Reserved.

Exercise data

lecture1_data

tokyo23

homework1

Page 14: QGIS training class 1

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.

Page 15: QGIS training class 1

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>

Page 16: QGIS training class 1

Copyright (C) 2013 microbase.LLC All Rights Reserved.

1) Click “Add vector layer”

2) Browse file

3) Open

Add “ku.shp” in “tokyo23” folder.

Page 17: QGIS training class 1

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.

Page 18: QGIS training class 1

Copyright (C) 2013 microbase.LLC All Rights Reserved.

Tokyo special districts are displayed.

Page 19: QGIS training class 1

Copyright (C) 2013 microbase.LLC All Rights Reserved.

Disp lay a feature

1) Click “Identify Feature”

2) Click a feature

Page 20: QGIS training class 1

Copyright (C) 2013 microbase.LLC All Rights Reserved.

Shibuya info can be shown in a new window.

Page 21: QGIS training class 1

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

Page 22: QGIS training class 1

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)

Page 23: QGIS training class 1

Copyright (C) 2013 microbase.LLC All Rights Reserved.

Hint

You can select plural files while pushing Ctrl key ( or Command key).

Page 24: QGIS training class 1

Copyright (C) 2013 microbase.LLC All Rights Reserved.

Answer

Page 25: QGIS training class 1

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

Page 26: QGIS training class 1

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.

Page 27: QGIS training class 1

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.

Page 28: QGIS training class 1

Copyright (C) 2013 microbase.LLC All Rights Reserved.

Bas ic data management

Page 29: QGIS training class 1

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.

Page 30: QGIS training class 1

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”.

Page 31: QGIS training class 1

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.

Page 32: QGIS training class 1

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”.

Page 33: QGIS training class 1

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 )

Page 34: QGIS training class 1

Copyright (C) 2013 microbase.LLC All Rights Reserved.

12 cities are selected.

Deselect

Page 35: QGIS training class 1

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

Page 36: QGIS training class 1

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

Page 37: QGIS training class 1

Copyright (C) 2013 microbase.LLC All Rights Reserved.

Answer

PERIMETER >= 50000 AND NOT AREA < 50000000

Page 38: QGIS training class 1

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.

Page 39: QGIS training class 1

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

Page 40: QGIS training class 1

Copyright (C) 2013 microbase.LLC All Rights Reserved.

CSV data has been added.

Page 41: QGIS training class 1

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

Page 42: QGIS training class 1

Copyright (C) 2013 microbase.LLC All Rights Reserved.

You can join / unjoin other data more.

“ku_pop” layer is joined to “ku” layer.

Page 43: QGIS training class 1

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”

Page 44: QGIS training class 1

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”.

Page 45: QGIS training class 1

Copyright (C) 2013 microbase.LLC All Rights Reserved.

Open “ku_pop.shp” and check that the attribute table is joined one or not.

Page 46: QGIS training class 1

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]

Page 47: QGIS training class 1

Copyright (C) 2013 microbase.LLC All Rights Reserved.

Togg le ed i t mode

Toggle edit mode before calculate field.

Page 48: QGIS training class 1

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.

Page 49: QGIS training class 1

Copyright (C) 2013 microbase.LLC All Rights Reserved.

to int ( ) = ( ) 内のフィールド値を整数に変換

Fill as above

Page 50: QGIS training class 1

Copyright (C) 2013 microbase.LLC All Rights Reserved.

Jo ined ! !

Page 51: QGIS training class 1

Copyright (C) 2013 microbase.LLC All Rights Reserved.

Map Des ign

Page 52: QGIS training class 1

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

Page 53: QGIS training class 1

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).

Page 54: QGIS training class 1

Copyright (C) 2013 microbase.LLC All Rights Reserved.

Open the window “ layer proper ty” and choose “sty le” tab.

Page 55: QGIS training class 1

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 .

Page 56: QGIS training class 1

Copyright (C) 2013 microbase.LLC All Rights Reserved.

The stat ion symbol has changed .

Page 57: QGIS training class 1

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

Page 58: QGIS training class 1

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) .

Page 59: QGIS training class 1

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”.

Page 60: QGIS training class 1

Copyright (C) 2013 microbase.LLC All Rights Reserved.

Resu l t

Page 61: QGIS training class 1

Copyright (C) 2013 microbase.LLC All Rights Reserved.

Change par t ia l symbol s ty les

show different markers depending on attributes.

Page 62: QGIS training class 1

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)

Page 63: QGIS training class 1

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”.

Page 64: QGIS training class 1

Copyright (C) 2013 microbase.LLC All Rights Reserved.

Existing rule has been edited.

If you’d like to add an another rule or delete

Page 65: QGIS training class 1

Copyright (C) 2013 microbase.LLC All Rights Reserved.

Only “Circ leK” has been d isp layed .

Page 66: QGIS training class 1

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.

Page 67: QGIS training class 1

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 .

Page 68: QGIS training class 1

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)

Page 69: QGIS training class 1

Copyright (C) 2013 microbase.LLC All Rights Reserved.

Hint

Page 70: QGIS training class 1

Copyright (C) 2013 microbase.LLC All Rights Reserved.

Answer

Page 71: QGIS training class 1

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.

Page 72: QGIS training class 1

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.

Page 73: QGIS training class 1

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.

Page 74: QGIS training class 1

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

Page 75: QGIS training class 1

Copyright (C) 2013 microbase.LLC All Rights Reserved.

HOMEWORK

Page 76: QGIS training class 1

Copyright (C) 2013 microbase.LLC All Rights Reserved.

DATA

homework1

pref_pop.csv

Japan_pref.shp

Page 77: QGIS training class 1

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.