[wxPython-users] Scaling polygons dynamically

Christopher Barker Chris.Barker at noaa.gov
Wed Feb 21 13:39:59 PST 2007


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 at noaa.gov




More information about the wxpython-users mailing list