QGIS just like most computer software uses the fonts that are installed on your computer. So, to use a Hausa font in QGIS you will need to install the font on your computer.
That is it!
QGIS just like most computer software uses the fonts that are installed on your computer. So, to use a Hausa font in QGIS you will need to install the font on your computer.
National Aeronautics and Space Administration (NASA) has this great tool called G.Projector for exploring complex Map Projection not easily implemented in common cartographic or GIS tool. The software is based o Java and it is available on major operating system like Windows, macOS and Linux. G.Projector is an interactive tool for exploring map projections. It takes an input map image, typically in Equirectangular form (also called Cylindrical Equidistant), and transforms it to one of over 200 other projections.
Download and launch G.Projector from the official website, it is a simple standalone software (no installation is required), however you need to have Java 11 or higher installed on your machine.
To start using G.Projector, you need to have a basemap (source map) of the globe in one of the following projections namely: Aitoff, Cylindrical equal Area, Equirectangular, Hammer, Robinson, or Winkel Tripel. Your source map in any of the projections above can then be transformed to one of over 200 other projections. An important note is that your input map image, must not have a border or extra margins around the edges.
The steps required are as follow;-
1) Launch the G.Projector software
2) Go to "File" >> "New with import…", select your base map and choose its corresponding map projection such as "Equiretangular" as "Input projection"
3) In the "Projection" tab, select the new map projection type you want to transform the map into. As an example, here I choose "Sinusoidal" as projection mode with Interrupted: 30° Gores
4) In the "Graticule" tab, set the "Stroke" as you want
5) In the "Overlays" tab, select <None> for "Overlay 1".
6) In the "Border" tab, set "Weight" to 0%.
7) Export the current view now under "File" >> "Save Map as…"
That is it!
Happy Map Projection
There are several ways to install the WebODM server software including purchasing the windows installer for easy installation. In this guide, I will demonstrate how it can be install on windows 11 local machine, for other detailed installation guide see the webODM github page.
Photogrammetry software require a computer with high processing power and the minimum recommend spec for webODM are 100GB free disk space and 16GB RAM.
The vtracer module can be used to convert a raster image to vector SVG image. See the code below;-
import vtracer # pip install vtracer
inp = "map.png"
out = '001'
# Minimal example: use all default values, generate a multicolor SVG
vtracer.convert_image_to_svg_py(inp, f'{out}_defaultcolor.svg')
# Single-color example. Good for line art, and much faster than full color:
vtracer.convert_image_to_svg_py(inp, f'{out}_blackandwhite.svg', colormode='binary')
print('Done...')
Resulting Vector SVG Map
LAYER NEW BorderLine,Beacons,BoundaryLine,Title,NorthArrow,ContourLine,Legend,Roads
COLOR 7 Beacons
COLOR 10 BoundaryLine
COLOR 7 Title
COLOR 5 NorthArrow
COLOR 12 ContourLine
COLOR 7 BorderLine
(alert "DONE CREATING THE LAYERS...")
To list all the layers' names in the current drawing:-
(defun c:ListLayersSimple (/ tbl)
(setq tbl (tblnext "LAYER" T)) ; Start of layer table
(while tbl
(princ (strcat "\n" (cdr (assoc 2 tbl)))) ; Layer name
(setq tbl (tblnext "LAYER")) ; Next layer
)
(princ)
)
Thank you for reading.
One important ritual you must perform whenever you are starting a new drawing in AutoCAD, is to setup the drawing UNITS according to your drawing needs or specification.
For survey drawings, you will make not less than ten clicks to complete the process. So, I decided to automate this process using AutoLISP.
- LUNITS - system variable that controls the linear/length drawing units
- LUPREC - system variable that controls the linear/length precision
- AUNITS - system variable that controls the angles drawing units
- AUPREC - system variable that controls the angles precision
- ANGBASE - system variable that controls the angle orientation
- ANGDIR - system variable that controls the angle direction to be either Clock-clockwise or Counter-clockwise
- INSUNITS - system variable that controls the insertion scaling
The picture above show what each variable is found.
To get the default values you want to use, use the getvar function in AutoLISP to confirm the values you want to set. The values can be checked as follow:-
(getvar "LUNITS")
(getvar "LUPREC")
(getvar "AUNITS")
(getvar "AUPREC")
(getvar "ANGDIR")
(getvar "ANGBASE")
(getvar "INSUNITS")
The setvar function in AutoLISP to set the drawing units in AutoCAD. For example, running this expression below will set the linear/length drawing units to Decimal units.
(setvar "LUNITS" 2)
The Unit format is as follow: 1=Scientific, 2=Decimal, 3=Engineering, 4=Architectural, 5=Fractional
To set the linear/length precision,the expression is like this below which will set the precision to four decimal places: (0.0001). To change the decimal place, change the value 4 to a new number.
(setvar "LUPREC" 4)
Similar concept is applicable to the other units system variables above. For AUNITS, it requires an integer between 0 and 4 and AUPREC requires an integer between 0 and 8.
(setvar "AUNITS" 1)
(setvar "AUPREC" 1)
ANGDIR requires 0 or 1 only. ANGBASE can be set to any number but in this case, I will use 270 to set it to NORTH.
(setvar "ANGDIR" 1)
(setvar "ANGBASE" 270)
For the insertion scaling, I will 6 for meters.
(setvar "INSUNITS" 6)
Putting it altogether:-
;;;Program to configure AutoCAD drawing UNITS for Survey Plan Drawing
;;;Step 1: Manually configure the settings you wanted
;;;Step 2: Determine the default setting using the GETVAR SYSVariable
(defun C:GETDEFAULTUNITS(/ linear-units linear-units-precision angular-units angular-units-precision angule-dir base-angle insertion-scale)
(setq linear-units (getvar "LUNITS") ; 2
linear-units-precision (getvar "LUPREC") ; 2
angular-units (getvar "AUNITS") ; 1
angular-units-precision (getvar "AUPREC") ; 1
angule-dir (getvar "ANGDIR") ; 1
base-angle (getvar "ANGBASE") ; 270
insertion-scale (getvar "INSUNITS") ; 6
) ; end setq
(princ)
) ; end defun
;;; Step 3: Configure the units using the values obtained above
(defun C:SETUNITS(/)
(setvar "LUNITS" linear-units)
(setvar "LUPREC" linear-units-precision)
(setvar "AUNITS" angular-units)
(setvar "AUPREC" angular-units-precision)
(setvar "ANGDIR" angule-dir)
(setvar "ANGBASE" base-angle)
(setvar "INSUNITS" insertion-scale)
(princ)
); end defun
That is it!
Bearing refers to the direction or orientation of a line or object relative to a fixed reference point, typically north. It is often measured in degrees, with 0° representing north, 90° representing east, 180° representing south, and 270° representing west. In simpler terms, bearing is like a compass pointing in a specific direction.
Bearings are commonly used in the field of Navigation, Surveying, Astronomy and Engineering. In some instances, different discipline use different terms such as Azimuth, Heading, Direction, Course etc to refer to bearing.
As at the time of writing, calculating the bearing of a line in QGIS doesn't work well for the context of surveying in Nigeria. Nigerian land surveyors work with Whole Circle Bearing (WCB) which is a method of expressing direction using degrees measured clockwise from north. WCB values range from 0° to 360° where North is 0°, East is 90°, South is 180° and West is 270°.
In this post, lets explore how to calculate the Whole Circle Bearing of lines and use it to label the lines.
Different organizations are responsible for the production of Electronic Navigational Charts a.k.a Electronic Nautical Charts in different countries. In Nigeria, the Nigerian Navy Hydrographic Office (NNHO) commenced the production of Nautical Charts in 2018.
In the US, charts are produced by National Oceanic and Atmospheric Administration (NOAA). In the UK, it is UK Hydrographic Office (UKHO), they called their charts 'Admiralty Charts'. Other countries have similar agencies and organizations that makes these charts.
The ArgoGIS WMS url is: https://enc.argogis.com/wms/wms_enc
To add it to QGIS, navigate to the Layer menu and add WMS/WMTS layer, then provide the url above. The result around 'Bonny Town' looks like the image below.
In other words, the autoLISP program will select a line, get its bearing and distance and write the values on beside the line. The distance is in meters and the bearing format is in Whole Circle Bearing and DD°MM'SS
(defun c:BRGDIST (/ ss i entData ptStart ptEnd dx dy angleRad angleDeg wcb bearingStr dist midpoint)
; Function to convert decimal degrees to DMS (degrees, minutes, seconds)
(defun DEGtoDMS (deg / d m s)
(setq d (fix deg)) ; Degrees
(setq m (fix (* (- deg d) 60))) ; Minutes
(setq s (* (- (* (- deg d) 60) m) 60)) ; Seconds
(strcat (itoa d) "°" (itoa m) "'" (rtos s 2 2) "\"") ; Format as DD°MM'SS"
)
; Select lines
(setq ss (ssget '((0 . "LINE"))))
(if ss
(progn
(setq i 0)
(repeat (sslength ss)
; Extract line data
(setq entData (entget (ssname ss i)))
(setq ptStart (cdr (assoc 10 entData))) ; Start point
(setq ptEnd (cdr (assoc 11 entData))) ; End point
; Calculate bearing
(setq angleRad (angle ptStart ptEnd)) ; Angle in radians (from X-axis, counterclockwise)
(setq angleDeg (/ (* angleRad 180.0) pi)) ; Convert to degrees
; Convert to Whole Circle Bearing (clockwise from north, 0°-360°)
(setq wcb (rem (+ (- 90 angleDeg) 360) 360)) ; Adjust for WCB
(setq bearingStr (DEGtoDMS wcb)) ; Convert WCB to DMS format
; Calculate distance
(setq dist (rtos (distance ptStart ptEnd) 2 2)) ; Distance with 2 decimal places
; Calculate midpoint
(setq midpoint (list
(/ (+ (car ptStart) (car ptEnd)) 2.0)
(/ (+ (cadr ptStart) (cadr ptEnd)) 2.0)
))
; Create text at midpoint
(entmake
(list
'(0 . "TEXT")
(cons 10 midpoint) ; Insertion point
(cons 40 5) ; Text height
(cons 1 (strcat bearingStr " " dist"m")) ; Bearing (DMS) + distance
(cons 50 angleRad) ; Rotation angle (aligned with line)
(cons 7 "Standard") ; Text style
)
)
(setq i (1+ i))
)
)
)
(princ)
)
This will create a new layer for the annotation
(defun c:BRGDIST (/ ss i entData ptStart ptEnd dx dy angleRad angleDeg wcb bearingStr dist midpoint)
; Function to convert decimal degrees to DMS (degrees, minutes, seconds)
(defun DEGtoDMS (deg / d m s)
(setq d (fix deg)) ; Degrees
(setq m (fix (* (- deg d) 60))) ; Minutes
(strcat (itoa d) "°" (itoa m) "'") ; Format as DD° MM'
;; (setq s (* (- (* (- deg d) 60) m) 60)) ; Seconds
;; (strcat (itoa d) "°" (itoa m) "'" (rtos s 2 2) "\"") ; Format as DD° MM' SS"
)
; Create or use the annotation layer
(if (not (tblsearch "LAYER" "BRG_DIST"))
(command "._LAYER" "_M" "BRG_DIST" "_C" "1" "" "") ; Create layer and set color to red
)
(setvar "CLAYER" "BRG_DIST") ; Set current layer to BRG_DIST
; Select lines
(setq ss (ssget '((0 . "LINE"))))
(if ss
(progn
(setq i 0)
(repeat (sslength ss)
; Extract line data
(setq entData (entget (ssname ss i)))
(setq ptStart (cdr (assoc 10 entData))) ; Start point
(setq ptEnd (cdr (assoc 11 entData))) ; End point
; Calculate bearing
(setq angleRad (angle ptStart ptEnd)) ; Angle in radians (from X-axis, counterclockwise)
(setq angleDeg (/ (* angleRad 180.0) pi)) ; Convert to degrees
; Convert to Whole Circle Bearing (clockwise from north, 0°-360°)
(setq wcb (rem (+ (- 90 angleDeg) 360) 360)) ; Adjust for WCB
(setq bearingStr (DEGtoDMS wcb)) ; Convert WCB to DMS format
; Calculate distance
(setq dist (rtos (distance ptStart ptEnd) 2 2)) ; Distance with 2 decimal places
; Calculate midpoint
(setq midpoint (list
(/ (+ (car ptStart) (car ptEnd)) 2.0)
(/ (+ (cadr ptStart) (cadr ptEnd)) 2.0)
))
; Create text at midpoint
(entmake
(list
'(0 . "TEXT")
(cons 10 midpoint) ; Insertion point
(cons 40 5) ; Text height
(cons 1 (strcat bearingStr " " dist "m")) ; Bearing (DMS) + distance
(cons 50 angleRad) ; Rotation angle (aligned with line)
(cons 7 "Standard") ; Text style
(cons 8 "BRG_DIST") ; Layer
)
)
(setq i (1+ i))
)
)
)
(princ)
)
Happy Coding!
Recently, I was working on a project where I had to label some points in several AutoCAD files from data points obatined from GPS/GNSS reciever. So, I wrote this Python code to 'Generate AutoCAD Script (.SCR) file from GNSS Data'.
easting = '356662'
northing = '946418'
# construct text string eg: _TEXT easting,northing 10 90 PA10
script_str_txt = f'_TEXT {easting},{northing} 10 90 {name}\n'
# construct point string eg: _POINT easting,northing
script_str_pt = f'_POINT {easting},{northing}\n'
with open(f"{file_num}_{sch_name}.scr", "a") as f:
f.write(script_str_txt)
The result of the script:
sch_dict = {'GSS TOTO WEST TOTO LGC':1, 'GJSS ASOPADA KARU LGC':2, 'GJSS KURMIN TAGWAYE AKWANG':3, 'GJSS LAFIA SOUTH LAFIA LGC':4, 'GJSS SAMBGOBARAU KOKONA LGC':5, 'GOV DAY SEC OBI LGC':6, 'GS LOKO NASARAWA LGC':7, 'GSS ALUSHI KEANA LGC':8, 'GSS AZUB CENTRAL LAFIA LGC':9, 'GSS EFUGBORINGO DOMA LGC':10, 'GSS GUDI AKWANGA LGC':11, 'GSS KEKURA AWE LGC':12, 'GSS MAMA WAMBA LGC':13, 'GSS SABONGARI KEFFI KEFFI LGC':14, 'ISLAMIYYA LGEA KEANA LGC':15, 'LGEA DHIZILA OBI LGC':16, 'LGEA EFURIGBORINGO DOMA LGC':17, 'LGEA EZZEN MADA STATION EGGON':18, 'LGEA GUDIGE TSOHO NASARAWA LGC':19, 'LGEA IBI AWE LGC':20, 'LGEA KIGBUNA LAFIA LGC':21, 'LGEA MADA HILL AKWANGA LGC':22, 'LGEA PILOT CEN UMAISHA TOTO LG':23, 'LGEA PRI ADOKASA KARU LGC':24, 'LGEA PRI KONZA WAMB LGC':25, 'LGEA PRI NASARAWA EAST NAS LGC':26, 'LGEA REFUGE CAMP LAFIA LGC':27, 'LGEA SAKWATO KOKONA LGC':28, 'LGEA TRANSFER UMAISHA TOT LGC':29, 'NADP PROJECT LAFIA LGC':30, 'RCM GSS NAS EGGON LGC':31}
# Read the GNSS created spread sheet....
df = pd.read_csv(r"sch-24.csv")
group_df = df.groupby('School Name')
group_keys = list(group_df.groups.keys())
for s in group_keys:
temp_df = group_df.get_group(s)
for idx, row in temp_df.iterrows():
easting = row['X']
northing = row['Y']
name = row['Name']
sch_name = row['School Name']
file_num = sch_dict[sch_name]
# construct text string eg: _TEXT easting,northing 10 90 PA10
script_str_txt = f'_TEXT {easting},{northing} 10 90 {name}\n'
# construct point string eg: _POINT easting,northing
script_str_pt = f'_POINT {easting},{northing}\n'
with open(f"{file_num}_{sch_name}.scr", "a") as f:
f.write(script_str_txt)
with open(f"{file_num}_{sch_name}.scr", "a") as f:
f.write(script_str_pt)
# break
print('Done...')
World Files are georeferencing files for images that describe the location, scale, and orientation of an image such geoTiff with .tfw as its world file, JPEG with .jgw as its world file and PNG with .pgw as its world file.
Image world files (.tfw, .jgw, .pgw) are text files that contains geographic information for a raster image. They are used to georeference the image, which means to position the image correctly on a map or in a mapping system.The .tfw world file is a text file used to georeference the GeoTIFF raster images, like the orthomosaic and the DSM. The .jgw world file is a text file used to georeference the JPEG raster images. The .pgw world file is a text file used to georeference the PNG raster images.
Any of the world files have similar structure which contain 6-line in the text file:
- Line 1: pixel size in the x-direction in map units (GSD).
- Line 2: rotation about y-axis.
- Line 3: rotation about x-axis.
- Line 4: pixel size in the y-direction in map in map units (GSD).
- Line 5: x-coordinate of the upper left corner of the image.
- Line 6: y-coordinate of the upper left corner of the image.
*GSD: Ground Sampling Distance.
As pixels are considered as square lines 1 and 4 are the same.
Georeferencing a JPEG image in AutoCAD using its .jgw World Files
This one used case of the worl files in AutoCAD. The Visual LISP program below adopted from Insert georeferenced image with world file in AutoCAD will select an image that has a jgw world file and georeferencing it appropraitely.
(vl-load-com)
(defun ss->lst (ss / e n out)
(setq n -1)
(while (setq e (ssname ss (setq n (1+ n)))) (setq out (cons (vlax-ename->vla-object e) out)))
)
(defun _writefile (filename lst / file result)
(cond ((and (eq 'str (type filename)) (setq file (open filename "w")))
(foreach x lst
(write-line
(cond ((= (type x) 'str) x)
((= (type x) 'int) (itoa x))
((= (type x) 'real) (rtos x 2 6))
((vl-prin1-to-string x))
)
file
)
)
(close file)
filename
)
)
)
(defun _readfile (filename / file result)
(cond
((and (eq 'str (type filename)) (setq file (open filename "r")))
(while (setq line (read-line file)) (setq result (cons (vl-string-trim " " line) result)))
(close file)
(reverse result)
)
)
)
(setq opt "ReadIt")
; (initget 0 "ReadIt WriteIt")
; (setq opt (cond ((getkword (strcat "\nImage World File [ReadIt/WriteIt] <" opt ">: ")))
; (opt)
; )
; )
(princ "\nSelect image(s): ")
(setq pre (getvar 'dwgprefix))
(if (and (setq ss (ssget '((0 . "image")))) (setq ss (ss->lst ss)))
(foreach image ss
(setq name (vlax-get image 'name)
hgt (vlax-get image 'height)
wdth (vlax-get image 'width)
imhgt (vlax-get image 'imageheight)
imwdth (vlax-get image 'imagewidth)
rot (vlax-get image 'rotation)
bpt (vlax-get image 'origin)
imgpath (vl-filename-directory (vlax-get image 'imagefile))
jgw (strcat imgpath "\\" name ".jgw")
)
(if (= opt "ReadIt")
(progn
(if (and (or (setq jgw (findfile (strcat pre name ".jgw")))
(setq jgw (findfile (strcat imgpath "\\" name ".jgw")))
(setq jgw (getfiled (strcat "***Select <<" name ".jgw>>***") pre "jgw" 16))
)
(setq pre (strcat (vl-filename-directory jgw) "\\"))
(setq data (mapcar 'atof (_readfile jgw)))
(> (length data) 5)
(setq l1 (car data))
(setq mvpt (list (nth 4 data) (nth 5 data) 0.0))
)
(progn (vla-put-imageheight image (* hgt l1))
(vla-put-imagewidth image (* wdth l1))
(vla-put-rotation image (cadr data))
(setq rot (vlax-get image 'rotation))
(setq bpt (polar bpt (+ (/ pi 2.) rot) (* hgt l1)))
(vlax-invoke image 'move bpt mvpt)
(princ (strcat "\njgw File Read - " jgw))
)
(princ "\njgw file NOT found or not correctly formatted!")
)
)
(progn (setq bpt (polar bpt (+ (/ pi 2.) rot) imhgt))
(if (setq jgw (_writefile
(strcat imgpath "\\" name ".jgw")
(list (/ imhgt hgt)
rot
(strcat "-" (rtos (abs rot) 2 6))
(strcat "-" (rtos (abs (/ imwdth wdth)) 2 6))
(rtos (car bpt) 2 6)
(rtos (cadr bpt) 2 6)
)
)
)
(print jgw)
(princ "\nError writing file...")
)
)
)
)
)
(princ)
Thank you for reading.
In QGIS the attribute entry form pop-up immediately you digitized a point or line or polygon feature. This is so that you can enter the corresponding attribute to the feature immediately, that makes sense. Howerver, it is not all the time that you may want this to happend. There are time you just don't care about the attributes and all you require is the geometrical features didgitized asap. In such a situation the attribute dialog box pop-up during digitizing may be anoying.
Here is how to prevent the attribute dialog box from displaying during digitizing. You just need to enable the feature: "Suppress attribute from pop-up after feature creation".
Go to: Settings menu >> Options >> Map Tools >> Digitizing
That is it!
The Javascript code below will calculate Land Surface Temperature (LST) from landsat 8 imagery.
Adopted from this medium post: Analyzing Land Surface Temperature (LST) with Landsat 8 Data in Google Earth Engine - https://medium.com/@ridhomuh002/analyzing-land-surface-temperature-lst-with-landsat-8-data-in-google-earth-engine-f4dd7ca28e70
// Load AOI or ROI
var aoi = ee.FeatureCollection("users/forum2k9/Karu"); // Karu polygon - change if you need different
Map.addLayer(aoi, {}, 'AOI - Karu');
Map.centerObject(aoi, 10);
// Define data retrieval Start and End Date
var startDate = '2023-03-01';
var endDate = '2023-10-31';
// Applies scaling factors. Recalculating from K to °C
function applyScaleFactors(image) {
// Scale and offset values for optical bands
var opticalBands = image.select('SR_B.').multiply(0.0000275).add(-0.2);
// Scale and offset values for thermal bands
var thermalBands = image.select('ST_B.*').multiply(0.00341802).add(149.0).subtract(273.15); // I'm used to the °C, In case of K delete the subtract part
// Add scaled bands to the original image
return image.addBands(opticalBands, null, true)
.addBands(thermalBands, null, true);
}
// Function to Mask Clouds and Cloud Shadows in Landsat 8 Imagery
function cloudMask(image) {
// Define cloud shadow and cloud bitmasks
var cloudShadowBitmask = (1 << 4);
var cloudBitmask = (1 << 3);
var cirrus = (1 << 2); // I add also mask for cirrus. Suprisely use of Bit 6 (Clear of any clouds) is not working - anybody know why?
// Select the Quality Assessment (QA) band for pixel quality information
var qa = image.select('QA_PIXEL');
// Create a binary mask to identify clear conditions (both cloud and cloud shadow bits set to 0)
var mask = qa.bitwiseAnd(cloudShadowBitmask).eq(0)
.and(qa.bitwiseAnd(cloudBitmask).eq(0))
.and(qa.bitwiseAnd(cirrus).eq(0));
// Update the original image, masking out cloud and cloud shadow-affected pixels
return image.updateMask(mask);
}
// Import and preprocess Landsat 8 imagery
var image = ee.ImageCollection("LANDSAT/LC08/C02/T1_L2")
.filterBounds(aoi)
.filterDate(startDate, endDate)
.map(applyScaleFactors)
.map(cloudMask)
.median()
.clip(aoi);
// Define visualization parameters for True Color imagery (bands 4, 3, and 2)
var visualization = {
bands: ['SR_B4', 'SR_B3', 'SR_B2'],
min: 0.0,
max: 0.2,
};
// Add the processed image to the map with the specified visualization
Map.addLayer(image, visualization, 'True Color 432');
print(image);
// Add the LST Layer to the Map with Custom Visualization Parameters
Map.addLayer(image.select('ST_B10'), {
min: 19, // Minimum LST value
max: 43, // Maximum LST value
palette: [
'040274', '040281', '0502a3', '0502b8', '0502ce', '0502e6',
'0602ff', '235cb1', '307ef3', '269db1', '30c8e2', '32d3ef',
'3be285', '3ff38f', '86e26f', '3ae237', 'b5e22e', 'd6e21f',
'fff705', 'ffd611', 'ffb613', 'ff8b13', 'ff6e08', 'ff500d',
'ff0000', 'de0101', 'c21301', 'a71001', '911003'
]}, 'Land Surface Temperature');
// // Calculate Normalized Difference Vegetation Index (NDVI)
// var ndvi = image.normalizedDifference(['SR_B5', 'SR_B4']).rename('NDVI');
// // Define NDVI Visualization Parameters
// var ndviPalette = {
// min: -1,
// max: 1,
// palette: ['blue', 'white', 'green']
// };
// Map.addLayer(ndvi, ndviPalette, 'NDVI Karu')
// Adopted from: https://github.com/panmoravec/GEE/blob/main/LST%20Landsat8
Export.image.toDrive({
image: image.select('ST_B10'),
description: 'LST_2023',
scale: 30,
region: aoi,
fileFormat: 'GeoTIFF',
maxPixels: 3100100100, // set bigger in case of need
});
// Another version for.... Land surface temperature (LST) Monitoring using Landsat imagery using Google Earth Engine
1) https://code.earthengine.google.com/525ebe138c6d2198a0fd464f7cfc967a
var LLST = require('users/sofiaermida/landsat_smw_lst:modules/Landsat_LST.js')
var Lan8 = LLST.collection('L8', '2021-1-01', '2021-12-31', geometry, true).select('LST').map(function(image){
return image.subtract(273.15).clip(geometry).set('system:time_start',image.get('system:time_start'))
})
print("chart");
// print(Lan8)
print(
ui.Chart.image.series({
imageCollection: Lan8,
region: geometry,
reducer: ee.Reducer.mean(),
scale: 30,
xProperty: 'system:time_start'
}));
Map.centerObject(geometry,10)
Map.addLayer(geometry)
Map.addLayer(Lan8.mean().clip(geometry), imageVisParam4 ,'Dhaka City LST')
====================================================================================
2) https://code.earthengine.google.com/3fdeff0b82b6fc98022a11facd30d269
// Land surface temperature
var landsat8 = ee.ImageCollection("LANDSAT/LC08/C01/T1_SR")
.filterBounds(ROI)
.filterDate('2020-01-01','2022-12-31')
//.filterMetadata('CLOUD_COVER', 'less_than', 1)
.median()
.clip(ROI)
print(landsat8)
Map.addLayer(landsat8, imageVisParam3, 'Satelliteimage with clouds')
Map.centerObject(landsat8,8)
// CLOUD MASK
//Bits 3 and 5 are cloud shadow and cloud, respectively
var maskL8sr = function(col){
var cloudShadowBitMask = (1 << 3)
var cloudsBitMask = (1 << 5)
// Get the piixel QA band
var qa = col.select('pixel_qa')
var mask = qa.bitwiseAnd(cloudShadowBitMask).eq(0)
.and(qa.bitwiseAnd(cloudsBitMask).eq(0))
return col.updateMask(mask)
}
// visualization params
var vizParams = {
bands: ['B5', 'B6', 'B4'],
min: 0,
max: 4000,
gamma: [1, 0.9, 1.1]
};
var vizParams2 = {
bands: ['B4', 'B3', 'B2'],
min: 0,
max: 3000,
gamma: 1.4,
};
//load the collection
{
var col = ee.ImageCollection("LANDSAT/LC08/C01/T1_SR")
.map(maskL8sr)
.filterBounds(ROI)
.filterDate('2020-01-01','2022-12-31')
.mean()
.clip(ROI)
}
print(col)
Map.addLayer(col, imageVisParam2, 'Cloud_Free')
// NDVI CALCULATION
var NDVI = col.normalizedDifference(['B5','B4'])
Map.addLayer(NDVI, {min: -1, max: 0.7, palette: ['blue','white','yellow','red']}, 'Created NDVI')
Map.centerObject(NDVI, 8)
print(NDVI)
// selecting Band10 which is the surface temperature
// thermal band 10
var thermalband = col.select('B10').multiply(0.1)
Map.addLayer(thermalband, {min:294.388, max:300.514, palette:['yellow','green','blue']}, 'Thermal band')
//finding minimum and maximum NDVI
var min = ee.Number(NDVI.reduceRegion({ //reduce region is used to calculate a statistcal function for each region
reducer: ee.Reducer.min(),
geometry: ROI,
scale: 30,
maxPixels: 1e9
}).values().get(0));
print(min, 'min');
var max = ee.Number(NDVI.reduceRegion({
reducer: ee.Reducer.max(),
geometry: ROI,
scale: 30,
maxPixels: 1e9
}).values().get(0));
print(max, 'max')
//fractional vegetation
var fv = (NDVI.subtract(min).divide(max.subtract(min))).pow(ee.Number(2))
print(fv,'fv');
Map.addLayer(fv, {},'Fractional Vegetation');
//Emissivity
// you will have to find the emissivity of natural and town
var a = ee.Number(0.004)
var b = ee.Number(0.986)
var EM = fv.multiply(a).add(b).rename('EMM')
Map.addLayer(EM, imageVisParam, 'Emissivity')
//FINDING LAND SURFACE TEMPERATURE
//LST in celsius degree bring -273.15
//NB: In kelvin don't bring -273.15
var LST = thermalband.expression(
'(Tb/(1 + (0.00115*(Tb/1.438))*log(Ep)))-273.15',{
'Tb':thermalband.select('B10'),
'Ep':EM.select('EMM')
}).rename('Land surface Temperature');
var viz = {min: 22.298638087799763, max:29.22115281845691, palette: [
'040274', '040281', '0502a3', '0502b8', '0502ce', '0502e6',
'0602ff', '235cb1', '307ef3', '269db1', '30c8e2', '32d3ef',
'3be285', '3ff38f', '86e26f', '3ae237', 'b5e22e', 'd6e21f',
'fff705', 'ffd611', 'ffb613', 'ff8b13', 'ff6e08', 'ff500d',
'ff0000', 'de0101', 'c21301', 'a71001', '911003'
]}
Map.addLayer(LST, viz, 'LST')
//TIMESSERIES
//print(image_drycollection)
//print(ui.Chart.image.series(LST, ROI, ee.Reducer.mean(), 1000, 'system:time_start'))
// Create the title label.
var title = ui.Label('Shama LandSurface Temperature Map Year of 2022 ');
title.style().set('position', 'top-center');
Map.add(title);
var title = ui.Label('Prepared by Kangah Desmond');
title.style().set('position', 'bottom-center');
Map.add(title);
// set position of panel
var legend = ui.Panel({
style: {
position: 'bottom-left',
padding: '8px 15px'
}
});
// Create the title label.
//var title = ui.Label('Dhaka City LandSurface Temperature Map Year of 2020 ');
//title.style().set('position', 'top-center');
//Map.add(title);
// Create legend title
var legendTitle = ui.Label({
value: 'LandSurface Temperature (degC)',
style: {
fontWeight: 'bold',
fontSize: '18px',
margin: '0 0 4px 0',
padding: '0'
}
});
// Add the title to the panel
legend.add(legendTitle);
// create the legend image
var lon = ee.Image.pixelLonLat().select('latitude');
var gradient = lon.multiply((viz.max-viz.min)/100.0).add(viz.min);
var legendImage = gradient.visualize(viz);
// create text on top of legend
var panel = ui.Panel({
widgets: [
ui.Label(viz['max'])
],
});
legend.add(panel);
// create thumbnail from the image
var thumbnail = ui.Thumbnail({
image: legendImage,
params: {bbox:'0,0,10,100', dimensions:'10x200'},
style: {padding: '1px', position: 'bottom-center'}
});
// add the thumbnail to the legend
legend.add(thumbnail);
// create text on top of legend
var panel = ui.Panel({
widgets: [
ui.Label(viz['min'])
],
});
legend.add(panel);
Map.add(legend);
// Create the title label.
//var title = ui.Label('Prepared By: Mijanur Rahman');
//title.style().set('position', 'bottom-right');
//Map.add(title);
To load a shapefile into Google Earth Engine (GEE), you can use the Code Editor, the Asset Manager, or the command line interface (CLI):
In this guide, I will use the 'Asset Manager' tab and access the shapefile from the Code Editor. Let get started...
Step 1: Go to code.earthengine.google.com and sign in. Click the “Assets” tab at the top left of the screen, and then click on the red “New” button. Select the “Shape files” option from the dropdown menu.
Step 2: In the pop-up window, click the red “Select” button and navigate to where your shapefile is stored. Select all of the files that make up your shapefile (.shp, .shx, .prj, .dbf, .cpg). You can hold the control key to select multiple files at once. Then click “Open” to add the selected files to the upload list. Update the Asset Name in the Asset ID section if needed. Then, click the “Upload” button at the bottom.
Step 3: Navigate to the 'Task' tab, there you see the submitted task in action, you don't have to do anything. Just watch the task will turn blue when the upload is complete.
Step 4: Click on the name of the name of the newly uploaded shapefile under the “Assets” tab to open its details windows where you will all meta data related to it including its "Table ID". The "Table ID" is what we will copy for use in the javascript code editor.
That is it!