Thursday, July 16, 2020

Maps - Custom Image backgrounds Part II

The Voyageurs Wolf Project was an initiative taken by University of Minnesota in collaboration with the Voyageurs National Park to study the ecology of wolves and their prey(moose, dear, beavers etc) during the summer in Great Voyageurs ecosystem. Specifically this research was aimed at studying the movement pattern of the wolves and its reproductive ecology.

To track the movements of wolves and their packs, the researchers targeted multiple wolves of 4 different wolf packs and attached a GPS tracking device to the animals. The location of these wolves were tracked every hour for 3 alternate days. The results are fascinating and present a great use case for data analysis. Researchers have a specific image covering the habitat of Voyageurs National Park and they have a set of Lat/Longs representing the positions of the wolves over time, they need to visualize these positions on top of the habitat image. Oracle Analytics provides a very simple way to easily achieve this. Users have the ability to upload any images as map backgrounds and to create map layers on top of these images. In case you missed it, here is a blog entry which covers this feature in detail.

An Oracle Analytics user can upload the image of the National Park, and could take the approach of manually creating points (as a layer), representing possible positions of the wolves on top of the image. But with the amount of distinct Lat/Longs positions in the data, this process would be too hard or too long. The number of points is going to be huge and building a pre-set layer process will turn out to be a real pain.
Great news : that there is a much simpler and elegant way to achieve this, where we wipe away the manual and error-prone step of creating of point layers on top of the image. Oracle Analytics allows to directly plot Lat/Longs data (or any coordinates) on top of any image used as a map background. No need to create any layers !

Here are the simple steps to be followed to achieve the result

1) Upload the image of the national park as a map backgrounds

Image of Voyageur National Park

2) Upload the dataset having the position of the wolves and their corresponding positions.
Dataset used for the experiment

3) Find the National Park image background from the Maps Console and choose the Inspect option. By default the coordinates are set to Auto


Now choose Custom(Lat,Long) from the drop down. This prompts to enter the bounding Lat/Longs for the image


The bounding box of the lat/long covered by the Voyageur National Park can be easily obtained through a simple web search and we will be using that information to fill the above fields.

After entering the values for Lat/Long, click on the Save button to save the changes made to the image background.

4) Create a project using the dataset, drag and drop the Lat and Long columns on to a canvas and select map viz. The Map Viz will default with a world map background, and plot the points on the default map background.


5) Go to the viz properties and change the background map to Image background depicting the Voyageurs National Park : click on map viz properties (bottom left), click on the Map icon, and select the Voyageur National Park Map backgrdound we just uploaded


and you should see the wolf positions on the image background.

The color represents the different wolf packs that were involved in the research. It is a pretty visual point that distinct wolf packs seem to avoid each other’s range. They generally avoid being around each other unless they are fighting for food that may be in short supply. When that occurs, they may engage in battles with other packs in order to continue have their claim on a given location as well as the food found within it. 

So Oracle Analytics not only allows user to upload any images as backgrounds for map visuals, but provides the ability to either define layers on it, or directly use coordinate systems to plot any amount of points data on the image directly. That allows pretty visual representations of the data. This blog entry leveraged direct Lat/Long information for, this, in an upcoming blog entry we will highlight how this can be used with different use case, such as shop-floor traffic.

Monday, July 6, 2020

Building a filter-selective calculation with Oracle Analytics - Part II

In our previous post here, we discussed a technique to build custom metrics in Oracle Analytics Self Service (DV, no RPD modeling) that would not obey to filter selections. Our use case was a a global revenue canvas where, if a user selects a specific country from a canvas filter, the metric % of Total Global Revenue would remain showing ratio of this country's revenue vs the whole global, unfiltered revenue.

We achieved this by duplicating the dataset in DV, defining a 'full-outer' join between our two datasets, and simply building a calculation with numerator and denominator each coming from respective datasets. That way the denominator in the ratio (% of Total Sales) could remain constant irrespective of filters on the numerator. So, functionally, what we delivered was : if user filter for France in the global revenue dashboard, Oracle Analytics will compute % of total Revenue as the division of France Revenue by total unfiltered Global Revenue. 

But what if our need had been to show revenue for France in 2019 as a ratio of Global revenue... in 2019 ? In this case, both numerator and denominator should still be filtered for a year in the time dimension, but both should not behave identically on geographies filter... The denominator should not be applied the filter for France in this case. 
With blog 'Part I' implemented, tweaking the model to achieve this new need is actually very simple. This short video walks you through the steps and the blog below describes them :


There is only one step to complete to achieve this, and is pretty simple : add an additional explicit match (join column) between the two datasets A and B. At the end of our previous blog, we had two identical datasets joined by a dummy column (1=1) :

All we need to do now is to add an explicit match on time dimension. That way the year filter will be applied to both datasets and our functional need will be resolved :

Once this is done, the canvas will now show Total Sales B (denominator) filtered by year -see $2.0M below- but not by Product Category. You can see below the amount of Sales for 2015 for just 'Technology' Product Category is only $764.3K :

So this canvas is really showing us the Percent of Sales that 'Technology' product line represented vs the total of Sales, but computing this ratio only for 2015. This is exactly the same use case as ratio of Sales made in France in 2019 as % of total Global Revenue in 2019.

Note that if we add more Matches (join columns) between our two datasets, we can easily extend the scope of what columns will the denominator be filtered on. For example, in the picture below, we are adding Order Priority column :

As a result, the whole canvas will filter by Order Priority as well (including denominator coming from datasource B). In the picture below, both datasets A and B are filtered on Time and Order Priority (see value of Total Sales B = $521.5K), but only dataset A also filters on Product Category ($152.5K). The numerator and denominator are behaving accordingly for the ratio calculation at the bottom.

One important design remark

One important aspect to keep in mind for this design to operate correctly : the definition of joins between mashed-up datasets (A and B here) requires designers to specify the type of the join in each viz on the canvas. So, for each of the elements on the canvas, in the properties tab, you need to make sure that the 'blending' tab is configured with 'All Rows' for both datasets. See the picture below. This detail is important and will prevent the correct behavior to happen if it's not setup.

Thanks for your time reading this series of blog entries !