I've included a photo of what I'm working on. I'm learning to code using swift playgrounds on the iPad. I'm up to arrays. In the photo I'm to build an island and add a body of water. I'm not sure if you need the entire code to understand my question. (The bottom part of the code just removes some of the land and adds water)
My question is for the part where the greater than and less than operators are being used. I don't understand what coordinate.column > 3 actually means.
If you need more info I can upload another photo with the final product and complete code.
I've added another photo of the final product and it has the remainder code with it as well. I understand that < means less than and > means greater than. But there are no columns that are less than 3 in the final product or a row greater than 8 so what makes the use of the operators work to get the water to surround the island?
Basically, the function goes through each of the tiles of your continent grid and decides if it should be kept as land (added to the island array) or transformed into water) (added to the sea array).
Let's say that your top left tile is of coordinate (0,0) (column 0 and row 0), then it goes as sea, now let's take tile (3,3), it still goes as sea as the comparison is strict (>3 not >=3), tile (5,7) is going in island and tile (8,9) is going in sea.
I guess it's worth mentioning that column and row properties are numbers (of type Int - natural (whole) numbers).
The field is represented by a grid, in your case 11x11. Each block has a two-dimensional coordinate within that grid, represented by aforementioned column and row properties.
Indexes in Swift start from 0, so when you iterate over all blocks, their column and row values can be essentially numbers from 0 to 10.
Now, what you want to do is to select bricks in the middle of the grid. If you want the island to be 4 blocks in size each dimension, you do that by comparing their coordinates. Essentially, "island in the middle of size 4 bricks each dimension" is a collection of bricks located at coordinates 4,4; 4,5; 4,6; 4,7; 5,4; 5,5; ...., 7,7.
That "if" condition that you have is merely a good way of selecting these bricks.
The > and < symbols are boolean operators, so here I am assuming that coordinate.column would return a number, and then it'll be compared for either > or < and then return true if in fact coordinate.column is < or > 8 and 3 respectively.
Related
How can I put the values in the table into the polygon function?
Note : ST_GeomFromText('LINESTRING(75 29,77 29,77 29, 75 29)') --coordinates are representations. What I want is to put the values in the table into the function.
you could use the geometry directly (if they were suitable, which they are not, see below).
SELECT ST_MakePolygon(wkb_geometry) FROM madened50 WHERE ...
BUT, a polygon is made of at least 4 points, with the 1st and last point being the same. In your table, the lines have 2 points only, so how exactly do you want to make a polygon from a line?
Don't forget that you can't just add one of point multiple times (the polygon will be invalid where the vertex is repeated, and a lot of function won't work properly with invalid geometries)
If it was only for the last point, which must be the same as the 1st one, you could add it though
SELECT ST_MakePolygon(ST_AddPoint(wkb_geometry, ST_StartPoint(wkb_geometry)))
FROM madened50 WHERE ...
I have a data where at one latitude and longitude multiple shops are located.
For Example.
Latitude Longitude ShopId Type
6.24458 50.001756 101 Saloon
6.24458 50.001756 102 Groceory
6.24458 50.001756 103 Pharmacy
6.24458 50.001756 104 FishMarket
When on map I am plotting using above latitude & longitude I am getting single mark. And when I hover the mark I am getting single shop details but I want 4 marks and on each mark it should show respective shopid and Type.
I am new to Tableau and not able to figure out how to do it.
You are likely getting 4 marks displayed at the same location. So when you click on the mark you see, then you are only selecting the top mark. You can verify this by dragging over the mark to select all the marks within a selection rectangle. If you then, right click and view data, you should see all 4 marks.
Another thing that can help when you have overlapping marks, is to make the marks partially transparent and add a border around the marks. Both options are available by clicking on the Color button on the marks card to get to the advanced color settings.
If this is not the behavior you want, you have a couple of options. One easy approach is to add a little random noise to each latitude and longitude (called jitter). Adding a little jitter makes the marks visible, although the size of the jittering depends on your data and scale. Jittering is especially useful if all your points are geocoded to the same situation - say if every building with a Los Angeles address is treated as if it is located at city hall. In that case, the geocoding distorts the data to a degree that jittering is just fine.
The undocumented RANDOM() function is an easy way to add some jitter. Excel and Hyper Extracts support RANDOM() among other data source types. It returns a number between 0 and 1.
The other options involve treating your coordinates as continuous dimensions instead of measures, and then using some other visual attribute size, color etc to indicate the number of items at each location. It is often useful to combine nearby items with some sort of grid or hex bin function -- In this case, instead of adding random noise to each coordinate, you round or truncate it in someway to effectively snap points to a grid. The ROUND() and HEXBINX() HEXBINY() functions are useful here. When using this approach, be sure your packed coordinate fields are continuous dimensions and have the appropriate Latitude or Longitude geographic role.
Finally, take a look at the density mark type. It can make visual heat maps, either working with exact data points or grid packed points.
I am learning Tableau using sample dataset Sample Superstore. I am trying to find out, For a given period let us say January 2012, what percentage of sales were shipped using a specific product container (e.g. Jumbo Box)
When containers are in Rows, I get 2.22% and when I flip row to column and vice-versa I get 9.17%. Would appreciate some inputs to clarify this.
2.22%
9.17%
When you use table calculation the values will differ according to the viz and what type of calculation you have used. For example table down will calculate from top to bottom and table across will calculate from left to right. Like this you will see many other options for calculations.
In below example I have used running total with table across that is direction from Left to Right column values (2014,2015,2016,2017,2018).
Example:
Image1 - Original Data(without table calculation)
Data with table calculation - running total(table across)
In below image, Left to Right values are Ship Dates against Segments. Look at the Yellow color highlighted row. Year 2015 for Consumer Segment the sales value is 40,656 but in the original data(Image1) it is 24,635. The reason it is showing 40,656 is because table calculation is performed with running total by table across(left to right), so the original value 24,635 is added with previous Year's(2014) value 16,021. Hence 16021 + 24635 = 40656. It means Left value(16021) is added with the Right value(24635). This pattern will continue till the right most value.
Image2
Columns and rows are switched
In below image(Image3) Left to Right values are Segments against Ship Dates. The Columns and rows are switched. The value of Corporate Segment for the Year 2014 is changed to 25950(blue circle) because the left side value 16021 is added with the original value 9929(Image1).
Image3
I'm not familiar with Local Binary Pattern (LBP), could anyone help me to know how to extract LBP features from facial images (I need a simple code example)?
While searching, I found this code, but I didn't understand it.
So first of all you need to split the face into a certain amount of
sections.
For each of these sections you then have to loop through the all of
the pixels contained within that section and get their value (grey scale or colour values).
For each pixel check the value of the pixels which border it in (diagonals and up down left and right) and save them
for each of the directions check if the colour value of. if the colour is greater than the original pixels value you can assign that value a 1 and if it is less you can assign it as a 0.
you should get a list of 1's and 0's from the previous steps. put these numbers together and it will be a large binary number, you should be able to convert this to decimal and you will have a number assigned for that pixel. save this number per pixel.
after you have got a decimal number for each pixel within a section you can average all of the values to get an average number for this section.
This may not be the best description of how this works so here is a useful picture which might help you.
There is an extractLBPFeatures function in the R2015b release of the Computer Vision System Toolbox for MATLAB.
I am drawing text in a PDF page using iTextSharp, and I have two requirements:
1) the text needs to be searchable by Adobe Reader and such
2) I need character-level control over where the text is drawn.
I can draw the text word-by-word using PdfContentByte.ShowText(), but I don't have control over where each character is drawn.
I can draw the text character-by-character using PdfContentByte.ShowText() but then it isn't searchable.
I'm now trying to create a PdfTextArray, which would seem to satisfy both of my requirements, but I'm having trouble calculating the correct offsets.
So my first question is: do you agree that PdfTextArray is what I need to do, in order to satisfy both of my original requirements?
If so, I have the PdfTextArray working correctly (in that it's outputting text) but I can't figure out how to accurately calculate the positioning offset that needs to get put between each pair of characters (right now I'm just using the fixed value -200 just to prove that the function works).
I believe the positioning offset is the distance from the right edge of the previous character to the left edge of the new character, expressed in "thousandths of a unit of text space". That leaves me two problems:
1) How wide is the previous character (in points), as drawn in the specified font & height? (I know where its left edge is, since I drew it there)
2) How do I convert from points to "units of text space"?
I'm not doing any fancy scaling or rotating, so my transformation matrices should all be identity matrices, which should simplify the calculations ...
Thanks,
Chris