예제 #1
0
def compute_subset_gdal(inputs=[], args=[]):
    """
    Runs the subset computation, creating a raster dataset as output.
    """
    raster, clip = inputs[0], inputs[1]
    raster_img = raster.get_data()

    if clip.get_epsg() != raster.get_epsg():
        clip.reproject(raster.get_epsg())

    clip_json = clip.get_data().geometry.unary_union.__geo_interface__

    # Passing "None" as second arg instead of a file path.  This tells gdal_clip
    # not to write the output dataset to a tiff file on disk
    output_dataset = gdal_clip(raster_img, None, clip_json)
    if output_dataset is None:
        return None

    # Copy data to new GDALDataObject
    outputDataObject = GDALDataObject()
    outputDataObject.set_data(output_dataset)
    outputDataObject._datatype = gaia.types.RASTER

    # Instantiate temporary reader to (only) parse metadata
    reader = GaiaGDALReader('internal.tif')
    reader.load_metadata(outputDataObject)

    return outputDataObject
예제 #2
0
def compute_subset_gdal(inputs=[], args=[]):
    """
    Runs the subset computation, creating a raster dataset as output.
    """
    raster, clip = inputs[0], inputs[1]
    raster_img = raster.get_data()

    if clip.get_epsg() != raster.get_epsg():
        clip.reproject(raster.get_epsg())

    clip_json = clip.get_data().geometry.unary_union.__geo_interface__

    # Passing "None" as second arg instead of a file path.  This tells gdal_clip
    # not to write the output dataset to a tiff file on disk
    output_dataset = gdal_clip(raster_img, None, clip_json)
    if output_dataset is None:
        return None

    # Copy data to new GDALDataObject
    outputDataObject = GDALDataObject()
    outputDataObject.set_data(output_dataset)
    outputDataObject._datatype = gaia.types.RASTER

    # Instantiate temporary reader to (only) parse metadata
    reader = GaiaGDALReader('internal.tif')
    reader.load_metadata(outputDataObject)

    return outputDataObject
예제 #3
0
 def compute(self):
     raster, clip = self.inputs[0], self.inputs[1]
     raster_img = raster.read()
     clip_df = clip.read(epsg=raster.get_epsg())
     # Merge all features in vector input
     raster_output = self.output.uri
     self.output.create_output_dir(raster_output)
     clip_json = clip_df.geometry.unary_union.__geo_interface__
     self.output.data = gdal_clip(raster_img, raster_output, clip_json)
예제 #4
0
 def compute(self):
     raster, clip = self.inputs[0], self.inputs[1]
     raster_img = raster.read()
     clip_df = clip.read(epsg=raster.get_epsg())
     # Merge all features in vector input
     raster_output = self.output.uri
     self.output.create_output_dir(raster_output)
     clip_json = clip_df.geometry.unary_union.__geo_interface__
     self.output.data = gdal_clip(raster_img, raster_output, clip_json)
예제 #5
0
def compute_subset_gdal(inputs=[], args=[]):
    """
    Runs the subset computation, creating a raster dataset as output.
    """
    raster, clip = inputs[0], inputs[1]
    raster_img = raster.get_data()

    if clip.get_epsg() != raster.get_epsg():
        clip.reproject(raster.get_epsg())

    clip_json = clip.get_data().geometry.unary_union.__geo_interface__

    # Passing "None" as second arg instead of a file path.  This tells gdal_clip
    # not to write the output dataset to a tiff file on disk
    output_dataset = gdal_clip(raster_img, None, clip_json)

    outputDataObject = GDALDataObject()
    outputDataObject.set_data(output_dataset)

    return outputDataObject