In Tableau, how to show a dimension as a pattern (not a gradient) in a treemap that already has another dimension on color? - gradient

I have a simple treemap in Tableau that has one dimension already being shown on color. I would like to add a second dimension that shows as the pattern (not a gradient). For example, a pattern of stripes through the treemap box where that dimension is present. Is this possible?
Very much appreciated.

No patterns, but you can have a second dimension shown as shade of the existing color by putting two dimensions on the color shelf. Hold down the shift key when adding the second dimension to the color shelf to avoid replacing the first dimension.

Related

PowerBI - Show lines on a map from one point to another

We got several OLAP Cubes in PowerBI Datasets.
One of the cubes has a dimension "dim_location" which contains columns for latitude and longitude. But each dataset has 2 pairs of values, let's call them start_latitude, start_longitude and end_latitude, end_longitude.
I got a fact table connected to that dim_location and want to show some of the measures on a map.
It works perfectly fine with both the map visual and the ArcGIS visual, if I use either the end or the start coordinates. I can show the values as circles with changing size or changing color dependent on the value of a measure. So far so good.
But what I instead want to accomplish is to show a line on the map for each dataset. Each line shall go from start point to end point, color dependent on measure value.
Is there a way to offer the coordinates in the cube dimension in some string syntax that will create a shape, like a polygon with only 2 points, which would result in a line, which can then be shown on the map?
As stated before everything works fine on the map and the ArcGIS visual with one point (lat/lon) per dataset. Tried to find help online for some polygon syntax but came up empty.

Tableau - Combine measures into a single column based on different dimensions

See picture. I have two columns: FIXED and the Original. Is there a way to combine both into a single column using an IF Formula or maybe a FIXED Formula?
The amount 949 highlighted in green is OK, is based on a calculation, but I also want to keep the amount 21.265 also highlighted in green, which was OK in the original column. I want to have both in a single column.
Picture

Finding CheckerBoard Points in opencv for any random ChessBoard( pattern size not known)

Well, OpenCv comes with its function findCheckerboardCorners() in C++ which goes like
bool findChessboardCorners(InputArray image, Size patternSize,
OutputArray corners,
int flags=CALIB_CB_ADAPTIVE_THRESH+CALIB_CB_NORMALIZE_IMAGE )
After using this function for a while, one thing that i understood was that the pattern size must comply with the image to a very good extent, else the algorithm refuses to detect any Chessboard altogether. I was wondering if there were any random image of a chessboard, this function would fail as it is impractical to enter the precise values of the patternSize. Is there a way, the patternSize for this function could be obtained from the image provided. Any help would be appreciated. Thanks.
Short answer: you cannot.
The OpenCV checkerboard detection code assumes that the pattern is uniform (all squares have the same size) and therefore, in order to uniquely locate its position in the image, the following two conditions must be true:
The pattern is entirely visible.
The pattern has a known numbers of rows and columns.
If either 1 or 2 is violated there is no way to know which corner is, say, the "top left" one.
For a more general case, and in particular if you anticipate that the pattern may be partially occluded, you must use a different algorithm and a non-uniform pattern, upon which corners can be uniquely identified.
There are various way to do that. My favorite pattern is Matsunaga and Kanatani's "2D barcode" one, which uses sequences of square lengths with unique crossratios. See the paper here. In order to match it, once you have sorted the corners into a grid, you can use a simple majority voting algorithm:
Precompute the crossratios of all the pattern's consecutive 4-tuples of corners, in both the horizontal and vertical directions.
Do the above for the detected corners in the grid.
For every possible horizontal shift
Over every row
Accumulate the number of crossratios that agree within a threshold
Select the horizontal shift with the highest number of agreements.
Repeat the above for every possible vertical shift, counting crossratios along the columns.
Repeat the above two steps reversing the order of the crossratios in the vertical and horizontal and vertical direction, separately and jointly, to account for reflections and rotations.
Placing the detected corners in a grid can be achieved in various ways. There is an often-rediscovered algorithm that uses topological proximity. The idea is to first associate each corner to all the squares within a small window of it, thus building a corner->squares table, and then traverse it as a graph to build a global table of the offsets of each corner from one another.
The doc for findChessboardCorners says that
patternSize – Number of inner corners per a chessboard row and
column
So patternSize is not the size of the chessboard inside the image but the number of inner corners. The number of inner corners does not depend from the size of the chessboard inside the image.
For example for the following image https://github.com/Itseez/opencv/blob/3.1.0/samples/data/chessboard.png
patternSize should be cv::Size(7,7).

2D color plot when one of the dimensions has a single value

I am trying to make a 2-D color plot with a script that formerly was dealing with a rectangle of data. However, I now need to use it to work with only a single point on the x axis having data.
What I've got is:
self.fig = plt.figure('Title', (10.,10.))
ax=plt.subplot(111)
im=ax.imshow(color_array,interpolation='none',extent=[100,100,50,150],aspect=0.15)
# setting labels, climate, color bar, saving image, etc..
I'm sure what's causing the issue is the extent = [100,100, I'm just not exactly sure how to write the code differently in order for the plot to show up as something other than a narrow vertical rectangle with nothing inside.
The color array is typically a 2-d array of numbers, but in this limited case, it is essentially a 1-d array. What happens is, there are three 2-d arrays, all the same dimensions, and two of them make up the x and y axes, and the third (the color array) determines the coloring of the field. Right now it they look (simplified) like this:
y-axis: [[90,100,110,120]]
x-axis: [[100,100,100,100]]
color: [[10,11,13,14]]
The answer turned out to be very simple. All that's required is a simple adjustment to the extent. Basically, just make sure the two values on the same axes have a distance of larger than 0 between them.
im=ax.imshow(color_array,interpolation='none',extent[100-1,100+1,50,150],aspect=0.15)
I used a value of 1 to separate the above, but really, any number will work (you can also scale it to the changing dimensions of your plots if you like it to be consistent).
I used an if statement to make sure that this only occurs in situations where the first index of the axis array is equal to the last index.

I have a large list of bounding boxes, how can I calculate duplicates?

I have a list of bounding boxes, I was wondering how I could calculate which ones were redundant / duplicates.
The reason being is I have 2 million of these I send to a API and I want to know which are overlapping others so I can reduce them down so each box only covers a unique area of land, so no two bounding boxes cover the same piece of geo space.
How would I calculate it so that these bounding boxes were each covering their own unique space of geo land ?
I am writing this program in C++ btw.
I think that this task is more complex then you think.
You would have to split existing boxes, untill no overlapping exists, and then remove the boxes totally contained in another.
Instead giving you a solution to that, I recomend to check if you can live with:
1) remove the boxes that are totally contained in another box.
2) leave (partly-)overlapping boxes as they are.
For 2 millions you need a spatial index (QuadTree), to get a list of all boxes nearby one box.
If you have to avoid any overlappings, then you must continue to think what should be the result?
A) A union of overlapping rectangles that therfore is not an rectangle anymore, but a polygon.
or B) The result should be rectangles.
You could check if X% of a box's vertices are inside another box to find if it's overlapped but I suppose this isn't the optimal solution.