Thursday, March 16, 2023

Research Note #28 Making A Polygon from Delimited Coordinates Text File (CSV) on QGIS

For this work, I was using QGIS 3.4.1-Madeira. The objective was to create a polygon to be used as study area for GEE analysis later. The study area will contain of several districts in state of Punjab, India. The study area itself is constructed from burnt area validation points over Punjab. 

I. Load the validation points coordinates from delimited text file.

  1. From 'Layer' menu, select 'Add Layer' --> 'Add Delimited Text Layer'
  2. In dialog box, select the delimited text file in the 'File name' section. 
  3. In 'Geometry Definition' section, particularly in 'Point coordinates', select the X (longitude) and Y (Latitude) fields. 
  4. Make the first row as the field names in the 'Record and Fields Options' section by ticking 'First record has field names'.
  5. Check again all entries, then click 'Add'. If it's OK, new layer containing all points from the delimited file will be added.
Validation points loaded on the map


II. Add the Punjab map layer
  1. Load the Punjab districts shape file by double clicking the SHP file on the Layer explorer.
  2. Double click the Punjab district layer. In the Layer Properties dialog bog, select 'Setting' and click on 'Query Builder' in the 'Provider Feature Filter'. This is done to filter the districts so only the one covered by validation points will be shown on the map.
  3. In Query builder insert this filter string:  "dtname" = 'Ludhiana' OR "dtname"='Amritsar' OR "dtname" = 'Moga' OR "dtname" = 'Malerkotla' OR "dtname" = 'Sangrur' OR "dtname" = 'Firozpur', then click OK.
  4. If it's correctly done, the map will include the selected districts only.
Query builder dialog box

The districts consisting validation points in Punjab


III. Create study area polygon from the validation points.
  1. From menu 'Processing', select 'Toolbox'. Then, in the Processing Toolbox explorer, select 'Vector Geometry' --> 'Concave hull (alpha shapes)'.
  2. In the Concave hull dialog box, make sure that the input layer is the coordinates layer previously generated. Let just use default values (0.3 threshold) and click 'Run'.
  3. If it's done correctly, a new polygon covering the validation points will be generated.
  4. This layer could be exported into SHP file and uploaded to GEE for data processing.
Concave Hull (Alpha shapes) dialog box


New polygons are shown as areas in hashed lines on the map