Author Topic: Find all cells in a region  (Read 168 times)


  • Guest
Find all cells in a region
« on: January 06, 2020, 08:48:49 AM »
I need to find all cells which are touched by the border of a region.
Then I can use other functions I already have to efficiently "fill" the inside of the region.  i.e. all the cells inside the region that are not touched by the border.  Then I'll loop over all regions in a province / country, and finally perform a union to get all cells touched by or within a country or province.

I was wondering though if this function already existed somewhere?
I've got quite far in the implementation but still rooting out some tricky bugs.
It's surprisingly fiddly.



  • Guest
Re: Find all cells in a region
« Reply #1 on: January 06, 2020, 11:51:17 AM »
Found it.  map.GetCells(region);
It's not very efficient with 200 grid divisions (~400,000 cells).  Also for smaller islands / island groups (like those in northern Scotland: Orkney, Shetland, Outer Hebrides) it misses them entirely.  But it will do for now.  Thank you.
Would you be interested in having code contributed back?  (for free)
I'm happy to share what I've developed so far though it does have some bugs.


  • Administrator
  • Hero Member
  • *****
  • Posts: 5705
    • View Profile
Re: Find all cells in a region
« Reply #2 on: January 06, 2020, 12:09:57 PM »
Sure, please feel free to post the code here or by email to contact at kronnect dot com.