PGIS Practical File (Finalised)
PGIS Practical File (Finalised)
MANUAL
1
PRACTICAL NO: 1
Our aim is to create map representing a location and its surrounding as follows:
2
1A) Creating Polygon vector layer
➢ Select Project→New
➢ Select Layer→Create Layer→New Shapefile Layer
➢ Select Polygon option from Geometry type.
3
➢ Click Toggle Editing Button → Click on Add Polygon →Now place the cursor
at the location where you want to place the polygon. for polygon layer minimum 3 points
should be selected
4
➢ Same way we can add one more polygon layer for Gardens.
5
6
1b Creating Line vector layer
➢ Repeat the same steps as we have done for polygon layer.
➢ Select geometry type Line.
➢ Road layer :
➢ To plot road click on Add Line Feature.
➢ set style for Roads in the same way as we have done for polygon
7
➢ To label your roads Right click on Road layer .Go to properties window then select label and
set single label property
➢ Following window will appear on the screen
➢ To merge roads
• Go to properties of road then select symbology. Click on Advanced button select
Symbol levels.
8
1C. Create Point vector layer
➢ Repeat same steps to add point layers as we have done in previous layers.(For
ATM, Restaurants, Banks, Bus Stops etc)
Final output:
9
PRACTICAL NO.2
Select SYMBOLOGY→ Select any outline style from below given options.
Press OK
➢ The display window will appear like
10
➢ In Layer Pane, Right click on IND_rails → Open Attribute Table
➢ Press Toggle Editing button using button , on Attribute table window toolbar.
Press “OK”
➢ A new column is added to the attribute table with value representing the length of track in
KM.
11
➢ 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.
12
PRACTICAL NO: 3
Exploring and Managing Raster data:
AIM: 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.asc”
“\GIS_Workshop\Practicals\Practical_02\A\Data\gl_gpwv3_pdens_90_ascii_one\
glds00ag60.asc”
13
3B)AIM: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
➢ Press “APPLY”
➢ Repeat the same for “glds00ag60.asc” Layer
➢ Select
➢ 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
14
“OK”.
➢ Layer will appear like
➢ Explore an area of your choice and check the raster band value using to verify the
classification rule.
➢ The red pixel shows negative changes and blue shows positive changes.
15
PRACTICAL N0.4
AIM: 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 mosaicked
together, as shown below.
These overlapping areas can be handled in several ways; for example, you can choose to only
keep
raster 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.
India-01.tif
India-02.tif
India-03.tif
India-04.tif
India-05.tif
16
➢ Press open
➢ In data source manager | Raster window click Add.
17
➢ 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 as
Merge_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.
18
➢ The result will be
19
PRACTICAL NO.5
20
➢ After adding map go to ItemProperties → Map1→ Layers
Check on Lock Layers and Lock Styles for Layers
This will ensure that if any change in layers or change their styles, the Print Layout view will not
change.
➢ Go to Add Item → Add Picture → Place a picture box at appropriate location.
➢ 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.
21
➢ The Print Layout will appear like
➢ Add Item → Add Legend→ Place the legend indicator at appropriate location.
22
➢ Uncheck auto update and use suitable legend indicator label.
➢ The Print Layout will appear
23
PRACTICAL NO.6
6A)AIM: 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
24
6B) AIM: 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
users
before 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
or
25
PRACTICAL NO.7
➢ Enter pop_max>100 and pop_max<10000 and click button SELECT FEATURES to get all the
places with population between 100 and 10000.
26
➢ Different queries can be performed using the dataset.
➢ Try this
Will give-
PRACTICAL NO.8
27
AIM: Terrain Data and Hill shade analysis
A terrain dataset is a multiresolution, TIN-based surface built from measurements stored as
features
in 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.
28
➢ The Lower altitude regions are shown using dark color and higher using light shade as seen
on
top region containing Himalaya and Mt Everest.
➢ Mt. Everest - is located at the coordinates 27.9881° N, 86.9253° E.
➢ Enter 86.92, 27.98 in the coordinate field, Scale 900000 and Magnifier 100% at the bottom of
QGIS.
29
➢ 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 map
is 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.
30
➢ Select the input raster layer name. Set contour interval 100.00 meters, select the output file
name & location and check the option to add output file to project after processing.
➢ Press “RUN”.
➢ The contour layer will appear like this
➢ Label the layer using “ELEV” field and set appropriate symbols for line.
➢ In the Layer panel right click on Contour Raster Layer and select “Open Attribute table”,
➢ Arrange the table in descending order based on the value of “ELEV” column.
31
Compare the above counter line raster layer with the previous Google map image or visit
https://www.google.com/maps/@27.9857765,86.9285378,14.75z/data=!5m1!1e4?hl=en-US
➢ To verify the above contour files using Google Map
➢ Make a copy of Contour Layer, Go to Layer →Save As
➢ Select file format as “Keyhole Markup Language”, set file name, location and Layer Name.
➢ Also set CRS to WGS 84 EPSG:4326
32
PRACTICAL NO.9
Managing Data Tables and Saptial data Sets:
9A) AIM :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”
33
➢ In the layer panel, Right click on “tl_2013_06_tract”, layer and select Properties
➢ Select the option + in Properties, and click on button ADD to add new table join.
➢ In the Add Vector Join window set the following properties and click OK.
34
➢ 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.
35
➢ 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.
36
9B) AIM :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.
37
➢ Attribute table after join
➢ Use the Identify Feature Button to select a region to view join data on map Layer.
➢ Output
38
PRACTICAL NO 10
39
➢ Use the select Feature button to check country wise counting of Earthquakes.
40
41
10B) AIM :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
42
➢ Go to Vector → Geoprocessing Tool → Buffer
43
➢ Create a buffer for River
44
➢ This will highlight only those rivers containing a populated place within 2 KM
45
PRACTICAL NO.11
Advanced GIS Operations 1:
AIM :Nearest Neighbor Analysis
➢ Go to Layer → add Layer → add Delimited Text Layer and load “EarthQuackeDataBase.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” load
the layer to the project and remove all rows from attribute table other than India.
46
➢ Go to Vector→ Analysis tool → Distance Matrix
47
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 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 each of these layers which is how your results will be displayed. In this analysis, we
are looking to get only 1 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.
Once the processing finishes, click the Close button in the Distance Matrix dialog. You can now
view 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....
48
9. Browse to the newly created matrix.csv file. Since this file is just text columns, select No
geometry (attribute only table) as theGeometry definition. Click OK.
10. You will see the CSV file loaded as a table. Right-click on the table layer and select Open
Attribute Table.
11. Now you will be able to see the content of our results. The InputID field contains the field
name
from 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.
12. This is very close to the result we were looking for. For some users, this table would be
sufficient. However, we can also integrate this results in our original Earthquake layer using
a Table Join. Right-click on the Earthquake layer, and select Properties.
13. Go to the Joins tab and click on the + button.
14. We want to join the data from our analysis result to this layer. We need to select a field
from each 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 and
click OK.
15. You will see the join appear in the Joins tab. Click OK.
49
16. Now open the attribute table of the signif layer by right-clicking and selecting Open
Attribute Table.
17. You will see that for every Earthquake feature, we now have an attribute which is the
nearest neighbor (closest populated place) and the distance to the nearest neighbor.
18. We will now explore a way to visualize these results. First, we need to make the table join
permanent by saving it to a new layer. Right-click the signif layer and select Save As....x
19. 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 and click
ok
50
20. Once the new layer is loaded, you can turn off the visibility of the signif layer. As our dataset
is quite 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
new layer. Right-click the earthquake_with_places layer and select Properties.\
21. In the source tab, scroll down to the Feature subset section. Click Query Builder.
51
22. For this tutorial, we will visualize the earthquakes and their nearest populated places for
Mexico. Enter the following expression in the Query Builder dialog.
23. 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
52
the ne_10m_populated_places_simple layer and select Properties.
24. Open the Query Builder dialog from the General tab. Enter the following expression.
"adm0name" = 'Mexico'
25. Now we are ready to create our visualization. We will use a plugin named MMQGIS. Find
and install the plugin. See Using Pluginsfor more details on how to work with plugins. Once you
have the plugin installed, go to MMQGIS ‣Create ‣Hub Lines.
53
26. 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.
27. The processing may take a few minutes. You can see the progress on the bottom-left corner
of the QGIS window.
28. 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.
54
55
PRACTICAL NO 12
AIM :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
4. 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 coordinates
are in Latitude and Longitude, so select INTPTLONG as X field and INTPTLAT as Y field.
Check the Use spatial index box and click OK.
56
5. 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.
6. Open the plugin dialog from Plugins ‣Analyses ‣Point sampling tool.
7. 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.
57
8. You will see a new layer max_temparature_at_urban_locations loaded in QGIS. Use
the Identify tool to 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.
9. 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.
10. 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.
11. 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 layer
to EPSG:4326 WGS84 projection.
58
12. Right-click the tl_2013_us_county layer and select Save As...
13. 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.
15. 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.
16. Go to Raster ‣Zonal statistics ‣Zonal statistics.
17. Select us.tmax_nohads_ll_{YYYYMMDD}_float as the Raster layer and counties as
59
the Polygon layer containing the zones. Enter ZS_ as the Output column prefix. Click OK.
18. The analysis may take some time depending on the size of the dataset.
19. 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 interested
in average temperature, the ZS_meanfield will be the one to use.
20. Let’s style this layer to create a temperature map. Right-click the counties layer and
select Properties.
21. Switch to the Style tab. Choose Graduated style and select ZS_mean as the Column. Choose
a Color Ramp and Mode of your chose. Click Classify to create the classes. Click OK.
60
Output would be:
61
PRACTICAL NO.13
Procedure
1. Open QGIS. Go to Layer ‣Add Layer ‣Add Vector Layer..
2. Browse to the downloaded Shapefiles.zip file and select it. Click Open.
3. 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.
4. 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.
5. 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.
62
6. 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.
7. 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.
63
8. Make sure you have the Interpolation plugin enabled. See Using Plugins for how to enable
plugins. Once enabled, go toRaster‣Interpolation ‣Interpolation.
9. 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 file
as elevation_tin.tif. CLick OK.
10. You will see the new later elevation_tin loaded in QGIS. Right-click the layer and select
Zoom to layer.
64
11. 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. Go
to Raster ‣Extraction ‣Clipper.
12. 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.
65
13. A new raster elevation_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.
14. 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.
66
15. 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.
67
16. 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.
17. 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 Attribute name box. Click OK.
18. The contour lines will be loaded as contours layer once the processing is finished. Right-click
the layer and select Properties.
68
19. 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.
69
Final Output:
70