Examples of using the API for Python in QGIS

Flow of how to use the API in QGIS

Please follow these instructions.

  1. Launch QGIS on your computer.

  2. Click Browser -> XYZ tiles -> OpenStreetMap to fix CRS(Coordinate Reference System) to EPSG3857 and to detect bounding box.

  3. Zoom up/down to set your region of interest.

  4. Open Plugins -> Python Console.

  5. In Python console, click Show Editor icon to open editor.

  6. In editor window, make new script or open your Python script.

  7. Execute your Python script by clicking Run Script icon.

Get and show an image in QGIS

If you have already installed Python and the module, please check the location of the module using the command.

$ pip show jaxa.earth

The location of the module will be as follows.

"C:\users\UserName\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages"

If you have installed neither Python nor the module, simply add the absolute path of your unzipped/untarred module, like this.

"C://YOUR-FOLDER-PATH/jaxa-earth-0.1.4"

It’s necessary to append absolute path of the API module to system path. Please use “/” instead of “\” in module path text.

If you don’t input ppu or bbox, these parameters will be automatically selected depending on your viewing area and display resolution. If you get ssl error, please set ssl_verify to False.

Instead of using show_images, use show_images_qgis in QGIS to acquire raster files. The raster files are saved in a temporary 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.4")

# 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()

When you execute the script, it looks like the image below .

_images/FigureQGIS01.png