0% found this document useful (0 votes)
82 views

PGIS Practical

The document discusses exploring and managing raster data in GIS. It describes how to add raster layers from population density datasets, set the projection and style the rasters. It also demonstrates performing raster analysis by calculating the difference between population values from 1990 and 2000 rasters. The document further explains raster mosaicking and clipping operations.

Uploaded by

bgmihack4253
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
82 views

PGIS Practical

The document discusses exploring and managing raster data in GIS. It describes how to add raster layers from population density datasets, set the projection and style the rasters. It also demonstrates performing raster analysis by calculating the difference between population values from 1990 and 2000 rasters. The document further explains raster mosaicking and clipping operations.

Uploaded by

bgmihack4253
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 70

Name: -Prem Lalsahab Pandey

Class: - TYBSCIT
Subject: - Principles Of Geographic Information Systems
Roll No: - 22
Principles of Geographic Information System

INDEX
SRNO. PRACTIC DATE SIGN
AL
1A Creating and Managing Vector Data
Adding vector layer
B Setting properties
C Vector Layer Formatting
D Calculating line lengths and statistics
2A Adding raster layers
B Raster Styling and Analysis
C Raster Mosaicking and Clipping
3A Making a Map
B Importing Spreadsheets or CSV files
C Using Plugin
D Searching and Downloading OpenStreetMap
Data
4A Working with attributes
B Terrain Data and Hill shade analysis
5A Working with Projections and WMS Data
6A Georeferencing Topo Sheets and Scanned Maps
B Georeferencing Aerial Imagery
C Digitizing Map Data
7A Table Joins
B Spatial Joins
C Poiny In polygon Analysis
D Performing Spatial Quaries
8A Nearest Neighbor Analysis
B Sampling raster data using points or polygon
C Interpolating Point Data Procedure

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System

PRACTICAL -1
a) Creating Polygon vector layer
Select Project >> New
Select Layer >> Create Layer >> New Shapefile Layer

Following dialog box will appear on the screen. Select Polygon option from Geometry type
Fill the appropriate information in each text box.
By default the file will be saved in bin folder.
To avoid it click on following button to change the location of file.
Field Panel Add the Attribute you want to show.(Text Data/Decimal Data/Whole Number/Date) of
Attribute.
Click on Add to field list button.
You can add Fields (Column Name) as you want for the Layer.
Select Geometry type, CRS dialog box will appear on Screen. Click on the WGS84 option and it will be
selected as follows.

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System

Select the Polygon Feature( In our case it is Thane for background) from layer panel

Save the newly added polygon as follows

Set style for polygon by using property window(Right click on Thane Layer)

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System

Same way we can add one more polygon layer for Gardens.

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System

b) Creating Line vector layer


Repeat the same steps as we have done for polygon layer.

Select geometry type Line.

Click on Add Line Feature. You want to draw line.

save your data

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System

set style for Roads in the same way as we have done for polygon
To label your roads Right click on Road layer .Go to properties window then select label andset
single label property

Roads will look like these

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System

C. Create Point vector layer

Repeat same steps to add point layers as we have done in previous layers.(ForATM,
Restaurants, Banks, Bus Stops etc)

Final output:

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System

d) Calculating line lengths and statistics

Go to Layer > Add Layer > Add Vector Layer


Add the following file to project

"\GIS_Workshop\Practicals\Practical_01\D\DATA\IND_rrd\IND_rails.shp"
Press “ADD”
Also add India Administrative Map
“GIS_Workshop\Practicals\Practical_01\D\DATA\IND_adm\IND_ad
m0.shp”
Double Click on IND_adm0
Select SYMBOLOGY >> Select any outline style from below given options

Press OK
The display window will appear like

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System

In Layer Pane, Right click on IND_rails >> Open Attribute Table

Press Toggle Editing button using button, on Attribute table window toolbar.
Press Open Field Calculator using calculator button.
Set the output field as “Track_Len”, field type to “Decimal Number”.
Use Expression as: $length/1000

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System

Press “OK”
A new column is added to the attribute table with value representing the length of track in KM.

Press CTRL+S or click on Save Edits option on tool bar


Close the attribute table window.
For calculating the total length of Railway tracks in India.
Select Vector >> Analysis Tools >> Basic Statics for Fields

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System

Press RUN

Open the “output.html” file to get the field statistics.

The above statistics show that the total length of Railway track in India is 60,479.32 KM.

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System

PRACTICAL – 2

Exploring and Managing Raster data:

a) Adding raster layers


From menu bar select Layer >> Add Layer >> Add Raster Layer
Select Gridded Population of the World (GPW) v3 dataset from Columbia University,
Population Density Grid for the entire globe in ASCII format and for the year 1990 and 2000.
“\GIS_Workshop\Practicals\Practical_02\A\Data\gl_gpwv3_pdens_90_ascii_one\glds90ag60.as”
“\GIS_Workshop\Practicals\Practical_02\A\Data\gl_gpwv3_pdens_90_ascii_one\glds00ag60.as”

Go to Project > Properties OR Press the CRS OPTION Set CRS option on bottomright
corner.
Select WGS 84 EPSG: 4326 and Press OK

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System

b) Raster Styling and Analysis

To start with analysis of population data, convert the pixel from grayscale to Color.
Select “glds90ag60.asc” Layer form layer Pane > select property OR double click on it.

Select Symbology

Press APPLY
Repeat the same for “glds00ag60.as” layer

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System

Layer output after applying style.


The objective this experiment is to analyze raster data, as an example we will find areas
with largest population change between 1990 and 2000, by calculating the difference
between eachpixel values.
Go to Raster >> Raster Calculator

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System

Put the expression "glds00ag60@1" - "glds90ag60@1"


Select the output file location & name and Press OK.
Remove the other two layers i.e. glds00ag60.asc and glds90ag60.asc
Double click on pop_diff layer.
Select Symbology

Set Render Type to “Single band Pseudo color”, Interpolation as Discrete, and remove all
classification and add as shown in figure above using button. After all settings press“OK”.
Layer will appear like

Explore an area of your choice and check the raster band value using “i” to verify
theclassification rule.
The red pixel shows negative changes and blue shows positive changes.

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System

C) Raster Mosaicking and Clipping


A mosaic is a combination or merge of two or more images.
In GIS, a single raster dataset can be created from multiple raster datasets by mosaicking
them together.

In many cases, there will be some overlap of the raster dataset edges that are being
mosaickedtogether, as shown below.

These overlapping areas can be handled in several ways; for example, you can choose to only
keepraster data from the first or last dataset, you can blend the overlapping cell values using a
weight- based algorithm, you can take the mean of the overlapping cell values, or you can take
the minimum or maximum value. When mosaicking discrete data, the First, Minimum, or
Maximum options give the most meaningful results. The Blend and Mean options are best suited
for continuous data. If any of the input rasters are floating point, the output is floating point. If all
the inputs are integer and First, Minimum, or Maximum is used, the output is integer.

Go to Layer > Add Layer > Add Raster Layer.

Select the following “.tif” raster images for India from data folder.
FAS_India1.2018349.terra.367.2km.tif FAS_India2.2018349.terra.367.2km.tif
FAS_India3.2018349.terra.367.2km.tif FAS_India4.2018349.terra.367.2km.tif

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System

Press open
In data source manager | Raster window click Add.

Go to Raster > Miscellaneous > Merge.


In the Merge dialog window

Select all layers and Press OK.

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System

In Merge dialog window select a file name and location to save merged images.

Save the file to “GIS_Workshop/Practicals/Practical_02/C/” location with the name


asMerge_Files.tif
Press Run and after completion of operation close the Merge window dialog box.

You can now deselect individual layers from layer pane and only keep the merged raster file.
Go to Layer> Add Vector Layer > Select
\GIS_Workshop\Practicals\Practical_02\C\IndiaAdminBoundry\IND_adm0.shp file.

From layer properties > select > Symbology > select any one of the following

Select Outline (Any Type)


The result will be

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System

Go to Raster > Extraction > Clip Raster by Mask Layer.


Select the merge raster image as input and Ind_adm0 as mask layer.

Select a file name and location for clipped raster as /Practical_02/C/Clipped_File.tif.

Press RUN.

AFTER CLIPPING

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System

Practical-3
a) Making a Map
Create a Thematic map or Existing Ones.
Consider the following map.

Go to Project >> New Print Layout.


Insert a suitable title and press “OK”.

A new Print Layout window will open

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System

Select Add Item >> Add Map

After adding map go to Item Properties > Map1> Layers


Check on Lock Layers and Lock Styles for Layers

Add an inset Using Add Item > Add Picture > Select an area to be highlighted on main Map.
Set a frame for Inset by enabling the check box for Frame.

To highlight the area shown in Inset


Select the Picture representing main Map from Items pane.
In Item Properties > Overviews > using “+” icon add an overview.
Select the checkbox Draw Overview
Name the Picture object representing inset (Map1 in our case).

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System

The Print Layout will appear like

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System

Add Item > Add Label


Change the Label text To “Mumbai Map”, Set appropriate font size and color using Item
Properties > Main Properties.

Add Item > Add Legend > Place the legend indicator at appropriate location.
Uncheck auto update and use suitable legend indicator label.

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System

Add Item > Add Scale Bar

Add Item > Add Label > Add a Label using HTML rendering.

A Map can be saved in Image or PDF using Layout > Export as Image / Export as PDF

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System

Save the Map to a location appropriate location as PDF or Image.

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System

b) Importing Spreadsheets or CSV files

Many times the GIS data comes in a table or an Excel spreadsheet or a list lat/long
coordinates,therefore it has to be imported in a GIS project.
Sample file for Earthquake data will be used in this practical.
Go to Layer > Add Layer > Add Delimited text Layer.
Data Source Manager | Delimited Text window will appear
Select the \GIS_Workshop\Practicals\Practical_03\C\Sample.csv file from data folder.

Press ADD and close the window.


Output:

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System

c) Using Plugins
Core plugins are already part of the standard QGIS installation. To use these, just enable them.
Open QGIS. Click on Plugins Manage and Install Plugins....

To enable a plugin, check on the checkbox next to Plugin. This will enable the plugin to use it.
External plugins are available in the QGIS Plugins Repository and need to be installed by the
usersbefore using them.
Click on Not Installed or Install from ZIP.
Once the plugin is downloaded and installed, you will see a confirmation dialog.
Click on Plugins > <<new Plugin Name>>
The Plugin if marked Experimental plugin can be installed, from Setting > check on.

A tab will be added to Plugin Manager Window.


Click on a plugin name and Click Install.

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System

d) Searching and Downloading OpenStreetMap Data


OpenStreetMap (OSM) created by Steve Coast in the UK in 2004 is a collaborative project to
create a free editable map of the world. Rather than the map itself, the data generated by the projectis
considered its primary output. The creation and growth of OSM has been motivated by restrictions
on use or availability of map information across much of the world, and the advent of inexpensive
portable satellite navigation devices.
Add “Open Layer” and “OSM Search” Plugin from Not Installed option from Plugin
ManagerDialog Box.
The OSM Place Search plugin will install itself as a Panel in QGIS, if not go to View >> Panels
>> select OSM Place Search.
Go to Web >> Open Layer Plugin and select Open Street Map
A World map will appear on screen.
If an error occurs in loading maps, go to project properties > CRS >

In OSM Place search Pane > Enter Mumbai or any place name to search
Double click on the desired place in OSM Place search Panel or Click and press “ZOOM”

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System

PRACTICAL - 4
A. Working with attributes
Start a new project.
Go to Layer > Add Layer > Add Vector Layer
Select “\GIS_Workshop\Practicals\Practical_04\A\Data\ne_10m_populated_places_simple.zip”
Right click on Layer in Layer Panel > Open Attribute Table.
Explore various attributes and their values in the Attribute table.
To find the Place with maximum population click on “pop_max” file.

On clicking the Select feature using expression expression E button the following window will
appear.

Enter pop_max>100 and pop_max<10000 and click Select Features button to get all the
places withpopulation between 100 and 10000.
The places matching the criteria will appear in different color.

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System

b) Terrain Data and Hill shade analysis


A terrain dataset is a multiresolution, TIN-based surface built from measurements stored as
featuresin a geodatabase. Terrain or elevation data is useful for many GIS Analysis like, to generate
various products from elevation data such as contours, hillshade etc.
Go to Layer > Add Raster Layer > select “10n060e_20101117_gmted_mea300.tif”,
fromData folde
Press enter the view port will be centered on Himalaya Region.
Crop the raster layer only for the region under study.
Go to Raster > Extraction> Clip Raster by Extent.

Select the raster layer (if project contains multiple layers).


Select the clipping area by selecting the option Use Canvas Extends if the visible part of
mapis to be selected or manually select an area on canvas by using Select Extent on
Canvas.
Select the location and file name for storing clipped raster layer.
Press RUN.
Deselect the original layer and keep the clipped one.
The Clipped raster layer is representing altitude are from 103 Meters.
Counter lines are the lines on a map joining points of equal height above or below sea level.
A contour interval in surveying is the vertical distance or the difference in the elevation
betweenthe two contour lines in a topographical map.
To derive counter lines from given raster.
Go to Raster > Extraction > Contour

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System

Select the input raster layer name. Set contour interval 100.00 meters, select the output
filename & location and check the option to add output file to project after processing.
Press “RUN”.
The contour layer will appear like this
Press “RUN” and Close the Hill Shape Dialog window.
After Raster styling the Output will appear like this.

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System

PRACTICAL-5
Working with Projections and WMS Data
A Web Map Service (WMS) is a standard protocol developed by the Open Geospatial Consortium in
1999 for serving georeferenced map images over the Internet. These images are typically producedby
amap server from data provided by a GIS database
Start a new Project.
Layer >> Add Layer >> Vector Layer
Select “ne_10m_admin_0_countries.zip” Layer from data folder.
Go to Layer >> Save As
Select format as ESRI Shape File
Select folder location and file name
Set CRS North_America_Albers_Equal_Area_Conic EPSG: 102008

Press “OK”.
Deselect the original Image and keep the projected layer visible.

Select Layer >> Add Layer >> Add Raster Layer >> Select MiniScale_(standard)_R17.tif
fromLocation
“GIS_Workshop\Practicals\Practical_05\DATA\minisc_gb\minisc_gb\data\RGB_TIF_compres
sed\MiniScale_(standard)_R17.tif”

The Layer appears on a different location than the location where Great Britain is shown
onMap.

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System

Open Layer Properties >> CRS >> Search bri >> select British National Grid EPSG 27700.
Processing may take some time.
Locate United Kingdom on Layer; the vector layer exactly coincides by the raster layercovering
United Kingdom

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System

PRACTICAL – 6
Georeferencing
A. Georeferencing Topo Sheets and Scanned Maps
Start a new project
Go to Layers >> Add Layer >> Add vector Layer
Select GIS_Workshop\Manual\Prac06\IND_adm0.shp
Zoom in to Mumbai region in the layer.

Go to Plugins >> Manage and Install Plugins


Ensure that Georeferencer GDAL is checked, if not install Georeferencer GDAL plugin.
Go to Raster >> Georefrencer
A new Georeferencer window will open
File >> Open Raster
Select file “1870_southern-india_3975_3071_600.jpg” from project data folder

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System

Select Transformation type >> Thin Plate


Spline
Re-sampling Method >> Nearest Neighbour
Target TRS >> Everest 1830 datum: EPSG
4044
Select Output Raster Name and Location
Check the Load in QGIS When Done
Option
Press “OK”.

In Georeferencer window Go to Edit >> Add Points

Select the set of control points.


Go to, Setting >> transformation settings.

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System

Press “RUN”
In Georeferencing window go to >> File >> Start Georeferencing
The canvas area will now have the scanned map of Mumbai referenced with control
points.
Select the newly added layer in Layer Panel Right click and go to property.
Set Transparency level of raster layer to appropriate level.

Output:

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System

B. Georeferencing Aerial Imagery

Install plugin OpenStreetMap


Go to Web Menu >> OpenLayerPlugin >> OpenStreetMap >> OpenStreetMap
Go to Project >> Properties >> Set CRS to EPSG 3857
Go to View >> Panels >> select OSM Place search
Zoom in to appropriate level. The map will appear like this

Go to Raster >> Georefrencer A new Georeferencer window will open


File >> Open Raster
Select file “Gateway_Imagery.tif” from project data folder

Go to Edit >> Add Point


Select control points from map (Indicated in red color).
Go to Setting >> Transformation Setting

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System

Go to File >> Start Georeferencing or Press the PLAY button in Georegerencing Window.
The progress indicator will appear
Observe that the aerial image of the Gateway of India is georeferenced on OSM in the map
canvas.

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System

C. Digitizing Map Data


Spatialite is an open database format similar to ESRI's geodatabase format. Spatialite database
is contained within a single file on your hard drive and can contain diferent types of spatial
(point, line, polygon) as well as non-spatial layers. This makes is much easier to move it
around instead ofa bunch of shapefiles.
Digitizing Map Data
Go to Layer ‣ Add Raster >> Select “Christchurch Topo50 map.tif” from project Folder.

QGIS offers a simple solution to make raster load much faster by using Image Pyramids.
Right-click the Christchurch Topo50 map.tif layer and select Properties.
Choose the Pyramids tab. Hold the Ctrl key and select all the resolutions offered in the
Resolutions panel.

Click Build pyramids. Then click OK.


Go to Settings >> Options…….Select the Digitizing tab in the Options dialog.
Set the Default snap mode to vertex and segment.

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System

Press OK.
Go to Layer >> Add Layer >> Add Spatialite Layer.
Select the name and location for Spatial database eg:
“GIS_Workshop\Practicals\Practical_06\C\MySpatialDataBase.sqlite”.
Name the Layer as “Digitized_Road
Set Geometry type as “Line”
Set CRS EPSG:4167 – NZGD2000

Add “Name” and “Class” fields using “Add to Fields List”.


Once the layer is loaded, click the Toggle Editing button to put the layer in editing mode.
Click the Add feature button. Click on the map canvas to add a new vertex.Add new vertices
along the road feature. Once you have digitized a road segment, right-click toend the feature.

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System

On Layer Panel Right Click on Digitze_Road, Select the Style tab in the Layer Properties
dialog
Result

Select appropriate style to see the digitized road feature clearly

After creating a new Spatialite layer


Select Digitized_Garden layer in Layer Panel and click on Toggle Editing button
and then Add Polygon Feature button on Tool bar.
Add two gardens to the region by adding polygon.

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System

The Layer will appear on map canvas

Using the above procedure a point feature can also be digitized.


The digitizing task is now complete. You can play with the styling and labeling options in
layerproperties to create a nice looking map from the data you created

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System

PRACTICAL – 7
Managing Data Tables and Saptial data Sets:
a) Table joins
Start a new project
Go to Layer Add Layer Add new Vector Layer
“I:\GIS_Workshop\Practicals\Practical_07\A\Data\tl_2013_06_tract.zip”
We could import this csv file without any further action and it would be imported. But, the default
type of each column would be a String (text). That is ok except for the D001 field which contains
numbers for the population. Having those imported as text would not allow us to run any
mathematical operations on this column. To tell QGIS to import the field as a number, we need to
create a sidecar file with a .csvt extension.

This file will have only 1 row specifying data types for each column. Save this file as
ca_tracts_pop.csvt in the same directory as the original .csv file.
Go to Layer >> Add Layer >> Add Delimited Text Layer And add
I:\GIS_Workshop\Practicals\Practical_07\A\Data\ca_tacts_pop.csv”

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System

In the layer panel, Right click on “tl_2013_06_tract”, layer and select Properties
Select the JOINS option in Properties, and click on PLUS button to add new table join.
In the Add Vector Join window set the following properties and click OK.

After performing join


For more clear output, select “tl_2013_06_tact” from Layer Panel, right click and select
properties. Go to Symbology and set the following properties

A detailed and accurate population map of California can be seen as the result. Same technique
can be used to create maps based on variety of census data.

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System

b) spatial joins
Go to Layer >> Add Layer >> Add Vector Layer >> Select
“I:\GIS_Workshop\Practicals\Practical_07\B\Data\nybb_12c\nybb_13c_av\nybb.shp” and
“I:\GIS_Workshop\Practicals\Practical_07\B\Data\OEM_NursingHomes_001\OEM_NursingHo
mes_001.shp”, from data folder.
Go to attribute table and observe the data.
Table before performing Join

Go to Vector >> Data Management Tools >> Join Attributes by Location. Attribute table after join

Use the Identify Feature Button to select a region to view join data on map Layer.
Output

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System

c) Points in polygon analysis


Go to Layer >> Add Layer >> Add Delimited Text
LayerSelect “EarthQuakeDatabase.txt”

Go to Layer >> Add Layer >> Add Delimited Text Layer


“I:\GIS_Workshop\Practicals\Practical_07\C\Data\ne_10m_admin_0_countries.zip

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System

Use the select Feature button to check country wise counting of Earthquakes.

Also a new column is added to attribute table “NumPoints” indicating number of earth quakepoints
in each country.

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System

d) Performing spatial queries


Go to Layer >> Add Layer >> Add Vector Layer and load
“\GIS_Workshop\Practicals\Practical_07\D\Data\ne_10m_populated_places_simple\ne_10m_popul
ated_places_simple.shp” and
“I:\GIS_Workshop\Practicals\Practical_07\D\Data\ne_10m_rivers_lake_centerlines\ne_10m_rivers
_lake_centerlines.shp” from project data folder.

Open project Properties >> Set CRS “World_Azimuthal_Equidistant EPSG 54032” . The map will
be re-projected as

Go to Vector >> Geoprocessing Tool >> Buffer


Repeat the step to create River Buffer
Create a buffer for River

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System

Go to Vector >> Research Tool >> Select By Location

This will highlight only those rivers containing a populated place within 2 KM

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System

PRACTICAL – 8
a) Nearest Neighbor Analysis
Go to Layer >> add Layer >> add Delimited Text Layer and load “signif.txt” from data file.

Go to Layer >> Add Layer >> Add vector Layer and from data folder
“\GIS_Workshop\Practicals\Practical_08\A\DATA\ne_10m_populated_places_simple.zip” loadthe
layer to the project and remove all rows from attribute table other than India.

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System

Go to Vector >> Analysis tool >> Distance Matrix

Calculate the Distance matrix and perform Nearest Neighbor Analysis


Now you will be able to see the content of our results. The InputID field contains the field namefrom
the Earthquake layer. The TargetID field contains the name of the feature from the Populated Places
layer that was the closest to the earthquake point. The Distance field is the distance between the 2
points.
Here select the earthquake layer signif as the Input point layer and the populated places
ne_10m_populated_places_simpleas the target layer. You also need to select a unique field from eachof
these layers which is how your results will be displayed. In this analysis, weare looking to get only1
nearest point, so check the Use only the nearest(k) target points, and enter 1. Name your output file
matrix.csv, and click OK. Once the processing finishes,click Close.

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System

Once the processing finishes, click the Close button in the Distance Matrix dialog. You
can nowview the matrix.csv file in Notepad or any text editor. QGIS can import CSV
files as well, so we will add it to QGIS and view it there. Go to Layer ‣ Add Layer
‣ Add Delimited Text Layer....
Browse to the newly created matrix.csv file. Since this file is just text columns, select
Nogeometry (attribute only table) as theGeometry definition. Click OK.

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System

You will see the CSV file loaded as a table. Right-click on the table layer and select
OpenAttribute Table.
Now you will be able to see the content of our results. The InputID field contains the
field namefrom the Earthquake layer. The TargetID field contains the name of the
feature from the Populated Places layer that was the closest to the earthquake point. The

Distance field is the distance between the 2 points.


This is very close to the result we were looking for. For some users, this table wouldbe
sufficient. However, we can also integrate this results in our original Earthquake
layer usinga Table Join. Right-click on the Earthquake layer, and select Properties.
Go to the Joins tab and click on the + button.

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System

We want to join the data from our analysis result to this layer. We need to select a
field fromeach of the layers that has the same values. Select matrix as the Join layer`
and InputID as the Join field. The Target field would be I_D. Leave other options to

their default values andclick OK.

You will see the join appear in the Joins tab. Click OK.

Now open the attribute table of the signif layer by right-clicking and selecting Open
AttributeTable.

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System
You will see that for every Earthquake feature, we now have an attribute which is the
nearestneighbor (closest populated place) and the distance to the nearest neighbor.

We will now explore a way to visualize these results. First, we need to make the
table joinpermanent by saving it to a new layer. Right-click the signif layer and
select Save As....
Click the Browse button next to Save as label and name the output layer as
earthquake_with_places.shp. Make sure the Add saved file to map box is checked andclick OK.

Once the new layer is loaded, you can turn off the visibility of the signif layer. As our dataset
isquite large, we can run our visualization analysis on a subset of the data. QGIS has a neat
feature where you can load a subset of features from a layer without having to export it to a
newlayer. Right-click the earthquake_with_places layer and select Properties.
In the General tab, scroll down to the Feature subset section. Click Query Builder.

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System

For this tutorial, we will visualize the earthquakes and their nearest populated places for
Mexico. Enter the following expression in the Query Builder dialog.
"COUNTRY" = 'MEXICO'

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System

You will see that only the points falling within Mexico will be visible in the canvas.
Let’s do the same for the populated places layer. Right-click on the
ne_10m_populated_places_simple layer and select Properties.
Open the Query Builder dialog from the General tab. Enter the following expression.
"adm0name" = 'Mexico'

Now we are ready to create our visualization. We will use a plugin named MMQGIS.
Find andinstall the plugin. See Using Plugins for more details on how to work with
plugins. Once you have the plugin installed, go to MMQGIS >> Create >> Hub Lines.

Select ne_10m_populated_places_simple as the Hub Point Layer and name as the Hub ID
Attribute. Similarly, selectearthquake_with_places as the Spoke Point Layer and
matrix_Tar as the Spoke Hub ID Attribute. The hub lines algorithm will go through each
of earthquake points and create a line that will join it to the populated place which
matches the attribute we specified.Click Browse and name the Output Shapefile as
earthquake_hub_lines.shp. Click OK to start the processing.

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System

The processing may take a few minutes. You can see the progress on the bottom-left
corner ofthe QGIS window.

Once the processing is done, you will see the earthquake_hub_lines layer loaded in
QGIS. You can see that each earthquake point now has a line that connects it to the
nearest populated place.

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System

B) Sampling Raster Data using Points or Polygons


Many scientific and environmental datasets come as gridded rasters. Elevation data (DEM)is
also distributed as raster files. In these raster files, the parameter that is being represented is
encoded as the pixel values of the raster. Often, one needs to extract the pixel values at certain
locations or aggregate them over some area. This functionality is available in QGIS via two plugins
- Point SamplingTool and Zonal Statistics plugin.

Procedure
Go to Layer >> Add Raster Layer and browse to the
downloaded us.tmax_nohads_ll_{YYYYMMDD}_float.tif file and click Open.
Once the layer is loaded, select the Identify tool and click anywhere on the layer. You will see
the temperature value in celsius as the value or Band 1 at that location.

Now unzip the downloaded 2013_Gaz_ua_national.zip file and extract the


2013_Gaz_ua_national.txt file on your disk. Go to Layer ‣ Add Delimited Text Layer.

In the Create a Layer from Delimited Text File dialog, click Browse and open
2013_Gaz_ua_national.txt. Choose Tab under Custom delimiters. The point coordinatesare in Latitude
and Longitude, so select INTPTLONG as X field and INTPTLAT as Y field. Check the Use spatial
index box and click OK.

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System

Now we are ready to extract the temperature values from the raster layer. Install the Point Sampling
Tool plugin. See Using Plugins for details on how to install plugins.

Open the plugin dialog from Plugins >> Analyses >> Point sampling tool.
In the Point Sampling Tool dialog, select 2013_Gaz_ua_national as the Layer containing
sampling points. We must explicitely pick the fields from the input layer that we want in the
output layer. Choose GEOID and NAME fields from the2013_Gaz_ua_national layer. We can
sample values from multiple raster band at once, but since our raster has only 1 band, choose
the us.tmax_nohads_ll_{YYYYMMDD}_float: Band 1. Name the output vector layer as
max_temparature_at_urban_locations.shp. Click the OK to start the sampling process.Click Close once
the process finishes.

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System

You will see a new layer max_temparature_at_urban_locations loaded in QGIS. Use the Identify toolto
click on any point to see the attributes. You will see the us.tmax_no field -which contains the raster pixel
value at the location of the point.

First part of our analysis is over. Let’s remove the unnecessary layers. Hold the Shift key and
select max_temparature_at_urban_locations and 2013_Gaz_ua_national layers. Right-click and
select Remove to remove them from QGIS TOC.
Go to Layer >> Add Vector Layer. Browse to the downloaded tl_2013_us_county.zip file
and click Open. Select thetl_2013_us_county.shp as the layer and click OK.
The tl_2013_us_county will be added to QGIS. This layer is in EPSG:4269 NAD83
projection.This doesn’t match the projection of the raster layer. We will re-project this layerto
EPSG:4326 WGS84 projection.
Right-click the tl_2013_us_county layer and select Save As...
In the Save Vector layer as.. dialog, click Browse and name the output file as counties.shp.
Choose Selected CRS from the CRS dropdown menu. Click Browse and select WGS 84 as the
CRS. Check the Add saved file to map and click OK.

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System

A new layer named counties will be add to QGIS.

Enable the Zonal Statistics Plugins. This is a core plugin so it is already installed. See Using
Plugins to know to how enable core plugins.

Go to Raster >> Zonal statistics >> Zonal statistics.


Select us.tmax_nohads_ll_{YYYYMMDD}_float as the Raster layer and counties as the Polygon
layer containing the zones. Enter ZS_ as the Output column prefix. Click OK.

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System

The analysis may take some time depending on the size of the dataset.
Once the processing finishes, select the counties layer. Use the Identify tool and click on any
county polygon. You will see three new attributes added to the layer: ZS_count, ZS_mean and
ZS_sum. These attributes contain the count of raster pixels, mean of raster pixel values and sum of
raster pixel values respectively. Since we are interestedin average temperature, the ZS_meanfield will
be the one to use.

Let’s style this layer to create a temperature map. Right-click the counties layer and
select Properties.
Switch to the Style tab. Choose Graduated style and select ZS_mean as the Column. Choosea
Color Ramp and Mode of your chose. Click Classify to create the classes. Click OK.

You will see the county polygons styled using average maximum temperature extracted from
the raster grid.

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System

c) Interpolating Point Data


Procedure
Open QGIS. Go to Layer >> Add Layer >> Add Vector Layer..
Browse to the downloaded Shapefiles.zip file and select it. Click Open.
In the Select layers to add... dialog, hold the Shift key and select
Arlington_Soundings_2007_stpl83.shp andBoundary2004_550_stpl83.shp layers.Click OK.
You will see the 2 layers loaded in QGIS. The Boundary2004_550_stpl83 layer represents the
boundary of the lake. Un-check the box next to it in the Table of Contents.

This will reveal the data from the second layer Arlington_Soundings_2007_stpl83. Though the
data looks like lines, it is a series of points that are very close.

Click the Zoom icon and select a small area on the screen. As you zoom closer, you will see the
points. Each point represents a reading taken by a Depth Sounder at the location recorded by a
DGPS equipment.

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System

Select the Identify tool and click on a point. You will see the Identify Results panel show up on
the left with the attribute value of the point. In this case, the ELEVATION attribute contains the
depth of the lake at the location. As our task is to create a depth profile and elevation contours,we will use
this values as input for the interpolation.
Make sure you have the Interpolation plugin enabled. See Using Plugins for how to enable
plugins. Once enabled, go toRaster >> Interpolation ‣ Interpolation.
In the Interpolation dialog, select Arlington_Soundings_2007_stpl83 as the Vector layers in
the Input panel. Select ELEVATION as the Interpolation attribute. Click Add. Change the
Cellsize X and Cellsize Y values to 5. This value is the size of each pixel in the output grid.
Since our source data is in a projected CRS with Feet-US as units, based on our selection,
the grid size will be 5 feet. Click on the ... button next to Output file and name the output
fileas elevation_tin.tif. CLick OK.

You will see the new later elevation_tin loaded in QGIS. Right-click the layer and select Zoomto
layer.
Now you will see the full extent of the created surface. Interpolation does not give accurate
results outside the collection area. Let’s clip the resulting surface with the lake boundary. Goto
Raster >> Extraction >> Clipper.

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System

Name the Output file as elevation_tin_clipped.tif. Select the Cliiped mode as Mask layer.Select

Boundary2004_550_stpl83 as the Mask layer`. Click OK.


A new raster elevation_tin_clipped will be loaded in QGIS. We will now style this layer to
show the difference in elevations. Note the min and max elevation values from the
elevation_tin layer. Right-click the elevation_tin_clipped layer and select Properties.

Go to the Style tab. Select Render type as Singleband pseudocolor. In the Generate new color
map panel, select Spectralcolor ramp. As we want to create a depth-map as opposed to a height-
map, check the Invert box. This will assign blues to deep areas and reds to shallow areas.
Click Classify
Switch to the Tranparency tab. We want to remove the black-pixels from our output. Enter 0 as
the Additional no data value. Click OK.
Now you have a elevation relief map for the lake generated from the individual depth readings.
Let’s generate contours now. Go to Raster >> Extraction >> Contours.
In the Contour dialog, enter contours as the Output file for contour lines. We will generate
contour lines at 5ft intervals, so enter 5.00 as the Interval between contour lines. Check the

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System

The contour lines will be loaded as contours layer once the processing is finished. Right-click

the layer and select Properties.


Go to the Labels tab. Check the Label this layer with box and select ELEV as the field.
Select Curved as the Placement type and click OK.

You will see that each contour line will be appropriately labeled with the elevation along the
line.

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)


Principles of Geographic Information System

SHETH N.K.T.T. COLLEGE, THANE TY.BSCIT (2023-24)

You might also like