python - How to extract interior polygon coordinates using Shapely? -


I'm new to shouting (but excited about it), and recently I've discovered a street collision . / P>

I have a polygon-sized file that I am reading through Fiona. This size-file contains both polygon and multifunctional objects and I need to create an array for each of the coordinates within it (like both external and / or internal) for each feature. In particular, two polygon objects have internal rings (and they are valid).

I think there is no problem reaching outward coordinates of polygon (valuable) / multiplexing (s) ... but I'm not pulling anything for internal coordinates.

Do I need to take a new perspective (i.e. linearings) here ...? Fiona.open (INFILE) in polys:

  def convert_polygen (infile) ): Print "Yes, I am a polygon" # How many points count each counting for the interior polygon: except for the interior_poli + = lenan (myShape.interior.coords): pass # count each external polygon external poly + = lenan (myShape .exterior.coords) How many points for geomArray = asarray (myShape.exterior) print geomArray print "A MultiPolygon" # Count H, I do "+ Str (interior_poly) print" in polygon "print + str (exterior_poly) elif isinstance (myShape, MultiPolygon)" in the polygon "Number of external points ow the number of internal digits Many points for each inner polygon attempt: interior_poly + Exclude lane (myShape.interior.coords): try pass: pass: try: except how many points count for exterior_poly + = lane (myShape.exterior.coords) except for each external polygon except: GeomArray = asarray (myShape.interior) : Try nearby: Excluding geomArray = asarray (myShape.exterior): Close prince T geomArray print "number of interior points in polygon" + str (interior_poly) print "Number of external points in polygon" internal and outer ring are structured differently. For any polygon, there is always 1 outer ring with zero or more interior rings.  

By looking at the structure of a geometry in this way, external is a linearRing object, and internal zero or more LinearRing > list of objects will be linerring in the object cods , in which you coords [:] . can slice to see a list of coordinates

after a function that dictates the list of external and internal coordinates:

  def extract_poly_coords ( Geom): if geom.type == 'polygon': exterior_coords = geom.exterior .cords [:] interior_coords = [] in geom.interiors for interior: interior_coords + = interior.coords [:] elif geom.type == 'MultiPolygon': exterior_coords = [] for part in geom: EPC = Extract_poly_coords (part) # recursive call exterior_coords + = epc ['exterior_coords'] interior_coords + = EPC ['interior_coords'] and: Increase value ErrorError ('Unhedded geometry ty For example:  
  Extract_poly_coords (myShape)    

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -