Question About Polygons Contains Gaps

64 views
Skip to first unread message

Mustafa Deniz Ayar

unread,
Jun 9, 2022, 2:14:22 PM6/9/22
to MapInfo-L
Hello everyone,
How can I print the gap areas and gap perimeters of polygons containing gaps in a table using mapbasic as shown in the picture?Ekran görüntüsü 2022-06-09 200213.png

Peter Horsbøll Møller

unread,
Jun 10, 2022, 3:22:19 AM6/10/22
to mapi...@googlegroups.com

Hi Mustafa

 

You can extract the segment using ExtractNodes

ExtractNodes( object, polygon_index, begin_node, end_node, b_region )

 

You need to determine the number of segments and then you can extract each using an expression like this:

 

Dim nNumSegm, nNumNodes, nSegm As Integer

Dim oPoly, oSegm As Object

 

Fetch First From Selection

oPoly = Selection.OBJ

 

nNumSegm = ObjectInfo(oPoly, OBJ_INFO_NPOLYGONS)

For nSegm = 1 To nNumSegm

   nNumNodes = ObjectInfo(oPoly, OBJ_INFO_NPOLYGONS+nSegm)

   oSegm = ExtractNodes(oPoly, nSegm, 1, nNumNodes, 1)

   Print "Area, sq m: " & FormatNumber$(Round(Area(oSegm, "sq m"), 0.01))

   Print "Perimeter, m: " & FormatNumber$(Round(Perimeter(oSegm, "m"), 0.01))

Next

 

You need to create a MapBasic application for this, or run it through the Python console.

 

You can investigate an individual segments through the MapBasic window or the SQL Window but modifying the script:

Dim nNumSegm As Integer

Dim nNumNodes As Integer

Dim nSegm As Integer

Dim oPoly As Object

Dim oSegm As Object

 

Fetch First From Selection

oPoly = Selection.OBJ

 

nNumSegm = ObjectInfo(oPoly, OBJ_INFO_NPOLYGONS)

Print "Number of segments: " & nNumSegm

nSegm = nNumSegm

nNumNodes = ObjectInfo(oPoly, OBJ_INFO_NPOLYGONS+nSegm)

oSegm = ExtractNodes(oPoly, nSegm, 1, nNumNodes, 1)

Print "Area, sq m: " & FormatNumber$(Round(Area(oSegm, "sq m"), 0.01))

Print "Perimeter, m: " & FormatNumber$(Round(Perimeter(oSegm, "m"), 0.01))

 

Both scripts above work on the current Selection so you need to select the polygon you want to inspect.

 

I hope this helps

 

Peter Horsbøll Møller

www.precisely.com

 

Peter Horsbøll Møller
Principal Sales Engineer - Distinguished Engineer

 

From: mapi...@googlegroups.com <mapi...@googlegroups.com> On Behalf Of Mustafa Deniz Ayar
Sent: 9. juni 2022 19:12
To: MapInfo-L <mapi...@googlegroups.com>
Subject: [MI-L] Question About Polygons Contains Gaps

 

This message originated Externally. Use proper judgement and caution with attachments, links, or responses.

 

Hello everyone,
How can I print the gap areas and gap perimeters of polygons containing gaps in a table using mapbasic as shown in the picture?

--
--
You received this message because you are subscribed to the
Google Groups "MapInfo-L" group.To post a message to this group, send
email to mapi...@googlegroups.com
To unsubscribe from this group, go to:
http://groups.google.com/group/mapinfo-l/subscribe?hl=en
For more options, information and links to MapInfo resources (searching
archives, feature requests, to visit our Wiki, visit the Welcome page at
http://groups.google.com/group/mapinfo-l?hl=en

---
You received this message because you are subscribed to the Google Groups "MapInfo-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mapinfo-l+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mapinfo-l/3337a8ed-9365-42dd-92f6-72120241c7c7n%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages