Usage examples for Python in QGIS
Usage flow of the API in QGIS
Please follow these instruction.
Launch QGIS in your computer.
Click Browser -> XYZ tiles -> OpenStreetMap to fix CRS(Coordinate Reference System) to EPSG3857 and to detect bounding box.
Zoom up/down to set your region of interest.
Open Plugins -> Python Console.
In Python console, click Show Editor icon to open editor.
In editor window, make new script or open your python script.
Execute your Python script by clicking Run Script icon.
Get and show an image in QGIS
If you already installed python and the module, please check module’s location by the command.
$ pip show jaxa.earth
The module’s location will be like this.
"C:\users\UserName\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages"
If you did not installed neither of python and the module, simply add your unzipped/untarred module’s absolute path, like this.
"C://YOUR-FOLDER-PATH/jaxa-earth-0.1.2"
It’s necessary to append absolute path of the API module to system path. Please use “/” instead of “\” in module path’s text.
If you don’t input ppu or bbox, these parameters will be automaticlly selected depends
on your looking area and display’s resolution. If you got ssl error,
please set ssl_verify to False
.
Instead of using show_images
, use show_images_qgis
in QGIS to aquire raster files.
The raster files saved in temporal folder, so if you quit QGIS without saving,
the raster data will be discarded.
# Add path
import sys
sys.path.append("C://YOUR-FOLDER-PATH/jaxa-earth-0.1.2")
# Load module
from jaxa.earth import je
# Get an image
data = je.ImageCollection(ssl_verify=True)\
.filter_date()\
.filter_resolution()\
.filter_bounds()\
.select()\
.get_images()
# Process and show an image
img = je.ImageProcess(data)\
.show_images_qgis()
It looks like an image below if you execute the script.
