Date: prev next · Thread: first prev next last
2015 Archives by date, by thread · List index


At 11:07 23/02/2015 -0700, Nobody Noname wrote:
I don't understand the COUNTIF() condition which is why I was looking at the Flood Fill function to search within the sanctuary boundary. If I had a list of X & Y coordinates defining the boundary of the sanctuary I suppose I could search from left to right along the X-axis, then drop down one Y-axis increment searching the inner area and looking for inner coordinates that represented birds. I think I may be talking BASIC and you may be talking LibreOffice.

Whether I filter the X & Y coordinates by reading a serial file in some flavor of BASIC or process them in a spreadsheet like LibreOffice Calc is irrelevant to me, its the algorithm to do it that I'm looking for. However I understand this is a LibreOffice forum so I understand if that's where your coming from. So I probably need to look up the COUNTIF() function.

I assumed (for obvious reasons!) that you would be using a spreadsheet, but I think the question of whether you use a program or a spreadsheet to solve this problem is a red herring.

You have a list of bird locations. You are proposing to construct a separate list of cells that are located within your shape. Then it seems that you are going to step through your long list of cells and for each cell run through the entire list of bird locations to see how many birds are in that cell. That is surely a very inefficient way of doing what you ask? You would need something like this only if you needed to know separately how many bird locations were positioned in *each* cell.

But your declared problem is merely counting the single total number of bird locations within your shape. To do this, all you need to do is to create a list of the Y values of the shape boundary for each X coordinate in your grid (or vice versa). Provided that the shape is not re-entrant in at least one direction, you should be able to have just two values for each row (or column). So this list has only twice-N values instead of the N-squared values in yours. Now you step through the *birds* - not the cells - and for each bird you first determine the column (or row) in which it occurs and then simply whether it is within the limits of the shape in that row in order to decide whether to count it. That's far smaller data and far fewer calculations - and no need for the "fill" algorithm you mention.

Brian Barker

--
To unsubscribe e-mail to: users+unsubscribe@global.libreoffice.org
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.