This method takes a list of rasters and returns a raster that is constructed of all of them
354407
def join(rasters):
    

    raster = rasters[0]  # using the first raster to understand what is the type of data we have
    mask_band = None
    nodata = None
    with raster._raster_opener(raster.source_file) as r:
        nodata = r.nodata
        mask_flags = r.mask_flag_enums
    per_dataset_mask = all([rasterio.enums.MaskFlags.per_dataset in flags for flags in mask_flags])
    if per_dataset_mask and nodata is None:
        mask_band = 0
    return GeoRaster2.from_rasters(rasters, relative_to_vrt=False, nodata=nodata, mask_band=mask_band)
118457
public int[] getUnsignedPixelValues(WritableRaster raster) {
		short[] pixelValues = getPixelValues(raster);
		int[] unsignedPixelValues = getUnsignedPixelValues(pixelValues);
		return unsignedPixelValues;
	}
496616
def main():
    
    input_tif = "../tests/data/Jamaica_dem.tif"
    output_tif = "../tests/data/tmp_results/log_dem.tif"
    rst = RasterUtilClass.read_raster(input_tif)
    # raster data (with noDataValue as numpy.nan) as numpy array
    rst_valid = rst.validValues
    output_data = np.log(rst_valid)
    # write output raster
    RasterUtilClass.write_gtiff_file(output_tif, rst.nRows, rst.nCols, output_data, rst.geotrans,
                                     rst.srs, rst.noDataValue, rst.dataType)
480982
def raster_to_shape(raster):
    """"""
    left = raster.bounds.left
    right = raster.bounds.right
    top = raster.bounds.top
    bottom = raster.bounds.bottom

    top_left = (left, top)
    top_right = (right, top)
    bottom_left = (left, bottom)
    bottom_right = (right, bottom)

    return Polygon((
        top_left, top_right, bottom_right, bottom_left, top_left,
    ))
1233942
def _get_files_recursively(rootdir):
    
    output = []
    for root, dirs, files in os.walk(rootdir):
        for filename in files:
            output.append(os.path.join(root, filename))

    return output
900841
def raster_to_asc(raster_f, asc_f):
        
        raster_r = RasterUtilClass.read_raster(raster_f)
        RasterUtilClass.write_asc_file(asc_f, raster_r.data, raster_r.nCols, raster_r.nRows,
                                       raster_r.geotrans, raster_r.noDataValue)
555220
private List<SpriteTiled> getRasters(Integer sheet)
    {
        return rasterSheets.computeIfAbsent(sheet, s ->
        {
            final List<SpriteTiled> rasters = new ArrayList<>(RasterImage.MAX_RASTERS);
            rasterSheets.put(s, rasters);
            return rasters;
        });
    }
413669
def _parse_raster_info(self, prop=RASTER_INFO):
        

        raster_info = {}.fromkeys(_iso_definitions[prop], u'')

        # Ensure conversion of lists to newlines is in place
        raster_info['dimensions'] = get_default_for_complex_sub(
            prop=prop,
            subprop='dimensions',
            value=parse_property(self._xml_tree, None, self._data_map, '_ri_num_dims'),
            xpath=self._data_map['_ri_num_dims']
        )

        xpath_root = self._get_xroot_for(prop)
        xpath_map = self._data_structures[prop]

        for dimension in parse_complex_list(self._xml_tree, xpath_root, xpath_map, RASTER_DIMS):
            dimension_type = dimension['type'].lower()

            if dimension_type == 'vertical':
                raster_info['vertical_count'] = dimension['size']

            elif dimension_type == 'column':
                raster_info['column_count'] = dimension['size']
                raster_info['x_resolution'] = u' '.join(dimension[k] for k in ['value', 'units']).strip()

            elif dimension_type == 'row':
                raster_info['row_count'] = dimension['size']
                raster_info['y_resolution'] = u' '.join(dimension[k] for k in ['value', 'units']).strip()

        return raster_info if any(raster_info[k] for k in raster_info) else {}
44351
public static List<double[]> histogramGray( List<File> images ) {
		List<double[]> points = new ArrayList<>();

		GrayU8 gray = new GrayU8(1,1);
		for( File f : images ) {
			BufferedImage buffered = UtilImageIO.loadImage(f.getPath());
			if( buffered == null ) throw new RuntimeException("Can't load image!");

			gray.reshape(buffered.getWidth(), buffered.getHeight());
			ConvertBufferedImage.convertFrom(buffered, gray, true);

			TupleDesc_F64 imageHist = new TupleDesc_F64(150);
			HistogramFeatureOps.histogram(gray, 255, imageHist);

			UtilFeature.normalizeL2(imageHist); // normalize so that image size doesn't matter

			points.add(imageHist.value);
		}

		return points;
	}
762924
def get_map_matrix(inputfile):
    
    matrix = read_input_file(inputfile)
    output = []
    for row in matrix:
        if row[3]:
            output.append([row[3], row[1], row[2]])
    return output
901408
public static <E> List<E> asFlatList(Iterable<E>... iterables) {
		List<E> list = new ArrayList<E>();
		for(Iterable<E> iterable: iterables) {
			for(E e: iterable) {
				list.add(e);
			}
		}
		return list;
	}
297642
def raster_field(self):
        """"""
        for field in self.model._meta.fields:
            if isinstance(field, models.FileField):
                return field
        return False
1327253
def getAsGrassAsciiRaster(self, tableName, rasterId=1, rasterIdFieldName='id', rasterFieldName='raster', newSRID=None):
        
        # Get raster in ArcInfo Grid format
        arcInfoGrid = self.getAsGdalRaster(rasterFieldName, tableName, rasterIdFieldName, rasterId, 'AAIGrid', newSRID).splitlines()

        ## Convert arcInfoGrid to GRASS ASCII format ##
        # Get values from header which look something this:
        # ncols        67
        # nrows        55
        # xllcorner    425802.32143212341
        # yllcorner    44091450.41551345213
        # cellsize     90.0000000
        # ...
        nCols = int(arcInfoGrid[0].split()[1])
        nRows = int(arcInfoGrid[1].split()[1])
        xLLCorner = float(arcInfoGrid[2].split()[1])
        yLLCorner = float(arcInfoGrid[3].split()[1])
        cellSize = float(arcInfoGrid[4].split()[1])

        # Remove old headers
        for i in range(0, 5):
            arcInfoGrid.pop(0)

        # Check for NODATA_value row and remove if it is there
        if 'NODATA_value' in arcInfoGrid[0]:
            arcInfoGrid.pop(0)

        ## Calculate values for GRASS ASCII headers ##
        # These should look like this:
        # north: 4501028.972140
        # south: 4494548.972140
        # east: 460348.288604
        # west: 454318.288604
        # rows: 72
        # cols: 67
        # ...

        # xLLCorner and yLLCorner represent the coordinates for the Lower Left corner of the raster
        north = yLLCorner + (cellSize * nRows)
        south = yLLCorner
        east = xLLCorner + (cellSize * nCols)
        west = xLLCorner

        # Create header Lines (the first shall be last and the last shall be first)
        grassHeader = ['cols: %s' % nCols,
                       'rows: %s' % nRows,
                       'west: %s' % west,
                       'east: %s' % east,
                       'south: %s' % south,
                       'north: %s' % north]

        # Insert grass headers into the grid
        for header in grassHeader:
            arcInfoGrid.insert(0, header)

        # Create string
        arcInfoGridString = '\n'.join(arcInfoGrid)
        return arcInfoGridString
1103517
def generate_gradient(self, color_list, size=101):
        
        list_length = len(color_list)
        gradient_step = size / (list_length - 1)

        gradient_data = []
        for x in range(list_length):
            gradient_data.append((int(gradient_step * x), color_list[x]))

        data = []
        for i in range(len(gradient_data) - 1):
            start, color1 = gradient_data[i]
            end, color2 = gradient_data[i + 1]

            color1 = self.hex_2_hsv(color1)
            color2 = self.hex_2_hsv(color2)

            steps = end - start
            for j in range(steps):
                data.append(
                    self.hsv_2_hex(*self.make_mid_color(color1, color2, j / (steps)))
                )
        data.append(self.hsv_2_hex(*color2))
        return data
315199
def clean(self):
        
        data = super(RasterQueryForm, self).clean()
        geom = data.pop('upload', None) or data.pop('bbox', None)
        if geom:
            data['g'] = geom
        return data
1069996
def _read_bands(self):
        
        bands = []

        try:
            for i, band in enumerate(self.bands):
                bands.append(rasterio.open(self.bands_path[i]).read_band(1))
        except IOError as e:
            exit(e.message, 1)

        return bands
430165
public short[] getPixelValues(WritableRaster raster) {
		DataBufferUShort buffer = (DataBufferUShort) raster.getDataBuffer();
		short[] pixelValues = buffer.getData();
		return pixelValues;
	}