Hi,

On 17.02.2014, at 09:29, Ari Simmons wrote:
> I am new to Shapely (but enthusiastic about it), and recently I've discovered 
> a bit of a road bump. 
> 
> I have a polygon shapefile that I am reading in via Fiona. This shapefile 
> contains BOTH polygon and multipolygon items and I need to build an array for 
> each feature of all the coordinates within it (i.e. both exterior and/or 
> interior). Notably, two of the polygon items have interior rings (and they 
> are valid). 
> 
> I seem to have no problem accessing the exterior coordinates of the 
> polygon(s)/multipolygon(s) ... but I am not pulling anything for the interior 
> coordinates. 

There are errors in your code and the program tells you that, but you aren't 
listening :)

  try:
    make_error()
  except:
    pass

This try/except block swallows all errors. This is bad coding practice and you 
should avoid it.


Two hints:

> 
>                 interior_poly += len(myShape.interior.coords)

interior is a list, because a polygon can contain multiple interiors.


>         elif isinstance(myShape, MultiPolygon):
>             print "yes, I am a MultiPolygon"
>             # count how many points for each interior polygon
>             try:
>                 interior_poly += len(myShape.interior.coords)

and a polygon contains multiple polygons. You can iterate over myShape to get 
the sub-polygons.



Gruß/Regards,
Oliver



_______________________________________________
Community mailing list
Community@lists.gispython.org
http://lists.gispython.org/mailman/listinfo/community

Reply via email to