uhi-desktop 1.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- uhi_desktop-1.1.0/LICENSE +21 -0
- uhi_desktop-1.1.0/PKG-INFO +151 -0
- uhi_desktop-1.1.0/README.md +132 -0
- uhi_desktop-1.1.0/desktop_app/README.md +114 -0
- uhi_desktop-1.1.0/desktop_app/__init__.py +1 -0
- uhi_desktop-1.1.0/desktop_app/icon.png +0 -0
- uhi_desktop-1.1.0/desktop_app/uhi_desktop.py +250 -0
- uhi_desktop-1.1.0/pyproject.toml +37 -0
- uhi_desktop-1.1.0/setup.cfg +4 -0
- uhi_desktop-1.1.0/tests/test_core.py +81 -0
- uhi_desktop-1.1.0/tests/test_desktop.py +58 -0
- uhi_desktop-1.1.0/tests/test_integration.py +166 -0
- uhi_desktop-1.1.0/uhi_desktop.egg-info/PKG-INFO +151 -0
- uhi_desktop-1.1.0/uhi_desktop.egg-info/SOURCES.txt +23 -0
- uhi_desktop-1.1.0/uhi_desktop.egg-info/dependency_links.txt +1 -0
- uhi_desktop-1.1.0/uhi_desktop.egg-info/entry_points.txt +2 -0
- uhi_desktop-1.1.0/uhi_desktop.egg-info/requires.txt +1 -0
- uhi_desktop-1.1.0/uhi_desktop.egg-info/top_level.txt +2 -0
- uhi_desktop-1.1.0/uhi_landsat/__init__.py +3 -0
- uhi_desktop-1.1.0/uhi_landsat/icon.svg +20 -0
- uhi_desktop-1.1.0/uhi_landsat/metadata.txt +18 -0
- uhi_desktop-1.1.0/uhi_landsat/uhi_core.py +473 -0
- uhi_desktop-1.1.0/uhi_landsat/uhi_dialog.py +42 -0
- uhi_desktop-1.1.0/uhi_landsat/uhi_dialog.ui +63 -0
- uhi_desktop-1.1.0/uhi_landsat/uhi_plugin.py +110 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Krishna Dutt Panchagnula
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: uhi-desktop
|
|
3
|
+
Version: 1.1.0
|
|
4
|
+
Summary: Standalone desktop app that maps urban heat islands from Landsat 10/11
|
|
5
|
+
Author: Krishna Dutt Panchagnula
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/krishnaduttPanchagnula/qgis-urban-heat-island
|
|
8
|
+
Project-URL: Source, https://github.com/krishnaduttPanchagnula/qgis-urban-heat-island
|
|
9
|
+
Project-URL: Issues, https://github.com/krishnaduttPanchagnula/qgis-urban-heat-island/issues
|
|
10
|
+
Project-URL: Downloads, https://github.com/krishnaduttPanchagnula/qgis-urban-heat-island/releases
|
|
11
|
+
Keywords: qgis,landsat,urban heat island,land surface temperature,gis,raster
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Topic :: Scientific/Engineering :: GIS
|
|
14
|
+
Requires-Python: >=3.9
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
License-File: LICENSE
|
|
17
|
+
Requires-Dist: numpy>=1.21
|
|
18
|
+
Dynamic: license-file
|
|
19
|
+
|
|
20
|
+
# Urban Heat Island QGIS plugin (Landsat 10/11)
|
|
21
|
+
|
|
22
|
+

|
|
23
|
+
|
|
24
|
+
A QGIS tool for GIS analysts: give it a place, a date and a radius, and it makes
|
|
25
|
+
two ready-to-use maps showing how hot the ground is and where the hottest parts
|
|
26
|
+
of the city are.
|
|
27
|
+
|
|
28
|
+
## What it does
|
|
29
|
+
|
|
30
|
+
The plugin looks for a Landsat satellite image of your area close to the date you
|
|
31
|
+
choose, reads the two heat-sensing channels on the satellite, and adds two layers
|
|
32
|
+
to your QGIS project:
|
|
33
|
+
|
|
34
|
+
- **LST (land surface temperature)** — a colour map of how warm the ground is, in °C.
|
|
35
|
+
Blue is cooler, red is hotter.
|
|
36
|
+
- **UHI (urban heat island)** — an easier-to-read map with five heat zones:
|
|
37
|
+
cool, slightly cool, average, warm, and hot spot.
|
|
38
|
+
|
|
39
|
+
You do not need to know how to process satellite imagery. You just fill in a
|
|
40
|
+
short form and the maps appear in your layer panel.
|
|
41
|
+
|
|
42
|
+
**No QGIS?** There is also a standalone desktop app with exactly the same logic in
|
|
43
|
+
[`desktop_app/`](desktop_app/README.md). Install it with
|
|
44
|
+
`pip install git+https://github.com/krishnaduttPanchagnula/qgis-urban-heat-island.git@v1.1.0`
|
|
45
|
+
and launch it with `uhi-desktop`; the desktop README also covers conda, the release
|
|
46
|
+
zip and running from source.
|
|
47
|
+
|
|
48
|
+
## Install
|
|
49
|
+
|
|
50
|
+
Download `uhi_landsat_plugin_v1.0.0.zip` from the
|
|
51
|
+
[latest release](https://github.com/krishnaduttPanchagnula/qgis-urban-heat-island/releases/latest),
|
|
52
|
+
or install straight from QGIS:
|
|
53
|
+
|
|
54
|
+
1. *Plugins → Manage and Install Plugins → Settings…*
|
|
55
|
+
2. Tick **Add new repository**, name it `Urban Heat Island`, and use this URL:
|
|
56
|
+
`https://raw.githubusercontent.com/krishnaduttPanchagnula/qgis-urban-heat-island/main/plugins.xml`
|
|
57
|
+
3. Search for **Urban Heat Island (Landsat 10/11)** and click *Install Plugin*.
|
|
58
|
+
|
|
59
|
+
Manual install: unzip the release into your QGIS Python plugins folder, e.g.
|
|
60
|
+
`~/.local/share/QGIS/QGIS3/profiles/default/python/plugins/`, so that
|
|
61
|
+
`uhi_landsat/metadata.txt` sits directly under that folder. Restart QGIS and
|
|
62
|
+
enable the plugin in *Plugins → Manage and Install Plugins*. The city/heat icon
|
|
63
|
+
appears in the plugin manager and on the toolbar.
|
|
64
|
+
|
|
65
|
+
No extra software is needed — QGIS already includes everything the plugin needs.
|
|
66
|
+
|
|
67
|
+
## Before you start: getting the satellite data
|
|
68
|
+
|
|
69
|
+
The satellite files are free, but you need one of these three ways to reach them.
|
|
70
|
+
Pick whichever is easiest for you:
|
|
71
|
+
|
|
72
|
+
| Option | What you need | Best for |
|
|
73
|
+
|---|---|---|
|
|
74
|
+
| **Folder on my computer** | The satellite files already downloaded from USGS EarthExplorer into one folder | Offline work, or if you do not have cloud accounts |
|
|
75
|
+
| **AWS account** | An Amazon Web Services account (downloads cost a few cents) | Automatic download, no manual searching |
|
|
76
|
+
| **USGS website login** | Your USGS EarthExplorer login cookie | Automatic download with an existing USGS account |
|
|
77
|
+
|
|
78
|
+
Leave the source on **Automatic – try all options** and the plugin will try each
|
|
79
|
+
available option in turn and use the first one that works. If one fails, you will
|
|
80
|
+
see the reason and it will move to the next one.
|
|
81
|
+
|
|
82
|
+
## How to use it
|
|
83
|
+
|
|
84
|
+
1. Click the heat-island icon in the QGIS toolbar (or find it in the *Plugins* menu).
|
|
85
|
+
2. **Date** — choose the day you are interested in. A dry, cloud-free day works best.
|
|
86
|
+
If there is no satellite pass on that exact day, the plugin looks up to one week
|
|
87
|
+
before or after and uses the clearest image it finds.
|
|
88
|
+
3. **Location name** — type a name such as `Milan`. This is only used to name the
|
|
89
|
+
output layers.
|
|
90
|
+
4. **Latitude / Longitude** — the centre of the area. You can read these off the
|
|
91
|
+
QGIS status bar by clicking on the map.
|
|
92
|
+
5. **Radius (km)** — how far around that point to map. 20 km is a good start.
|
|
93
|
+
6. **Output folder** — where the two maps will be saved.
|
|
94
|
+
7. **Where to get the data** — choose one of the three options above. If you pick
|
|
95
|
+
*Folder on my computer*, click `...` and select the folder.
|
|
96
|
+
8. Click **OK**. A progress bar appears; you can cancel at any time. QGIS stays
|
|
97
|
+
usable while it works.
|
|
98
|
+
|
|
99
|
+
Two layers then appear in your layer panel, already coloured and ready to use.
|
|
100
|
+
A message at the bottom of QGIS tells you which data source worked and the average
|
|
101
|
+
temperature for your area.
|
|
102
|
+
|
|
103
|
+
## Understanding the maps
|
|
104
|
+
|
|
105
|
+
- The **LST** layer shows actual ground temperature in °C. Use it to compare
|
|
106
|
+
neighbourhoods or to find the warmest surfaces.
|
|
107
|
+
- The **UHI** layer sorts the area into five zones relative to the average for
|
|
108
|
+
that image: `1` cool, `2` slightly cool, `3` average, `4` warm, `5` hot spot.
|
|
109
|
+
Value `0` means no result — usually cloud or water.
|
|
110
|
+
- The zones are **relative to the area and date you chose**. They are excellent
|
|
111
|
+
for spotting heat patterns within one map, but two maps from different dates
|
|
112
|
+
should only be compared if you used the same area and settings.
|
|
113
|
+
|
|
114
|
+
## Practical tips
|
|
115
|
+
|
|
116
|
+
- Cloudy days hide the ground. Try a dry month, or let the plugin pick the
|
|
117
|
+
clearest nearby date.
|
|
118
|
+
- Cloudy and water pixels are automatically left out, so they will not distort
|
|
119
|
+
your results.
|
|
120
|
+
- Larger radii take longer to process. Start with 20 km and increase if needed.
|
|
121
|
+
- Only Landsat 8 and 9 are supported (the satellites with heat channels 10 and 11).
|
|
122
|
+
- Something not working? Open an
|
|
123
|
+
[issue](https://github.com/krishnaduttPanchagnula/qgis-urban-heat-island/issues)
|
|
124
|
+
with the message from QGIS and the date and place you entered.
|
|
125
|
+
|
|
126
|
+
## For the technically minded
|
|
127
|
+
|
|
128
|
+
Scene discovery uses the public USGS LandsatLook and Element84 Earth Search STAC
|
|
129
|
+
catalogues. Band files come from the first working of: local folder, the
|
|
130
|
+
requester-pays `usgs-landsat` S3 bucket, or `landsatlook.usgs.gov` with a session
|
|
131
|
+
cookie. Temperature is a split-window estimate,
|
|
132
|
+
`T = T10 + A·(T10−T11) + B·(T10−T11)² + C` with A=1, B=0, C=0, after radiance and
|
|
133
|
+
brightness-temperature conversion using the scene MTL file. Clear-sky pixels are
|
|
134
|
+
selected with QA_PIXEL bits 6 and 7. Processing is streamed in 512-row blocks, so
|
|
135
|
+
peak memory stays near 100 MB. Every output GeoTIFF stores provenance: source used,
|
|
136
|
+
scene ID, acquisition time, band paths, retrieval time, licence and coefficients.
|
|
137
|
+
|
|
138
|
+
`shortcut: the split-window uses fixed coefficients (clear sky, ~0.97 emissivity),
|
|
139
|
+
so this is a relative heat-island product, not a calibrated absolute temperature.
|
|
140
|
+
For absolute LST, use USGS Collection 2 Level-2 ST_B10.`
|
|
141
|
+
|
|
142
|
+
## Tests
|
|
143
|
+
|
|
144
|
+
- `python3 tests/test_core.py` — pure logic, no QGIS needed.
|
|
145
|
+
- `python3 tests/test_integration.py` — end-to-end with real GDAL bindings.
|
|
146
|
+
- `python3 tests/test_desktop.py` — desktop app worker with real GDAL bindings.
|
|
147
|
+
|
|
148
|
+
## Publishing
|
|
149
|
+
|
|
150
|
+
Maintainers: see [PUBLISHING.md](PUBLISHING.md) for PyPI trusted publishing and
|
|
151
|
+
manual `twine` upload instructions.
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# Urban Heat Island QGIS plugin (Landsat 10/11)
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
A QGIS tool for GIS analysts: give it a place, a date and a radius, and it makes
|
|
6
|
+
two ready-to-use maps showing how hot the ground is and where the hottest parts
|
|
7
|
+
of the city are.
|
|
8
|
+
|
|
9
|
+
## What it does
|
|
10
|
+
|
|
11
|
+
The plugin looks for a Landsat satellite image of your area close to the date you
|
|
12
|
+
choose, reads the two heat-sensing channels on the satellite, and adds two layers
|
|
13
|
+
to your QGIS project:
|
|
14
|
+
|
|
15
|
+
- **LST (land surface temperature)** — a colour map of how warm the ground is, in °C.
|
|
16
|
+
Blue is cooler, red is hotter.
|
|
17
|
+
- **UHI (urban heat island)** — an easier-to-read map with five heat zones:
|
|
18
|
+
cool, slightly cool, average, warm, and hot spot.
|
|
19
|
+
|
|
20
|
+
You do not need to know how to process satellite imagery. You just fill in a
|
|
21
|
+
short form and the maps appear in your layer panel.
|
|
22
|
+
|
|
23
|
+
**No QGIS?** There is also a standalone desktop app with exactly the same logic in
|
|
24
|
+
[`desktop_app/`](desktop_app/README.md). Install it with
|
|
25
|
+
`pip install git+https://github.com/krishnaduttPanchagnula/qgis-urban-heat-island.git@v1.1.0`
|
|
26
|
+
and launch it with `uhi-desktop`; the desktop README also covers conda, the release
|
|
27
|
+
zip and running from source.
|
|
28
|
+
|
|
29
|
+
## Install
|
|
30
|
+
|
|
31
|
+
Download `uhi_landsat_plugin_v1.0.0.zip` from the
|
|
32
|
+
[latest release](https://github.com/krishnaduttPanchagnula/qgis-urban-heat-island/releases/latest),
|
|
33
|
+
or install straight from QGIS:
|
|
34
|
+
|
|
35
|
+
1. *Plugins → Manage and Install Plugins → Settings…*
|
|
36
|
+
2. Tick **Add new repository**, name it `Urban Heat Island`, and use this URL:
|
|
37
|
+
`https://raw.githubusercontent.com/krishnaduttPanchagnula/qgis-urban-heat-island/main/plugins.xml`
|
|
38
|
+
3. Search for **Urban Heat Island (Landsat 10/11)** and click *Install Plugin*.
|
|
39
|
+
|
|
40
|
+
Manual install: unzip the release into your QGIS Python plugins folder, e.g.
|
|
41
|
+
`~/.local/share/QGIS/QGIS3/profiles/default/python/plugins/`, so that
|
|
42
|
+
`uhi_landsat/metadata.txt` sits directly under that folder. Restart QGIS and
|
|
43
|
+
enable the plugin in *Plugins → Manage and Install Plugins*. The city/heat icon
|
|
44
|
+
appears in the plugin manager and on the toolbar.
|
|
45
|
+
|
|
46
|
+
No extra software is needed — QGIS already includes everything the plugin needs.
|
|
47
|
+
|
|
48
|
+
## Before you start: getting the satellite data
|
|
49
|
+
|
|
50
|
+
The satellite files are free, but you need one of these three ways to reach them.
|
|
51
|
+
Pick whichever is easiest for you:
|
|
52
|
+
|
|
53
|
+
| Option | What you need | Best for |
|
|
54
|
+
|---|---|---|
|
|
55
|
+
| **Folder on my computer** | The satellite files already downloaded from USGS EarthExplorer into one folder | Offline work, or if you do not have cloud accounts |
|
|
56
|
+
| **AWS account** | An Amazon Web Services account (downloads cost a few cents) | Automatic download, no manual searching |
|
|
57
|
+
| **USGS website login** | Your USGS EarthExplorer login cookie | Automatic download with an existing USGS account |
|
|
58
|
+
|
|
59
|
+
Leave the source on **Automatic – try all options** and the plugin will try each
|
|
60
|
+
available option in turn and use the first one that works. If one fails, you will
|
|
61
|
+
see the reason and it will move to the next one.
|
|
62
|
+
|
|
63
|
+
## How to use it
|
|
64
|
+
|
|
65
|
+
1. Click the heat-island icon in the QGIS toolbar (or find it in the *Plugins* menu).
|
|
66
|
+
2. **Date** — choose the day you are interested in. A dry, cloud-free day works best.
|
|
67
|
+
If there is no satellite pass on that exact day, the plugin looks up to one week
|
|
68
|
+
before or after and uses the clearest image it finds.
|
|
69
|
+
3. **Location name** — type a name such as `Milan`. This is only used to name the
|
|
70
|
+
output layers.
|
|
71
|
+
4. **Latitude / Longitude** — the centre of the area. You can read these off the
|
|
72
|
+
QGIS status bar by clicking on the map.
|
|
73
|
+
5. **Radius (km)** — how far around that point to map. 20 km is a good start.
|
|
74
|
+
6. **Output folder** — where the two maps will be saved.
|
|
75
|
+
7. **Where to get the data** — choose one of the three options above. If you pick
|
|
76
|
+
*Folder on my computer*, click `...` and select the folder.
|
|
77
|
+
8. Click **OK**. A progress bar appears; you can cancel at any time. QGIS stays
|
|
78
|
+
usable while it works.
|
|
79
|
+
|
|
80
|
+
Two layers then appear in your layer panel, already coloured and ready to use.
|
|
81
|
+
A message at the bottom of QGIS tells you which data source worked and the average
|
|
82
|
+
temperature for your area.
|
|
83
|
+
|
|
84
|
+
## Understanding the maps
|
|
85
|
+
|
|
86
|
+
- The **LST** layer shows actual ground temperature in °C. Use it to compare
|
|
87
|
+
neighbourhoods or to find the warmest surfaces.
|
|
88
|
+
- The **UHI** layer sorts the area into five zones relative to the average for
|
|
89
|
+
that image: `1` cool, `2` slightly cool, `3` average, `4` warm, `5` hot spot.
|
|
90
|
+
Value `0` means no result — usually cloud or water.
|
|
91
|
+
- The zones are **relative to the area and date you chose**. They are excellent
|
|
92
|
+
for spotting heat patterns within one map, but two maps from different dates
|
|
93
|
+
should only be compared if you used the same area and settings.
|
|
94
|
+
|
|
95
|
+
## Practical tips
|
|
96
|
+
|
|
97
|
+
- Cloudy days hide the ground. Try a dry month, or let the plugin pick the
|
|
98
|
+
clearest nearby date.
|
|
99
|
+
- Cloudy and water pixels are automatically left out, so they will not distort
|
|
100
|
+
your results.
|
|
101
|
+
- Larger radii take longer to process. Start with 20 km and increase if needed.
|
|
102
|
+
- Only Landsat 8 and 9 are supported (the satellites with heat channels 10 and 11).
|
|
103
|
+
- Something not working? Open an
|
|
104
|
+
[issue](https://github.com/krishnaduttPanchagnula/qgis-urban-heat-island/issues)
|
|
105
|
+
with the message from QGIS and the date and place you entered.
|
|
106
|
+
|
|
107
|
+
## For the technically minded
|
|
108
|
+
|
|
109
|
+
Scene discovery uses the public USGS LandsatLook and Element84 Earth Search STAC
|
|
110
|
+
catalogues. Band files come from the first working of: local folder, the
|
|
111
|
+
requester-pays `usgs-landsat` S3 bucket, or `landsatlook.usgs.gov` with a session
|
|
112
|
+
cookie. Temperature is a split-window estimate,
|
|
113
|
+
`T = T10 + A·(T10−T11) + B·(T10−T11)² + C` with A=1, B=0, C=0, after radiance and
|
|
114
|
+
brightness-temperature conversion using the scene MTL file. Clear-sky pixels are
|
|
115
|
+
selected with QA_PIXEL bits 6 and 7. Processing is streamed in 512-row blocks, so
|
|
116
|
+
peak memory stays near 100 MB. Every output GeoTIFF stores provenance: source used,
|
|
117
|
+
scene ID, acquisition time, band paths, retrieval time, licence and coefficients.
|
|
118
|
+
|
|
119
|
+
`shortcut: the split-window uses fixed coefficients (clear sky, ~0.97 emissivity),
|
|
120
|
+
so this is a relative heat-island product, not a calibrated absolute temperature.
|
|
121
|
+
For absolute LST, use USGS Collection 2 Level-2 ST_B10.`
|
|
122
|
+
|
|
123
|
+
## Tests
|
|
124
|
+
|
|
125
|
+
- `python3 tests/test_core.py` — pure logic, no QGIS needed.
|
|
126
|
+
- `python3 tests/test_integration.py` — end-to-end with real GDAL bindings.
|
|
127
|
+
- `python3 tests/test_desktop.py` — desktop app worker with real GDAL bindings.
|
|
128
|
+
|
|
129
|
+
## Publishing
|
|
130
|
+
|
|
131
|
+
Maintainers: see [PUBLISHING.md](PUBLISHING.md) for PyPI trusted publishing and
|
|
132
|
+
manual `twine` upload instructions.
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# Urban Heat Island desktop app
|
|
2
|
+
|
|
3
|
+
A small standalone app that does exactly the same job as the QGIS plugin, without
|
|
4
|
+
running QGIS. It uses the **same shared engine** (`uhi_landsat/uhi_core.py`), so the
|
|
5
|
+
maps it produces are identical.
|
|
6
|
+
|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
## What it does
|
|
10
|
+
|
|
11
|
+
Enter a date, a place name, the latitude and longitude of the centre of your area,
|
|
12
|
+
and a radius. The app finds the clearest nearby Landsat satellite image and saves
|
|
13
|
+
two GeoTIFF maps in your chosen folder:
|
|
14
|
+
|
|
15
|
+
- a ground temperature map in °C;
|
|
16
|
+
- a five-zone urban heat island map (cool, slightly cool, average, warm, hot spot).
|
|
17
|
+
|
|
18
|
+
Clouds and water are left out automatically. A progress bar keeps you informed and
|
|
19
|
+
**Cancel** stops the work.
|
|
20
|
+
|
|
21
|
+
## Requirements
|
|
22
|
+
|
|
23
|
+
- Python 3.9 or newer
|
|
24
|
+
- `numpy` — installed automatically by pip
|
|
25
|
+
- GDAL Python bindings (`from osgeo import gdal`) — a system dependency that pip
|
|
26
|
+
cannot install reliably, so install it with conda or your OS package manager
|
|
27
|
+
|
|
28
|
+
If you already have QGIS installed, its Python interpreter has everything needed.
|
|
29
|
+
|
|
30
|
+
## Installation
|
|
31
|
+
|
|
32
|
+
### 1. pip (recommended)
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
pip install git+https://github.com/krishnaduttPanchagnula/qgis-urban-heat-island.git@v1.1.0
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
This adds a `uhi-desktop` command. Make sure GDAL is available in the same
|
|
39
|
+
Python environment (see option 3).
|
|
40
|
+
|
|
41
|
+
### 2. pip from the release zip
|
|
42
|
+
|
|
43
|
+
Download `uhi_desktop_v1.1.0.zip` from the
|
|
44
|
+
[release page](https://github.com/krishnaduttPanchagnula/qgis-urban-heat-island/releases/latest)
|
|
45
|
+
and install it directly:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
pip install https://github.com/krishnaduttPanchagnula/qgis-urban-heat-island/releases/download/v1.1.0/uhi_desktop_v1.1.0.zip
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### 3. Conda (easiest way to get GDAL)
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
conda create -n uhi python=3.11 numpy gdal -c conda-forge
|
|
55
|
+
conda activate uhi
|
|
56
|
+
pip install git+https://github.com/krishnaduttPanchagnula/qgis-urban-heat-island.git@v1.1.0
|
|
57
|
+
uhi-desktop
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
On Debian/Ubuntu you can also use `sudo apt install python3-gdal python3-numpy`
|
|
61
|
+
and then install with `pip --break-system-packages` or inside a virtual environment.
|
|
62
|
+
|
|
63
|
+
### 4. Download without installing
|
|
64
|
+
|
|
65
|
+
Unzip `uhi_desktop_v1.1.0.zip` (it already contains both `desktop_app/` and the
|
|
66
|
+
shared `uhi_landsat/` engine) and run:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
python desktop_app/uhi_desktop.py
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Double-clicking `uhi_desktop.py` also works where `.py` files are associated with Python.
|
|
73
|
+
|
|
74
|
+
### 5. From a source checkout
|
|
75
|
+
|
|
76
|
+
From the repository root:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
pip install .
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Run it
|
|
83
|
+
|
|
84
|
+
After a pip install, launch with:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
uhi-desktop
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
or `python -m desktop_app.uhi_desktop`. From the repository root,
|
|
91
|
+
`python desktop_app/uhi_desktop.py` works too.
|
|
92
|
+
|
|
93
|
+
## Getting the satellite data
|
|
94
|
+
|
|
95
|
+
The app offers the same three choices as the plugin:
|
|
96
|
+
|
|
97
|
+
| Option | What you need |
|
|
98
|
+
|---|---|
|
|
99
|
+
| **Folder on my computer** | Satellite files already downloaded from USGS EarthExplorer into one folder |
|
|
100
|
+
| **AWS account** | An Amazon Web Services account (a few cents per download) |
|
|
101
|
+
| **USGS website login** | Your USGS EarthExplorer login cookie |
|
|
102
|
+
|
|
103
|
+
Leave it on **Automatic - try all options** and it will use the first option that
|
|
104
|
+
works. Full step-by-step guidance is in the [main README](../README.md).
|
|
105
|
+
|
|
106
|
+
## Notes
|
|
107
|
+
|
|
108
|
+
- Keep the two folders together: `desktop_app/` imports the engine from
|
|
109
|
+
`../uhi_landsat/`.
|
|
110
|
+
- The app never freezes: downloads and processing run in a background thread.
|
|
111
|
+
- Memory use stays near 100 MB even for large areas, because the images are
|
|
112
|
+
processed in small blocks.
|
|
113
|
+
- Results are relative to the area and date you chose, so compare different dates
|
|
114
|
+
only when you use the same area and settings.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Standalone desktop app for the urban heat island workflow."""
|
|
Binary file
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
"""Standalone desktop app for the urban heat island workflow.
|
|
2
|
+
|
|
3
|
+
Uses the exact same uhi_core engine as the QGIS plugin, so results match.
|
|
4
|
+
Only requirements: Python 3, numpy and GDAL Python bindings.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import os
|
|
8
|
+
import queue
|
|
9
|
+
import subprocess
|
|
10
|
+
import sys
|
|
11
|
+
import threading
|
|
12
|
+
import tkinter as tk
|
|
13
|
+
from datetime import date, datetime, timedelta
|
|
14
|
+
from tkinter import filedialog, messagebox, ttk
|
|
15
|
+
|
|
16
|
+
HERE = os.path.dirname(os.path.abspath(__file__))
|
|
17
|
+
try: # pip-installed package
|
|
18
|
+
from uhi_landsat import uhi_core as core # noqa: E402
|
|
19
|
+
except ImportError: # running straight from a source checkout
|
|
20
|
+
sys.path.insert(0, os.path.join(HERE, "..", "uhi_landsat"))
|
|
21
|
+
import uhi_core as core # noqa: E402
|
|
22
|
+
|
|
23
|
+
SOURCES = [
|
|
24
|
+
("Automatic - try all options", "auto"),
|
|
25
|
+
("Folder on my computer", "local"),
|
|
26
|
+
("AWS account (small download fee)", "aws_s3"),
|
|
27
|
+
("USGS website login", "usgs_https"),
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class App:
|
|
32
|
+
def __init__(self, root):
|
|
33
|
+
self.root = root
|
|
34
|
+
root.title("Urban Heat Island - Landsat 10/11")
|
|
35
|
+
root.resizable(False, False)
|
|
36
|
+
icon_path = os.path.join(HERE, "icon.png")
|
|
37
|
+
if os.path.exists(icon_path):
|
|
38
|
+
self.icon = tk.PhotoImage(file=icon_path)
|
|
39
|
+
root.iconphoto(True, self.icon)
|
|
40
|
+
|
|
41
|
+
self.queue = queue.Queue()
|
|
42
|
+
self.worker = None
|
|
43
|
+
self.cancel_event = threading.Event()
|
|
44
|
+
self.last_output_dir = None
|
|
45
|
+
|
|
46
|
+
main = ttk.Frame(root, padding=14)
|
|
47
|
+
main.grid(row=0, column=0, sticky="nsew")
|
|
48
|
+
|
|
49
|
+
ttk.Label(main, text="Make an urban heat island map from a satellite image",
|
|
50
|
+
font=("DejaVu Sans", 12, "bold")).grid(row=0, column=0, columnspan=3,
|
|
51
|
+
sticky="w", pady=(0, 10))
|
|
52
|
+
|
|
53
|
+
row = 1
|
|
54
|
+
self.date_var = tk.StringVar(value=(date.today() - timedelta(days=30)).isoformat())
|
|
55
|
+
row = self._entry(main, row, "Date (YYYY-MM-DD)", self.date_var)
|
|
56
|
+
|
|
57
|
+
self.place_var = tk.StringVar(value="Milan")
|
|
58
|
+
row = self._entry(main, row, "Location name", self.place_var)
|
|
59
|
+
|
|
60
|
+
self.lat_var = tk.StringVar(value="45.4642")
|
|
61
|
+
row = self._entry(main, row, "Latitude of centre", self.lat_var)
|
|
62
|
+
|
|
63
|
+
self.lon_var = tk.StringVar(value="9.1900")
|
|
64
|
+
row = self._entry(main, row, "Longitude of centre", self.lon_var)
|
|
65
|
+
|
|
66
|
+
self.radius_var = tk.StringVar(value="20")
|
|
67
|
+
row = self._entry(main, row, "Radius in km", self.radius_var)
|
|
68
|
+
|
|
69
|
+
self.output_var = tk.StringVar(value=os.path.expanduser("~/uhi_output"))
|
|
70
|
+
row = self._entry(main, row, "Save maps in", self.output_var, browse="folder")
|
|
71
|
+
|
|
72
|
+
self.local_var = tk.StringVar()
|
|
73
|
+
row = self._entry(main, row, "Folder with satellite files (optional)",
|
|
74
|
+
self.local_var, browse="folder")
|
|
75
|
+
|
|
76
|
+
ttk.Label(main, text="Where to get the data").grid(row=row, column=0, sticky="w", pady=4)
|
|
77
|
+
self.source_combo = ttk.Combobox(main, state="readonly",
|
|
78
|
+
values=[label for label, _ in SOURCES], width=34)
|
|
79
|
+
self.source_combo.current(0)
|
|
80
|
+
self.source_combo.grid(row=row, column=1, columnspan=2, sticky="w", pady=4)
|
|
81
|
+
row += 1
|
|
82
|
+
|
|
83
|
+
self.cookie_var = tk.StringVar()
|
|
84
|
+
self._entry(main, row, "USGS login cookie (optional)", self.cookie_var, show="*")
|
|
85
|
+
row += 1
|
|
86
|
+
|
|
87
|
+
buttons = ttk.Frame(main)
|
|
88
|
+
buttons.grid(row=row, column=0, columnspan=3, pady=(12, 6), sticky="w")
|
|
89
|
+
self.run_button = ttk.Button(buttons, text="Make the maps", command=self.start)
|
|
90
|
+
self.run_button.pack(side="left")
|
|
91
|
+
self.cancel_button = ttk.Button(buttons, text="Cancel", command=self.cancel,
|
|
92
|
+
state="disabled")
|
|
93
|
+
self.cancel_button.pack(side="left", padx=6)
|
|
94
|
+
self.open_button = ttk.Button(buttons, text="Open output folder",
|
|
95
|
+
command=self.open_output, state="disabled")
|
|
96
|
+
self.open_button.pack(side="left")
|
|
97
|
+
row += 1
|
|
98
|
+
|
|
99
|
+
self.progress = ttk.Progressbar(main, mode="determinate", length=410)
|
|
100
|
+
self.progress.grid(row=row, column=0, columnspan=3, sticky="w", pady=(4, 4))
|
|
101
|
+
row += 1
|
|
102
|
+
|
|
103
|
+
self.status = tk.StringVar(value="Fill in the form and click 'Make the maps'.")
|
|
104
|
+
ttk.Label(main, textvariable=self.status, foreground="#333333",
|
|
105
|
+
wraplength=430, justify="left").grid(row=row, column=0, columnspan=3,
|
|
106
|
+
sticky="w", pady=(0, 8))
|
|
107
|
+
row += 1
|
|
108
|
+
|
|
109
|
+
self.result = tk.Text(main, height=6, width=62, state="disabled")
|
|
110
|
+
self.result.grid(row=row, column=0, columnspan=3, sticky="w")
|
|
111
|
+
row += 1
|
|
112
|
+
ttk.Label(main, text="Blank areas on the maps are cloud or water.",
|
|
113
|
+
foreground="#666666").grid(row=row, column=0, columnspan=3, sticky="w",
|
|
114
|
+
pady=(6, 0))
|
|
115
|
+
|
|
116
|
+
def _entry(self, parent, row, label, variable, browse=None, show=None):
|
|
117
|
+
ttk.Label(parent, text=label).grid(row=row, column=0, sticky="w", pady=4)
|
|
118
|
+
entry = ttk.Entry(parent, textvariable=variable, width=42, show=show)
|
|
119
|
+
entry.grid(row=row, column=1, columnspan=2, sticky="w", pady=4)
|
|
120
|
+
if browse:
|
|
121
|
+
ttk.Button(parent, text="...", width=3,
|
|
122
|
+
command=lambda: self._pick(variable)).grid(row=row, column=3, padx=(4, 0))
|
|
123
|
+
return row + 1
|
|
124
|
+
|
|
125
|
+
def _pick(self, variable):
|
|
126
|
+
chosen = filedialog.askdirectory(initialdir=variable.get() or os.path.expanduser("~"))
|
|
127
|
+
if chosen:
|
|
128
|
+
variable.set(chosen)
|
|
129
|
+
|
|
130
|
+
def _params(self):
|
|
131
|
+
try:
|
|
132
|
+
day = datetime.strptime(self.date_var.get().strip(), "%Y-%m-%d").date()
|
|
133
|
+
lat = float(self.lat_var.get())
|
|
134
|
+
lon = float(self.lon_var.get())
|
|
135
|
+
radius = float(self.radius_var.get())
|
|
136
|
+
except ValueError:
|
|
137
|
+
raise ValueError("Check the date (YYYY-MM-DD) and the latitude, longitude "
|
|
138
|
+
"and radius numbers.")
|
|
139
|
+
if radius <= 0:
|
|
140
|
+
raise ValueError("Radius must be greater than zero.")
|
|
141
|
+
label = SOURCES[self.source_combo.current()][1]
|
|
142
|
+
return {
|
|
143
|
+
"day": day.isoformat(),
|
|
144
|
+
"location": self.place_var.get().strip() or "area",
|
|
145
|
+
"lat": lat, "lon": lon, "radius_km": radius,
|
|
146
|
+
"output_dir": self.output_var.get().strip() or os.path.expanduser("~/uhi_output"),
|
|
147
|
+
"local_dir": self.local_var.get().strip(),
|
|
148
|
+
"source": label,
|
|
149
|
+
"cookie": self.cookie_var.get().strip(),
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
def start(self):
|
|
153
|
+
try:
|
|
154
|
+
params = self._params()
|
|
155
|
+
except ValueError as exc:
|
|
156
|
+
messagebox.showerror("Check your entries", str(exc))
|
|
157
|
+
return
|
|
158
|
+
self.cancel_event.clear()
|
|
159
|
+
self.queue = queue.Queue()
|
|
160
|
+
self.progress["value"] = 0
|
|
161
|
+
self.status.set("Looking for a satellite image...")
|
|
162
|
+
self.result.configure(state="normal")
|
|
163
|
+
self.result.delete("1.0", "end")
|
|
164
|
+
self.result.configure(state="disabled")
|
|
165
|
+
self.run_button.configure(state="disabled")
|
|
166
|
+
self.cancel_button.configure(state="normal")
|
|
167
|
+
self.open_button.configure(state="disabled")
|
|
168
|
+
self.worker = threading.Thread(target=self._work, args=(params,), daemon=True)
|
|
169
|
+
self.worker.start()
|
|
170
|
+
self.root.after(100, self._poll)
|
|
171
|
+
|
|
172
|
+
def _work(self, params):
|
|
173
|
+
def progress(value, message):
|
|
174
|
+
self.queue.put(("progress", value, message))
|
|
175
|
+
try:
|
|
176
|
+
result = core.compute(params, progress, self.cancel_event.is_set)
|
|
177
|
+
self.queue.put(("done", result))
|
|
178
|
+
except core.Cancelled:
|
|
179
|
+
self.queue.put(("cancelled", None))
|
|
180
|
+
except Exception as exc:
|
|
181
|
+
self.queue.put(("error", "{}: {}".format(type(exc).__name__, exc)))
|
|
182
|
+
|
|
183
|
+
def _poll(self):
|
|
184
|
+
while True:
|
|
185
|
+
try:
|
|
186
|
+
item = self.queue.get_nowait()
|
|
187
|
+
except queue.Empty:
|
|
188
|
+
break
|
|
189
|
+
kind, payload = item[0], item[1]
|
|
190
|
+
if kind == "progress":
|
|
191
|
+
self.progress["value"] = payload
|
|
192
|
+
self.status.set(item[2])
|
|
193
|
+
elif kind == "done":
|
|
194
|
+
stats = payload["stats"]
|
|
195
|
+
self.last_output_dir = os.path.dirname(payload["lst_path"])
|
|
196
|
+
self.progress["value"] = 100
|
|
197
|
+
self.status.set("Done. Maps saved in {}.".format(self.last_output_dir))
|
|
198
|
+
text = ("Data source: {}\nAverage temperature: {:.1f} °C\n"
|
|
199
|
+
"Temperature range: {:.1f} to {:.1f} °C\n"
|
|
200
|
+
"Clear-sky pixels: {}\n\nTemperature map: {}\nHeat-zone map: {}"
|
|
201
|
+
.format(payload["source"], stats["mean"], stats["min"],
|
|
202
|
+
stats["max"], stats["valid_pixels"],
|
|
203
|
+
payload["lst_path"], payload["uhi_path"]))
|
|
204
|
+
self._show_result(text)
|
|
205
|
+
self.open_button.configure(state="normal")
|
|
206
|
+
messagebox.showinfo("Finished", "Your two maps are ready.")
|
|
207
|
+
elif kind == "error":
|
|
208
|
+
self.status.set("Could not finish: {}".format(payload))
|
|
209
|
+
messagebox.showerror("Something went wrong", payload)
|
|
210
|
+
elif kind == "cancelled":
|
|
211
|
+
self.status.set("Cancelled.")
|
|
212
|
+
self.progress["value"] = 0
|
|
213
|
+
if self.worker and self.worker.is_alive():
|
|
214
|
+
self.root.after(100, self._poll)
|
|
215
|
+
else:
|
|
216
|
+
self.run_button.configure(state="normal")
|
|
217
|
+
self.cancel_button.configure(state="disabled")
|
|
218
|
+
|
|
219
|
+
def _show_result(self, text):
|
|
220
|
+
self.result.configure(state="normal")
|
|
221
|
+
self.result.delete("1.0", "end")
|
|
222
|
+
self.result.insert("1.0", text)
|
|
223
|
+
self.result.configure(state="disabled")
|
|
224
|
+
|
|
225
|
+
def cancel(self):
|
|
226
|
+
self.cancel_event.set()
|
|
227
|
+
self.status.set("Stopping after the current step...")
|
|
228
|
+
|
|
229
|
+
def open_output(self):
|
|
230
|
+
path = self.last_output_dir
|
|
231
|
+
if path and os.path.isdir(path):
|
|
232
|
+
try:
|
|
233
|
+
if sys.platform.startswith("win"):
|
|
234
|
+
os.startfile(path)
|
|
235
|
+
elif sys.platform == "darwin":
|
|
236
|
+
subprocess.run(["open", path], check=False)
|
|
237
|
+
else:
|
|
238
|
+
subprocess.run(["xdg-open", path], check=False)
|
|
239
|
+
except OSError:
|
|
240
|
+
messagebox.showinfo("Output folder", path)
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
def main():
|
|
244
|
+
root = tk.Tk()
|
|
245
|
+
App(root)
|
|
246
|
+
root.mainloop()
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
if __name__ == "__main__":
|
|
250
|
+
main()
|