Creating Random Points within a Polygon

936 views
Skip to first unread message

1-Cyze

unread,
Jun 29, 2011, 4:05:06 PM6/29/11
to MapInfo-L
Hi All!

I am trying to create "waypoints" within polygon boundaries. My main
concern is that I have no knowledge of MapBasic programming or
scripting of any sort. I don't even know where to begin to start.

What's a solution to create and disperse random points wthin a polygon
shape? I tried using the 'Disperse Point' tool but did not produce the
solution that I was looking for.

I know at the end that I will need to use MapBasic scripting to get
the best solution. I have begun reading and doing my research at it
but still very confused. If there's a layman's process to this please
help.

Thanks!!

Cyrus

Spencer Simpson

unread,
Jun 29, 2011, 5:02:39 PM6/29/11
to mapi...@googlegroups.com

Perhaps this is for some specific application that someone's already solved?

But lacking that, worry about the algorithm first, and only then worry about
how to do it in MapBasic or any other programming environment.

The first step is to be clear about your terminology. Use of the term
"waypoint" in the context of a 2-dimensional object like a region puzzles
me, because that term is used more appropriately in the context of a
1-dimensional linear path.

________________________________

Spencer

Hi All!

Thanks!!

Cyrus

--
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


Bill Thoen

unread,
Jun 29, 2011, 6:09:31 PM6/29/11
to mapi...@googlegroups.com
On 6/29/2011 3:02 PM, Spencer Simpson wrote:
> -----Original Message-----
> From: 1-Cyze [mailto:half....@hotmail.com]
> Sent: Wednesday, June 29, 2011 4:05 PM
> To: MapInfo-L
> Subject: [MI-L] Creating Random Points within a Polygon
>
> Hi All!
>
> I am trying to create "waypoints" within polygon boundaries. My main
> concern is that I have no knowledge of MapBasic programming or
> scripting of any sort. I don't even know where to begin to start.
>
> What's a solution to create and disperse random points wthin a polygon
> shape? I tried using the 'Disperse Point' tool but did not produce the
> solution that I was looking for.
>
> I know at the end that I will need to use MapBasic scripting to get
> the best solution. I have begun reading and doing my research at it
> but still very confused. If there's a layman's process to this please
> help.
Spencer's right up to a point... Figure out what you want to accomplish
before tackling the implementation, but knowing the language does tend
to protect you from designing a system that can't be built (for example,
if your app depended on callbacks to oop objects, you're holed below the
waterline on the jolly ship MapBasic before you even get the anchor up.
So here's a solution that will work in a logical :

---
To fill a polygon with psuedo random points:

assign var 'bbox" to the minimum bounding rectangle of your polygon.
assign var pg to a polygon

set var max_count to the maximum number of points you want in your polygon
set var count to 0

TOP:
set var x to pick random value between bbox.minx and bbox.maxx
set var y to pick random value between bbox.miny and bbox.maxy
set var p = make a point from x, y
if p is inside polygon
add point to map
increment count

if count <= max then
jump to TOP
---

Peter Horsbøll Møller

unread,
Jun 30, 2011, 12:14:52 PM6/30/11
to mapi...@googlegroups.com
Have a look at the Object2Centroids that I have posted on MapInfoTools:

I will let you create a number of points within one or more polygons - and even spread these randomly

Peter Horsbøll Møller
Pitney Bowes Business Insight - MapInfo


2011/6/30 Bill Thoen <bth...@gisnet.com>
Reply all
Reply to author
Forward
0 new messages