Changeset 2655 for inundation/utilities/polygon.py
- Timestamp:
- Apr 4, 2006, 3:49:42 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/utilities/polygon.py
r2633 r2655 127 127 verbose=verbose) 128 128 129 129 130 if one_point: 130 131 return count != 1 … … 135 136 else: 136 137 return indices[count:][::-1] #return reversed 138 139 140 def in_and_outside_polygon(points, polygon, closed = True, verbose = False): 141 """Determine points inside and outside a polygon 142 143 See separate_points_by_polygon for documentation 144 145 Returns an array of points inside and an array of points outside the polygon 146 """ 147 148 if verbose: print 'Checking input to outside_polygon' 149 try: 150 points = ensure_numeric(points, Float) 151 except NameError, e: 152 raise NameError, e 153 except: 154 msg = 'Points could not be converted to Numeric array' 155 raise msg 156 157 try: 158 polygon = ensure_numeric(polygon, Float) 159 except NameError, e: 160 raise NameError, e 161 except: 162 msg = 'Polygon could not be converted to Numeric array' 163 raise msg 164 165 166 167 if len(points.shape) == 1: 168 one_point = True 169 points = reshape(points, (1,2)) 170 else: 171 one_point = False 172 173 indices, count = separate_points_by_polygon(points, polygon, 174 closed=closed, 175 verbose=verbose) 176 # Returns an array of points inside and an array of points outside 177 # the polygon 178 179 if count == len(indices): 180 # No points are outside 181 return indices[:count],[] 182 else: 183 return indices[:count], indices[count:][::-1] #return reversed 137 184 138 185
Note: See TracChangeset
for help on using the changeset viewer.