Scaling polygons dynamically

Hi,

I know this really isn't directly related to wxPython per se, but since we are using Python with graphics and will eventually want to use wxPython to draw the polygons, I thought you guys might be able to help.

Our office is working with GIS maps using python and we've hit a snag. Due to the way the GIS software behaves, it will take a land parcel that shares a border with another parcel and call them just one parcel, instead of 2. The land parcels are represented by 2-dimensional polygons.

Our solution is to shrink or scale the parcel down by a unit of measurement so that the 2 parcels no longer share a line. Currently we use a Python version of the "inpoly" algorithm listed on this page: http://www.visibone.com/inpoly/. It works great until we hit some of our weird parcels that have 700 vectors.

Since we have to move each vector in four directions and then test each vector with the inpoly algorithm, this means that we do 4 X 700 or 2800 calculations. We also have to loop over the number of vectors, so that means 700 X 2800 which takes too long as this is for a web app.

Does anyone have an alternate algorithm for this kind of thing? Thank you for any help!

Mike Driscoll

···

-----Original Message-----
From: wxPython-users-digest-help@lists.wxwidgets.org [mailto:wxPython-users-digest-help@lists.wxwidgets.org]
Sent: Wednesday, February 21, 2007 11:13 AM
To: wxPython-users@lists.wxwidgets.org
Subject: wxPython-users Digest 21 Feb 2007 17:13:27 -0000 Issue 1887

wxPython-users Digest 21 Feb 2007 17:13:27 -0000 Issue 1887

Topics (messages 61636 through 61665):

Re: wx.TAB_TRAVERSAL Problem
  61636 by: Mike Driscoll
  61647 by: Robin Dunn
  61649 by: Chris Mellon
  61651 by: XAVJLM.web.de
  61654 by: XAVJLM.web.de

Re: Event when a TextCtrl has focus?
  61637 by: massimo s.

Re: TreeMixin v0.6
  61638 by: Robin Dunn

Re: SUSE 10.2 and wxPython 2.8 download
  61639 by: Robin Dunn
  61640 by: Robin Dunn

Re: Question....
  61641 by: Robin Dunn

Re: wxpython libraries size increase
  61642 by: Robin Dunn

Re: Help with LabelBook Control - Setting tabswidth
  61643 by: roee shlomo
  61664 by: Geoff Skerrett

Re: wx.ListCtrl.OnGetItemColumnImage
  61644 by: Robin Dunn
  61652 by: Stephen Hansen
  61655 by: Robin Dunn
  61657 by: Stephen Hansen

Re: Menubar Size
  61645 by: Robin Dunn

Re: howto: OK button in child window
  61646 by: Robin Dunn

Re: DnD Problem between TreeCtrl and Panel
  61648 by: Robin Dunn

No module named inspect
  61650 by: Thomas Thomas
  61653 by: Chris Mellon
  61656 by: Robin Dunn

Re: how to talk to picoscope hardware
  61658 by: Brennan Aitken-Gantz

2.8.1.1 Documentation on Intel Mac
  61659 by: Nigel King

Overlapping a Static Box with a wxGrid control
  61660 by: jupan ghe
  61665 by: Phil Mayes

more bugs in the GCDC code
  61661 by: Peter Damoc
  61662 by: Peter Damoc

Free New Chat Room and Online Friends
  61663 by: The Birdy Baba

Administrivia:

To subscribe to the digest, e-mail:
  <wxPython-users-digest-subscribe@lists.wxwidgets.org>

To unsubscribe from the digest, e-mail:
  <wxPython-users-digest-unsubscribe@lists.wxwidgets.org>

To post to the list, e-mail:
  <wxPython-users@lists.wxwidgets.org>

----------------------------------------------------------------------

Mike Driscoll wrote:

I know this really isn't directly related to wxPython per se, but
since we are using Python with graphics and will eventually want to
use wxPython to draw the polygons

Check out wx.lib.floatcanvas, or, better yet, the latest version from:

http://www.mithis.com/~chrisb/

I'm going to be doing more with it, in articular more mapping/GIS-y stuff, so we may be able to collaborate.

Due to the way the GIS software behaves, it will take a land
parcel that shares a border with another parcel and call them just
one parcel, instead of 2. The land parcels are represented by
2-dimensional polygons.

You really can't get the GIS to do the right thing with this?

Our solution is to shrink or scale the parcel down by a unit of
measurement so that the 2 parcels no longer share a line. Currently
we use a Python version of the "inpoly" algorithm listed on this
page:

You'll need to give us a bit more detail about how you use a point-in-polygon routine to do this scaling down.

Since we have to move each vector in four directions and then test
each vector with the inpoly algorithm, this means that we do 4 X 700
or 2800 calculations. We also have to loop over the number of
vectors, so that means 700 X 2800 which takes too long as this is for
a web app.

Have you tried using numpy for your inpoly routine -- it might be better to be more elegant, but maybe be faster.

Does anyone have an alternate algorithm for this kind of thing?

I've got some ideas, but I'll need a bit more detail. How are your polygons defined? Are the vertices in order? Do you know if they are clockwise or counter clockwise? are they convex?

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov