Skip to content

Commit

Permalink
Script now allows for buffered point inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
sambowers committed Oct 23, 2018
1 parent c664ab5 commit cfe41b3
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions biota/mask.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ def maskShapefile(tile, shp, buffer_size = 0., field = None, value = None, locat
if field != None:

shapes = shapes[getField(shp, field) == value]

# For each shape in shapefile...
for n, shape in enumerate(shapes):

Expand All @@ -298,18 +298,24 @@ def maskShapefile(tile, shp, buffer_size = 0., field = None, value = None, locat
if symax < tile.geo_t[3] + (tile.geo_t[5] * tile.ySize) + buffer_size_degrees: continue
if symin > tile.geo_t[3] - buffer_size_degrees: continue


#Separate polygons with list indices
n_parts = len(shape.parts) #Number of parts
indices = shape.parts #Get indices of shapefile part starts
indices.append(len(shape.points)) #Add index of final vertex

# Catch to allow use of point shapefiles, which don't have parts
if shape.shapeType == 1 or shape.shapeType == 11:
n_parts = 1
points = shape.points

for part in range(n_parts):

start_index = shape.parts[part]
end_index = shape.parts[part+1]
if shape.shapeType != 1 and shape.shapeType != 11:

start_index = shape.parts[part]
end_index = shape.parts[part+1]
points = shape.points[start_index:end_index] #Map coordinates

points = shape.points[start_index:end_index] #Map coordinates
pixels = [] #Pixel coordinantes

# Transform coordinates to pixel values
Expand Down

0 comments on commit cfe41b3

Please sign in to comment.