howto create polgon with hole and island

16 views
Skip to first unread message

ktr...@gmail.com

unread,
May 22, 2014, 12:59:36 PM5/22/14
to geospati...@googlegroups.com



Hello list,

as a bloody newbie I am trying to create a polygon with a hole plus an associated island (see black picture). I use the following code, but it does not work (see magenta picture)

import shapefile
w = shapefile.Writer(shapefile.POLYGON)
w.poly(parts=[[[0,50],[50,50],[50,0],[0,0],[0,50],[10,40],[10,10],[30,10],[30,40],[10,40],[70,20],[100,20],[100,0],[70,0],[70,20]]])
w.field('FIRST_FLD','C','40')
w.field('SECOND_FLD','C','40')
w.record('Poly','PolyTest')
w.save('TESTPOLY')

Any hints?

Thanks
Kurt










Joel Lawhead

unread,
May 22, 2014, 1:22:02 PM5/22/14
to geospati...@googlegroups.com
Hey - I just answered your question on StackExchange. The short answer is each one of your "sub" polygons (main, hole, island) needs it's own list inside the parts list. The code is with my answer (on my phone right now).  
  
I tested the change but let me know if you have issues. 

- Joel 
--
You received this message because you are subscribed to the Google Groups "Geospatial Python" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geospatialpyth...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Joel Lawhead, PMP
E-mail: jlaw...@geospatialpython.com
Web: GeospatialPython.com
Twitter: @SpatialPython

ktr...@gmail.com

unread,
May 22, 2014, 2:24:53 PM5/22/14
to geospati...@googlegroups.com
Hello Joel,

thank you very much for kind support and the detailled explatiion on gis.stackexchange.com I works like a charm now

Kurt


Am Donnerstag, 22. Mai 2014 19:22:02 UTC+2 schrieb Geospatial Python:
Hey - I just answered your question on StackExchange. The short answer is each one of your "sub" polygons (main, hole, island) needs it's own list inside the parts list. The code is with my answer (on my phone right now).  
  
I tested the change but let me know if you have issues. 

- Joel 

On Thursday, May 22, 2014, <ktr...@gmail.com> wrote:



Hello list,

as a bloody newbie I am trying to create a polygon with a hole plus an associated island (see black picture). I use the following code, but it does not work (see magenta picture)

import shapefile
w = shapefile.Writer(shapefile.POLYGON)
w.poly(parts=[[[0,50],[50,50],[50,0],[0,0],[0,50],[10,40],[10,10],[30,10],[30,40],[10,40],[70,20],[100,20],[100,0],[70,0],[70,20]]])
w.field('FIRST_FLD','C','40')
w.field('SECOND_FLD','C','40')
w.record('Poly','PolyTest')
w.save('TESTPOLY')

Any hints?

Thanks
Kurt










--
You received this message because you are subscribed to the Google Groups "Geospatial Python" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geospatialpython+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages