1 hole vs 2 polygons in a region

164 views
Skip to first unread message

Gamiz Ribelles, Sergi (Regsa)

unread,
Apr 28, 2009, 6:47:19 AM4/28/09
to Mapinfo-list (E-mail)
Hello,
Does anybody know how to distinguish between holes and multipolygon region using ObjectInfo() function or any other.
Thank you

Sergi Gàmiz Ribelles (627481954)
REGS DE CATALUNYA S.A. (www.regsa.es)
Unitat de Promoció de Regadius i Concentració Parcel·lària
c/General Brito, 6, 5è
25007 Lleida
tel. 973222838   fax 973222627
s...@regsa.cat

 

Uffe Kousgaard

unread,
Apr 28, 2009, 6:58:49 AM4/28/09
to mapi...@googlegroups.com
This is how I did it in some old code, newer methods may be available:

poly1 = ExtractNodes(obj,N1,1,objectinfo(obj,OBJ_INFO_NPOLYGONS+N1)-1,true)
poly2 = ExtractNodes(obj,N2,1,objectinfo(obj,OBJ_INFO_NPOLYGONS+N2)-1,true)

if areaoverlap(poly1,poly2)>0 then
  if area(poly1,"sq km")<area(poly2,"sq km") then
    note "N1 is inside N2"
  else
    note "N2 is inside N1"
  end if
end if
 
Regards
Uffe Kousgaard

Spencer Simpson

unread,
Apr 28, 2009, 10:27:40 AM4/28/09
to mapi...@googlegroups.com

If a region object has self-intersections, then "island" and "hole" status is meaningless.   

 

If it does not have self-intersections, then you can save time by extracting a representative point from a polygon (its centroid or one of its nodes) and finding out if the polygon contains the point.

 

In the general case, you have to worry about islands inside holes, and holes inside islands inside holes.  For example, Treasure Island is in Lake Mindemoya, on Manitoulin Island, in Lake Huron, in North America.

 

Because of this, in order to determine if any one of a region's polygons is the outside of an island, or a hole, you have to determine this status for all of them.  Count how many other polygons contain a polygon's representative point.  If it's an even number, you have the outside of an "island".  If it's odd, you have a "hole".

 

This is an NxN operation, but it used to be that if an "island" component of a region object had any "holes", they would immediately follow the outside" polygon of the corresponding "island" in the region object's sequence of polygons.   This allowed you to reduce the number of polygons you had to compare to the polygon in question.

 

Another way to tell was that the nodes of outside polygons of islands went clockwise, and the nodes of holes went counterclockwise.  Or the other way around; I forget.  The old BDYIMP program that imported a MapInfo-for-DOS .MBI file choked if this was not the case.

 

Pretty complicated for such a simple operation, and it's probably stored in the object anyway, so it should have been something you could get out of ObjectInfo().

 


Spencer


Gamiz Ribelles, Sergi (Regsa)

unread,
Apr 28, 2009, 1:43:23 PM4/28/09
to mapi...@googlegroups.com
Thanks Uffe, Thanks Spencer.
Finally, the easiest way I've found is by "Disaggregate" statement or command (although I tried to avoid it): those regions with 2 or more polygons which after disaggregation they remains showing 2 or more polygons, those have at least one hole. All others, only one polygon they were islands of the previous object.
I return to may previous table "combinning objects using ..." an unique ID column into the same table. Then I have to pack it again.
 
I were looking for any function or internal variable that identificates internal boundaries; I think MI calculates areas by closed integration along boundaries using nodes coordinates, adding results when they are external boundaries, substracting it they are internal boundaries. am I wrong?

Sergi Gàmiz Ribelles (627481954)
REGS DE CATALUNYA S.A. (www.regsa.es)
Unitat de Promoció de Regadius i Concentració Parcel·lària
c/General Brito, 6, 5è
25007 Lleida
tel. 973222838   fax 973222627
s...@regsa.cat

-----Mensaje original-----
De: mapi...@googlegroups.com [mailto:mapi...@googlegroups.com]En nombre de Spencer Simpson
Enviado el: martes, 28 de abril de 2009 16:28
Para: mapi...@googlegroups.com
Asunto: [MI-L] Re: 1 hole vs 2 polygons in a region

Reply all
Reply to author
Forward
0 new messages