# Sensor Observation Service API for Providing Gridded Climate Data to Agricultural Applications
## 3 Methodology
### Caching Mechanism  
The total Japanese territory is 377,972 km\({}^{2}\), while the NetCDF mesh count is 2,457,600 meshes. The total area of farmland in Japan is 4.5 million hectares, which is equivalent to 45,000 km\({}^{2}\)[26]. We cannot simply store all data on the cloud platform, as this requires huge disk space and leads to expensive system maintenance. Referring to the cloud platform pricing list at [[https://www.conoha.jp/en/pricing](https://www.conoha.jp/en/pricing)]([https://www.conoha.jp/en/pricing](https://www.conoha.jp/en/pricing)), we focus on a basic plan, which is 1 GB of RAM, 2 cores of CPU and 50 GB of storage. One fifth of the storage is used for operation, and the rest is for the caching system. Each time when NARO Agent responds to an SOS getObservation request, the simple mesh ID is recorded, and the data are cached in the system. The grids in the cache system are updated every day because we expect that users may frequently access the same grids. The access timestamp and \begin{table}
\begin{tabular}{c c} \hline \hline
**Land Use ID** & **Description** \\ \hline landuse\_H210100 & Paddy field \\ landuse\_H210200 & Other type of farmland \\ landuse\_H210500 & Forest \\ landuse\_H210600 & Unused land \\ landuse\_H210700 & Urban area \\ landuse\_H210901 & Road \\ landuse\_H211000 & Athletics facilities \\ landuse\_H211100 & Rivers and lakes \\ landuse\_H211400 & Sea shore \\ landuse\_H211500 & Tideland \\ landuse\_H211600 & Golf course \\ \hline \hline \end{tabular}
\end{table} 
Table 6: Land use ID in the AmGSD system [1]. \begin{table}
\begin{tabular}{c c c} \hline \hline
**Parameter** & **Example Value** & **Description** \\ \hline lower & 35.3542 139.456 & Lower corner of target area \\ \hline upper & 35.3542 140.456 & Upper corner of target area \\ \hline Land use & landuse\_H210100 & Land use code or prefecture code can be used for filtering; \\  & & AmGSD provides those codes in [1] \\ \hline ratio & 50 & Percentage for filtering of the land use; the default is 50 percent \\ \hline sort & timestamp & Sort key is for giving the priority of the search mesh; the list of values is the timestamp, frequency and cache \\ \hline reverse & true or false & This parameter is related to the sort value; it gives a condition of \\  & & sorting, which is descending or ascending; true is descending, \\  & & and false is ascending; false is set as the default \\ \hline \hline \end{tabular}
\end{table} 
Table 7: Request parameters of the Mesh Info API. frequency are recorded whenever users access them, so that we can dynamically optimize the caching system. When the amount of cached data exceeds the threshold, the grids that have seldom been accessed will be removed from the cache. In this way, the agent can respond quickly to often-accessed grids with no need to keep all data. According to the AmGSD land use information of each grid, we utilize this information for initializing the most efficient cache by identifying grids to be pre-cached in the system with criteria based on land use status and prefecture. Pre-Caching Mechanism  
The caching system explained in the previous section improves the response time from the second access. To maximize the response from the first access, we introduced a pre-caching mechanism. We developed this system primarily for agriculture applications. Therefore, we expected that most grids that are accessed will be in farmland. Before starting the SOS API service, we developed a pre-caching script. The script issued the getObservation request to grids that would have a high frequency of access to register them into the caching system. The grids to be pre-cached were selected based on land use and prefecture. We identified and counted grids that had an agricultural land use ratio greater than a certain threshold. This research is a part of an agricultural project that mainly focuses on rice cropping in Aichi prefecture. Thus, grids within Aichi prefecture that contain paddy fields of more than 20 percent are cached into the system before the clients' requests.