Reduce Satellite Image Resolution with Google Earth Engine
By: Irfan Alghani Khalid
Tags: Machine Learning, GIS, Data Science, Remote Sensing, Data Analysis

Implementation

Problem statement

In this article, I will use several satellite images. Here is the list of the data that I will use.

Precipitation data from TRMM 3B43. It has a 25 KM per pixel resolution. This data will be downscaled to 1 KM so we can see highly detailed precipitation data (link)

Normalized Difference Vegetation Index (NDVI) from MODIS. It records the quality of vegetation in a certain area, and it has 1 KM per pixel resolution. This data will be a predictor of the precipitation data (link)

Digital Elevation Model (DEM) from SRTM. It records elevation on earth, and it has 90 M per pixel resolution. This data will be a predictor of the precipitation data (link)

Land Cover from MODIS. It records the land cover type for a location, and it has 500 M per pixel resolution. This data will be a predictor of the precipitation data (link)

The final goal for using those data is to build a machine learning model to do spatial downscaling on a satellite that collects precipitation data.

In short, spatial downscaling is a method to increase the pixel resolution of a satellite image by looking at association with other variables. Machine learning can help in getting association between the satellite image and the other variables.

I will not explain the spatial downscaling further, but in the future, I hope I can share it with you in the future article. Right now, I only show you how to reproject and reduce the satellite image resolution.

Also, to make our scope smaller, we only take data from Riau Province, Indonesia. Here is the preview of the final result from this tutorial.

The Final Result

Prepare the data and libraries

After we got the problem statement, the next step is to import the GEE library. Here is the code for doing that.

When we run the code, we will get a prompt to input our verification code, so we need to go to a given link and retrieve the code. Here is what the output looks like after we run the code and put the verification code.

To authorize access needed by Earth Engine, open the following URL in a web browser and follow the instructions. If the web browser does not start automatically, please manually browse the URL below.



<LINK TO THE VERIFICATION CODE> The authorization workflow will generate a code, which you should paste in the box below.

Enter verification code: <THE VERIFICATION CODE> Successfully saved authorization token.

Get the shapefile data

The next step is to get the shapefile data. As I mentioned above, we will take data from Riau Province only. Therefore, we need to have a shapefile with a .shp format to remove the data outside that province. We will take the data from GADM. Here is the code for downloading the data.



! unzip gadm36_IDN_shp.zip ! wget https://biogeo.ucdavis.edu/data/gadm3.6/shp/gadm36_IDN_shp.zip ! unzip gadm36_IDN_shp.zip

Here is the code to load the data and filter it to retrieve only Riau Province.

Here is the result,

To use the shapefile on the earth engine, we need to save this file to GeoJSON format. Then, we put the GeoJSON file to an object called ee.Geometry. To do that, we can use the code like this,

Now we can use the object to clip our satellite images, so it removes images that don’t belong to that object.

Get the satellite data

The next step is to import our satellite image data. For your information, each data has different methods to load the images.

For data that has only one image, we can access it with ee.Image class. For data that has lots of images, we can access it with ee.ImageCollection class.

To aggregate the data from ee.ImageCollection class, we can use reduce method to convert the ee.ImageCollection object to ee.Image object, whether by aggregating them using average, median, etc.

Here is the code to load the data.

Reduce the satellite data resolution

The next step is to reduce our satellite images resolution. The goal of this step is to make the satellite images have a similar resolution as each other. This step also normalizes the projection of our satellite, which is the crucial step before we can model our data using machine learning.

The step that we need to do for all satellite images are,

Reproject each images using projection from our shapefile using reproject method Reduce the resolution for each satellite images to 25KM (25000 M) by calculating the average on each pixel using reduceResolution method Clip the images, so we only have images that intersect with the shapefile using the clip method

Here is the code for reducing satellite resolution:

Now let’s see whether our images have the same projection as the shapefile. Here is the code and the result before and after we change the projection and reduce the resolution of the image.

As you can see above, now our images have the same projection (CRS) as our shapefile. Also, our images already have a similar resolution, which is 25KM. You can see it in the ‘transform’ section. Now we can save the result to GeoTIFF format.

Save the result

To save the result to our Google Drive, we can use ee.batch.Export.image.toDrive method to do that. Here is the code for saving our images with GeoTIFF format.