Create a boundary around polygons (ST_ExteriorRing?) - postgis

I have a geometry of polygons, which are boxes that make a grid over an area.
I'd like to query the boundary of the outer most boxes of the grid.
It looked like ST_ExteriorRing might be the solution, but this query mirrors my existing geometry exactly.
SELECT ST_AsGeoJSON(ST_ExteriorRing(geom)) AS bounds
FROM myzones
How would I retrieve a bounding box that outlines the outer most border of my grid?
Note: Even though my geom is made up of boxes, the shape of all of them is not square.

St_Exteriorring is not an aggregate operator, so you'll a get an output record for every input record.
I think you need either st_union or st_collect (st_collect might be quicker, but it might cause the st_exteriorring to fail if it returns a geometrycollection): i.e.
SELECT ST_AsGeoJSON(ST_ExteriorRing(st_union(geom))) AS bounds
FROM myzones

Related

How to map Huggingface trainer output to actual label

I have a dataset where I calculate one-hot encoded labels for the hugging face trainer. However I have to drop some labels before training, but I don't know which ones exactly. So the resulting label space looks something like this:
{[1,0,0,0], [0,0,1,0], [0,0,0,1]}
Note how [0,1,0,0] is not in the list.
Now, when evaluating the model, it returns an array of probabilities.
Assuming I have hundreds of labels and don't know which ones have been dropped, how do I map the trainer's output (e.g. after softmax) to the correct labels?

How do I search for a cell by its text, then display the value of the cell to its right in Google Sheets?

So, I need a formula that searches for a cell in a specific row (or one of multiple rows) by its text, then displays the value of the cell to the right of it. I don't even know how to begin to do this one...
Here's an example of this:
Here is an example of a list of phrases with associated numbers that'll come up later in the sheet.
Here I want a formula that searches for instances of the word in the cell to its left appearing in Column A, and then display the value of the cell to the searched cell's right. Note that I'm only searching for phrases that come up once...
...and this is what I'd want the result to be.
(I'm on mobile, if that affects anything.)
EDIT: Also I've realized, unlike in the image the formula would actually be searching for a phrase TWO cells to its left instead of one, sorry!
try in H26:
=INDEX(IFNA(VLOOKUP(G26:G, A:B, 2, 0)))

How to arrange table data differently by using if, match, and index?

As shown in the attached image, I need to convert A2:D10 to the format of A12:E17. The 4 tables from F1 to AB12 are my experiments using if, match, and index. Same formula gets different results and it seems to be dependent on the row position of the tables. In My previous question, I was trying to pinpoint the problem to the if function.
What am I doing wrong here?
Thanks,
Lu
enter image description here
Again, as I said in your last question: The formula has not been array entered. Array formulas need to be confirmed with Ctrl-Shift-Enter.
Without that, the first array in the IF statement does not get resolved and the Match does not return the correct result.
Make use of the Evaluate Formula tool and step through the formula.
The merged cells don't help with the cell referencing. Unmerge the cells and fill in all the labels in row 1, then use this slightly amended formula and confirm it with Ctrl-Shift-Enter. Then copy across and down.
I hope that I get the English names of the functions right:
In D14 and following cells:
=INDEX($C$1:$C$5;MATCH(1;MMULT(($B$3:$B$10=$A14)*($A$3:$A$10=B$13);1);0))
The MATCH function tells which value (by number counted from the top) matches both conditions. The INDEX function returns this value from C1:C5.

Comparing cell values in Excel

What I am trying to achieve is to see if the value of Cell C4 exists in Column F.
If it exists in Column F, I eventually want Cell A4 to copy the format of the cell in Column F that matches the value of Cell C4.
Still following me?
For reference, my file looks like this:
The values of the cells in Column A are based on Sheet2.
So with a simple formula I managed to compare the values and only change Column A when there is an actual match as seen below.
=IF(C4=F:F, IF(C4<>"","x",Sheet2!A4), Sheet2!A4)
The only problem here is that it only results in a TRUE statement, if Cell C4 matches Cell F4. If it matches, let's say Cell F5, the statement will be FALSE and I need it to be TRUE (since value of C4 is indeed found in Column F.
I tried a variation using $F:$F instead of F:F, but this made no difference. Also setting a range (F2:F5) did not work.
This is where I am stuck.
As soon as I have this figured out, I can continue finding a way of copying the format of the matched cell. Feel free to reveal how I manage to do this if you already know. Will save me some headaches.
Try the following:
=IF(IFERROR(MATCH(C4,F:F,0),0)>0,IF(C4<>"","x",Sheet2!A4), Sheet2!A4)
Edited formula error (; --> ,)
EDIT:
Ok, so forgetting about you formula and trying to do what I think you want, which is:
Be able to copy in the list of resolvers at work into your color code scheme, and then apply that format to all tickets where this person is responsible. There has to be a way of telling, based on color, whether a ticket is assigned to a person that is not on the job (not in the list), or is not assigned to anyone. I assume you have a very limited amount of people at work, because if not, it will be very difficult to distinguish between the colors.
Being quite few people at work at one time, what you could do is to:
Name your the range with people at work "workers"
Name the new range "colors"
For each row with a color coding, enter the name of the color, or some other way of referencing the color. I entered "Yellow" "Red", "Green", "Blue", and I added a black for "x".
Selected the top cell in the tickets column, selected new conditional formatting rule, entered the following formula
=IFERROR(INDEX(colors;MATCH($C1;workers;0));"x")="Yellow"
Selected that this should have yellow fill, and applied to the entire Tickets column.
Did the same for red, green, black, etc.
Doing this, I managed to get the following behaviour:
1. I can change the names in the name column, and conditional formatting will not change
If a ticket is solved by someone in the list, the background color of TicketX is the same as the name in the name list
If a ticket is not solved by anyone, the formula returns "", which is not in any of the conditional formatting rules, so it remains white
If a ticket is solved by someone not at work, formula evaluates to "x", which is tied to color black in conditional formatting, so the cell turns black (could consider adding white text here to be able to see ticket number).
Now this is not that pretty, because you have to create so many rules, but as I say, if you are to distinguish between the colors, there can't be too many of them anyway.
To answer the first question of seeing if C4 exists in column F, you can put the following formula in cell E4.
=IFERROR(INDEX($F$2:$F$5,MATCH(C4,$F$2:$F$5)),"")
It will put the name if it exists and have a blank field if it doesn't. Just drag this formula throughput column E (or whatever column you want).
In order to match formats and don't want to get into VBA (and assuming you don't have a lot of possibilities), you could add conditional formatting to the new column of E. With the "Classic" Style of conditional formatting, make a new rule that sets your custom format when the cell contains the specific text of "Henk". Then continue on making rules for the other possible options. After you create the conditional formatting in, say, cell E4 for example, change the "Applies to" field to apply to Sheet1!$C$2:$C$5.

Format text in flow document table cell

I have a program that creates a table, adds it to a flow document along with table cells that are populated with text. Everything works great with one exception. One column of cells in the table displays costs and they have been formated as follows:
cellValue = "$" + string.Format("{0:##,#.00}", int.Parse(cellValue)).PadLeft(22 -
cellValue.Length);
As it turns out, with this formatting numbers like $ 11,111 take up a different width then numbers like $ 10,000. I would guess because the font is not equal width for each character.
What I would like to do is be able to display the costs just like the are when in an Excel spreadsheet when formatted as Accounting (ie the dollar sign is left hand justified, the numbers are right hand justified and the numbers are lined up from cell to cell).
Example:
$ 10,000.00
$ 11,111.11
If someone knows what formatting to apply to reach this goal please let me know.
This is probably too simple but at a guess I would use fixed font for the cell like "Courier New" so that all the characters are the same width and would align up. The downside of this is that "Courier New" is not the most elegant font to use.
I am sure Excel uses a much more sophisticated mechanism for aligning numeric values.
Maybe you should use something that better mimics a spreadsheet than a table in a flowdocument.

Resources