Skip to content

Commit

Permalink
updating clip function in raster class
Browse files Browse the repository at this point in the history
  • Loading branch information
Will committed Jul 1, 2015
1 parent 08277fa commit eadb1b9
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions fauxgeo/raster.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@
from osgeo import osr

import numpy as np
# from affine import Affine
from shapely.geometry import Polygon
import shapely
# import pyproj
import PIL
import pygeoprocessing as pygeo

Expand Down Expand Up @@ -807,21 +805,24 @@ def clip(self, aoi_uri):
pixel_size = self.get_affine().a

try:
pygeo.geoprocessing.vectorize_datasets(
[self.uri],
lambda x: x,
# pygeo.geoprocessing.vectorize_datasets(
# [self.uri],
# lambda x: x,
# dataset_out_uri,
# datatype,
# nodata,
# pixel_size,
# 'intersection',
# aoi_uri=aoi_uri,
# assert_datasets_projected=False, # ?
# process_pool=None,
# vectorize_op=False,
# rasterize_layer_options=['ALL_TOUCHED=TRUE'])
pygeo.geoprocessing.clip_dataset_uri(
self.uri,
aoi_uri,
dataset_out_uri,
datatype,
nodata,
pixel_size,
'intersection',
aoi_uri=aoi_uri,
assert_datasets_projected=False, # ?
process_pool=None,
vectorize_op=False,
rasterize_layer_options=['ALL_TOUCHED=TRUE'])
# pygeo.geoprocessing.clip_dataset_uri(
# self.uri, aoi_uri, dataset_out_uri, assert_projections=False)
assert_projections=False)
return Raster.from_tempfile(dataset_out_uri)
except:
os.remove(dataset_out_uri)
Expand Down Expand Up @@ -954,7 +955,9 @@ def overlay(self, raster):
raise NotImplementedError

def to_vector(self):
raise NotImplementedError
aoi_shapely = self.get_aoi()
proj = self.get_projection()
return Vector.from_shapely(aoi_shapely, proj)

def local_op(self, raster, pixel_op_closure, broadcast=False):
bounding_box_mode = "dataset"
Expand Down

0 comments on commit eadb1b9

Please sign in to comment.