How to create maps from satellite images for agricultural applications

Here is a scope of maps built from satellite images that might be useful for precision agriculture applications. You can embed queries from examples into your codes as is or freely customize them. You will find in these examples how to:

- process satellite images in RGB, NDVI and false colors

- set up any color schemes with any scale

- choose a particular date or period of time to make the most recent or season maps

- generate maps with a tile server for a broad territory or by a polygon for the particular crop


First, assign your area of interest and explore all available satellite images for it in 3 simple steps


Step 1. Get your API key

Sign up to get your API key, always use it in each query as &APPID={APIKEY}. Query language documentation is here.


Step 2. Setup a polygon

We use GeoJSON format for polygons.

You can use our visual tool to draw a polygon and get a list of coordinated in the popup window. Copy it and paste into the query.

Query template

&where=day=2016-07-10&op=ndvi&polygon={"type":"Feature","geometry":{"type":"Polygon","coordinates":[[[-102.73,34.43],[-102.73,34.49],[-102.57,34.49],[-102.57,34.43],[-102.73,34.43]]]}}&APPID={APIKEY}


Step 3. Get dates for which satellite images are available

Search for all available images for your polygon in our database. Setup your polygon you prepared in step 2, and search.

You can also setup a cloudiness. For example, if you are looking for dates when images had cloudiness less than 40%, add a filter &where=clouds< 40.

Query template

api.sat.owm.io/api/3.0/search?polygon={"type":"Feature","geometry":{"type":"Polygon","coordinates":[[[-102.73,34.43],[-102.73,34.49],[-102.57,34.49],[-102.57,34.43],[-102.73,34.43]]]}}&APPID={APIKEY}

Example of the respond:

                [
                {"date":"2013-12-12","day":"2013-346","time":1386874046,"clouds":0.76,
                "sun":{"elevation":27.06930431,"azimuth":160.64830388},
                "intersection":100,
                "bands":["B2","B3","B4","B5","B7"],
                "scenes":["LC80440342013346LGN00"],
                "status":"loaded"},
                
                {"date":"2016-04-01","day":"2016-092","time":1459535960,"clouds":0.59,
                "sun":{"elevation":51.94210445,"azimuth":143.49839958},
                "intersection":100,
                "bands":["B2","B3","B4","B5","B7"],
                "scenes":["LC80430342016092LGN00"],
                "status":"loaded"},
                ...
                ]

Workout 1. Compute NDVI for your polygon, for any date

In this example, we work with Sentinel 2 by setting from=s2. We have picked up a day, July 10, 2016, as where=day=2016-07-10.

For NDVI calculation bands parameters should be indicated as select=b8,b4, and type of operation as op=ndvi.

Query template

sat.owm.io/sql?from=s2&select=b8,b4&where=day=2016-07-10&op=ndvi&polygon={"type":"Feature","geometry":{"type":"Polygon","coordinates":[[[-102.73,34.43],[-102.73,34.49],[-102.57,34.49],[-102.57,34.43],[-102.73,34.43]]]}}&APPID={APIKEY}

Result:

...

Workout 2. Setup your color scheme of NDVI

In this example, we have chosen satellite image for the particular day as where=day=2016-07-10, compute NDVI for our polygon with select=b8,b4 and op=ndvi.

To set up a color scheme, use the parameter of &color. This parameter consists of pairs of numbers like 0.03:fcfefcff separated by semicolons. The first number in the pair is NDVI value from 0 to 1 that you can set up with any decimal places (0.03 in our example). The second is hex code for colors (fcfefcff).

Query template

sat.owm.io/sql?from=s2&select=b8,b4&where=day=2016-07-10&op=ndvi&polygon={"type":"Feature","geometry":{"type":"Polygon", "coordinates":[[[-102.73,34.43],[-102.73,34.49],[-102.57,34.49],[-102.57,34.43],[-102.73.43]]]}} &color=0:d93f2aff;0.05:df452cff;0.1:e66c2eff;0.15:e4622dff;0.2:f2b331ff; 0.25:f7d932ff;0.3:eff630ff;0.35:b0f321ff;0.4:80f116ff;0.45:76f013ff; 0.5:74ed17ff;0.55:6cde28ff;0.6:50ab56ff;0.65:317b83ff;0.7:0648b3ff;0.75:1f46f0ff;0.8:2d45e9ff;0.85:533dcaff;0.9:783bb1ff;1:a342aeff; &APPID={APIKEY}

Result:

...



Workout 5. The most recent NDVI with tile server

You should call a tile server with /{z}/{x}/{y}, setup processing type as &op=ndvi and choose the most recent images with &order=last

Query template

{s}.sat.owm.io/sql/{z}/{x}/{y}?select=b8,b4&from=s2&op=ndvi&order=last&APPID={APIKEY}

Result:

Map

Workout 6. Season NDVI map with tile server

You should call a tile server with /{z}/{x}/{y}, setup processing type as &op=ndvi and indicate a period,e.g. April, as &where=between(2016-04-01:2016-04-30). We choose only cloudiness images with &order=best

Query template

{s}.sat.owm.io/sql/{z}/{x}/{y}?select=b5,b4&op=ndvi&where=between:(2016-04-01,2016-04-30)&order=best&APPID={APIKEY}

Result:

Map