Getting the bounding/"border" of a polygon after having called Union

37 views
Skip to first unread message

hir0pr0...@googlemail.com

unread,
Mar 21, 2017, 2:14:44 PM3/21/17
to NetTopologySuite
Hi all,

I am struggling to find the data member which contains the outer boundary of a polygon.
I have done this, and it does work (the resulting area has 163 points and I have confirmed the area looks ok):



            WKTReader wkt = new WKTReader();
           
GeometryFactory geoFac = new GeometryFactory();
           
List<GeoAPI.Geometries.IGeometry> geometries = new List<GeoAPI.Geometries.IGeometry>();

           
try
           
{
               
GeoAPI.Geometries.IGeometry polygon1 = wkt.Read("POLYGON ((125.69921875 7.13018989562983,125.698623657227 7.12970018386841,125.697982788086 7.12817001342773,125.697486877441 7.12660980224615,125.696617126465 7.12379980087286,125.694747924805 7.12446022033686,125.693237304688 7.12523984909063,125.692199707031 7.12578010559093,125.690773010254 7.12459993362438,125.69019317627 7.12322998046886,125.689109802246 7.12146997451794,125.688270568848 7.1207799911499,125.685516357422 7.12201023101807,125.68433380127 7.12291002273565,125.683120727539 7.12367010116589,125.681930541992 7.12457704544079,125.68000793457 7.12604999542248,125.680328369141 7.12620019912725,125.680671691895 7.12652015686047,125.680992126465 7.1269202232362,125.681350708008 7.1273398399353,125.681686401367 7.1277899742127,125.682052612305 7.12815999984753,125.682357788086 7.12848997116095,125.682563781738 7.12882995605469,125.682777404785 7.12911987304693,125.682998657227 7.12941980361944,125.683143615723 7.12978982925426,125.683349609375 7.13011980056763,125.683601379395 7.13044023513788,125.683837890625 7.13079977035534,125.684013366699 7.13122987747198,125.684188842774 7.13166999816906,125.684448242188 7.13209009170538,125.684707641602 7.1325302124024,125.68489074707 7.13299989700329,125.684913635254 7.13352012634272,125.685028076172 7.1339101791383,125.685211181641 7.13422012329113,125.685386657715 7.13456010818487,125.685432434082 7.13464021682745,125.686943054199 7.13493013381958,125.688201904297 7.13542985916138,125.689086914062 7.13626003265381,125.689872741699 7.13507986068726,125.692016601563 7.13322019577026,125.693809509277 7.13191986083984,125.698532104492 7.13047981262213,125.69921875 7.13018989562983))");
               
GeoAPI.Geometries.IGeometry polygon2 = wkt.Read("POLYGON ((125.693511962891 7.12045001983648,125.692337036133 7.11979007720953,125.689163208008 7.11634016036987,125.688003540039 7.11532020568848,125.686988830566 7.11425018310558,125.688636779785 7.11273002624506,125.687522888184 7.11180019378656,125.686492919922 7.11136007308971,125.685287475586 7.1109499931336,125.685020446777 7.11012983322149,125.684623718262 7.10966014862061,125.68286895752 7.10764980316162,125.682456970215 7.10798978805553,125.680847167969 7.10918998718267,125.679679870605 7.11019992828369,125.678840637207 7.1095600128175,125.678283691406 7.10856008529663,125.67716217041 7.10866022109991,125.675636291504 7.10929012298595,125.674667358399 7.10994005203253,125.673233032227 7.11064004898077,125.670837402344 7.11228990554821,125.669616699219 7.11313009262085,125.668296813965 7.11439990997326,125.668579101563 7.11467981338501,125.668853759766 7.11490011215216,125.669036865234 7.11515998840332,125.669212341309 7.11544990539562,125.669441223145 7.11568021774292,125.669647216797 7.11593008041393,125.669776916504 7.11625003814697,125.669982910156 7.11652994155884,125.670181274414 7.11685991287243,125.670387268066 7.11724996566784,125.670608520508 7.11769008636486,125.670883178711 7.11809015274042,125.671203613281 7.11845016479492,125.671417236328 7.11890983581549,125.671669006348 7.11933994293213,125.671943664551 7.11978006362921,125.672203063965 7.12024021148676,125.672523498535 7.12066984176641,125.672882080078 7.12108993530273,125.673316955567 7.12149000167847,125.673767089844 7.12195014953625,125.674247741699 7.12239980697643,125.674789428711 7.12275981903088,125.675300598145 7.12306022644043,125.675720214844 7.12334012985235,125.67603302002 7.12362003326427,125.676246643066 7.12389993667597,125.67643737793 7.12416982650751,125.676803588867 7.12434005737305,125.677268981934 7.12445020675671,125.677757263184 7.12459993362438,125.678237915039 7.12482976913446,125.678657531738 7.12517023086548,125.679077148438 7.1254701614381,125.679481506348 7.12576007843023,125.679901123047 7.12599992752087,125.68000793457 7.12604999542248,125.681930541992 7.12457704544079,125.683120727539 7.12367010116589,125.68433380127 7.12291002273565,125.685516357422 7.12201023101807,125.688270568848 7.1207799911499,125.689109802246 7.12146997451794,125.69019317627 7.12322998046886,125.690773010254 7.12459993362438,125.692199707031 7.12578010559093,125.693237304688 7.12523984909063,125.694747924805 7.12446022033686,125.696617126465 7.12379980087286,125.696640014648 7.12342977523804,125.696662902832 7.1230897903443,125.695747375488 7.12233018875128,125.693511962891 7.12045001983648))");
               
GeoAPI.Geometries.IGeometry polygon3 = wkt.Read("POLYGON ((125.708892822266 7.10717010498053,125.706588745117 7.10666990280146,125.700729370117 7.1052498817445,125.695823669434 7.10410022735607,125.693740844727 7.10365009307867,125.687210083008 7.10184001922607,125.686767578125 7.10275983810419,125.686660766602 7.10416984558105,125.686073303223 7.10526990890503,125.685417175293 7.10615015029913,125.684303283691 7.10657978057873,125.68286895752 7.10764980316162,125.684623718262 7.10966014862061,125.685020446777 7.11012983322149,125.685287475586 7.1109499931336,125.686492919922 7.11136007308971,125.687522888184 7.11180019378656,125.688636779785 7.11273002624506,125.686988830566 7.11425018310558,125.688003540039 7.11532020568848,125.689163208008 7.11634016036987,125.692337036133 7.11979007720953,125.693511962891 7.12045001983648,125.69654083252 7.11746978759771,125.699287414551 7.11627006530767,125.701309204102 7.11505985260021,125.703506469727 7.11367988586431,125.705627441406 7.11223983764654,125.707611083985 7.11237001419079,125.708526611328 7.11219978332531,125.708801269531 7.1091098785401,125.708892822266 7.10717010498053))");
               
GeoAPI.Geometries.IGeometry polygon4 = wkt.Read("POLYGON ((125.696060180664 7.07643985748291,125.696273803711 7.07651996612549,125.696487426758 7.08052015304571,125.696037292481 7.08544015884399,125.695671081543 7.09052991867077,125.695442199707 7.09287977218628,125.694541931152 7.09764003753673,125.694343566895 7.0998301506043,125.694389343262 7.10146999359142,125.695823669434 7.10410022735607,125.700729370117 7.1052498817445,125.706588745117 7.10666990280146,125.708892822266 7.10717010498053,125.712478637695 7.10768985748291,125.718719482422 7.10899019241333,125.729621887207 7.11178016662603,125.729888916016 7.10822010040289,125.729667663574 7.10617017745983,125.729461669922 7.10284996032715,125.727531433105 7.10193014144903,125.726303100586 7.10124015808117,125.722030639648 7.09951019287115,125.720962524414 7.09907007217407,125.718650817871 7.09886980056768,125.717132568359 7.09822988510126,125.715408325195 7.09654998779308,125.714622497559 7.09567022323608,125.713912963867 7.09396982192993,125.712432861328 7.09241008758556,125.710411071777 7.09022998809814,125.710601806641 7.08812999725347,125.710472106934 7.0858798027038,125.709419250488 7.08388996124279,125.709159851074 7.08320999145513,125.708106994629 7.08084011077887,125.706993103027 7.07906007766724,125.705200195313 7.07472991943365,125.705078125 7.07479000091564,125.704948425293 7.07496023178095,125.704689025879 7.07518005371105,125.704376220703 7.07534980773931,125.704048156738 7.0755500793457,125.703689575195 7.07573986053472,125.70329284668 7.07585000991821,125.70288848877 7.07599020004278,125.702453613281 7.07610988616955,125.701972961426 7.07622003555304,125.701461791992 7.07639980316168,125.700927734375 7.07663011550915,125.700340270996 7.07675981521612,125.699798583984 7.07688999176037,125.69930267334 7.07679986953741,125.698852539063 7.07666015625006,125.698471069336 7.07653999328625,125.698127746582 7.076409816742,125.697776794434 7.07635021209722,125.69743347168 7.07621002197266,125.697036743164 7.07616996765137,125.696586608887 7.0763401985169,125.696060180664 7.07643985748291))");
                geometries
.Add(polygon1);
                geometries
.Add(polygon2);
                geometries
.Add(polygon3);
                geometries
.Add(polygon4);
           
}
           
catch (ParseException e)
           
{
               
Console.WriteLine(e.InnerException);
           
}
           
GeometryCollection geometryCollection = (GeometryCollection)geoFac.BuildGeometry(geometries);


           
return geometryCollection.Union();

However, the resulting polygon with 163 points is nowhere to be found (or, should I say, I can't find it which isn't necessarily the same...) 
Where is it contained ? Or do I need to call a method after the Union() to get the polygon ? It was my expectation that I would get that from Union()...

Thanks for a clarification !

Regards,
Hiro

FObermaier

unread,
Mar 22, 2017, 6:30:26 AM3/22/17
to NetTopologySuite
The property you are looking for is named "Boundary".
Reply all
Reply to author
Forward
0 new messages