Friday, December 18, 2020

Consuming Analysis from Spatial Studio directly from OAC

Spatial Analysis is a process in which you model problems geographically and compute results using various spatial calculation. This is something that is used widely in many scenarios which include analyzing the results of an election, finding areas that are likely to affected by a hurricane when it makes a landfall, etc... Spatial technology helps in understanding where things occur, measuring sizes, shapes, geographical distributions, relationships and interactions between places, and more.

Spatial Studio is a web application built by Oracle that provides a great graphical user interface leveraging the underlying Oracle Database spatial functions. Once Spatial calculations and analysis are computed with Spatial Studio, results can then easily be dynamically visualized in Oracle Analytics. This blog shows how to enable that dynamic aspect of consumption of Spatial Studio analysis directly into Oracle Analytics.

In our scenario here, we work at an insurance company in the United States with many home or car insurance customer policies. US meteorological department just predicted that hurricane NATE will be making a landfall in the country in another couple of days. Experts are predicting that it will create havoc to real estate assets that lie within the 100 kms buffer of it's path. As a business analyst for the insurance company, we need to analyze and asses the likely damage to the properties and the expected expenditure. This is a perfect example for spatial analysis and we are going to see how Spatial Studio in combination with OAC is making it very easy for us. 

The first step is to proceed with the spatial analysis in Spatial Studio 

Let's upload the customer assets data into Studio (the database) as well as the geographical data associated with the hurricane expected path. The data for the hurricane was obtained under the form of shape files (from the web). Visualizing these two overlaid onto each other in Spatial studio renders this :


Then, Studio easily allows to compute and visualize a buffer of 100kms around the hurricane path. This can be done by using the transform operation in studio to add a buffer of 100kms distance. 


Finally we a spatial analysis will identify all the customer assets that lie inside the buffer zone. This is achieved by the usage of the Filter operation that returns all shapes contained inside another.


That was so easy and the resulting spatial analysis is now saved into the Spatial Studio database. Le'ts just go and check the list of datasets in the Spatial Studio, where we should find the results of our analysis.

Let's now expose the Spatial calculations results directly to Oracle Analytics

With its 20.1 release, Spatial Studio now allows to represent these results under the form of a query-able synonym object in the database. Right click on a spatial analysis dataset and choose Properties. Under the Settings tab, a new property field called "Synonym" is introduced. Give a name that you want to assign to the spatial analysis dataset to this field. This will be the name of the public view in which the spatial analysis dataset will be saved in the database. In this example, let us give it a name 'oac_spatial_analysis' and choose Apply.


So at this point, we completed the analysis in Studio to identify customer assets that are at risk because of the hurricane, and we have assigned a synonym value to the results-set of this data. The work Spatial Studio part is now completed and let us move on to the OAC part.

From an OAC instance, let's create a connection to the database used by Spatial Studio and choose the appropriate schema. Now search for the synonym name to find the corresponding spatial analysis dataset. In our case, we search for 'oac_spatial_analysis'.



We can see the dataset, but we cannot directly add it into OAC since it contains columns of SDO_GEOMETRY data type. As of 5.9 release, OAC cannot handle that datatype but it will be enabled soon in an upcoming release. Meanwhile, the temporary workaround for adding spatial analysis dataset is be to enter a SQL command to get all the data from the spatial analysis dataset except for the SDO_GEOMETRY column :


In the above picture, we have issued a SQL statement against oac_spatial_analysis (synonym) view which includes all the columns except for the geometry column. This includes valuable information such as customer ids, names, addresses etc. We can now add this dataset into OAC.

Now we can visualize the list of customer assets that are at risk and the business analyst of the insurance company can get quick insights by blending this spatial results with his onw business datasets in OAC.

Thanks for reading this blog !

No comments:

Post a Comment