public class JGrassUtilities extends Object
Modifier and Type | Field and Description |
---|---|
static String |
COLS |
static String |
EAST |
static Interpolation |
interpolation |
static String |
NORTH |
static String |
ROWS |
static String |
SOUTH |
static String |
WEST |
static String |
XRES |
static String |
YRES |
Constructor and Description |
---|
JGrassUtilities() |
Modifier and Type | Method and Description |
---|---|
static GridCoverage2D |
buildCoverage(String name,
double[][] dataMatrix,
double n,
double s,
double w,
double e,
CoordinateReferenceSystem crs,
boolean matrixIsRowCol)
Creates a
coverage from a double[][] matrix and the necessary
geographic Information. |
static BufferedImage |
ByteBufferImage(byte[] data,
int width,
int height)
create a buffered image from a set of color triplets
|
static boolean |
checkRasterMapConsistence(String mapsetPath,
String mapname)
Returns the list of files involved in the raster map issues.
|
static int[] |
coordinateToNearestRowCol(JGrassRegion active,
Coordinate coord)
Return the row and column of the active region matrix for a give coordinate *
NOTE: basically the inverse of
rowColToCenterCoordinates(JGrassRegion, int, int) |
static WritableRaster |
createDoubleWritableRaster(int width,
int height,
Class<?> dataClass,
SampleModel sampleModel,
Double value)
Creates a
writable raster . |
static WritableRaster |
createWritableRasterFromMatrix(double[][] matrix,
boolean matrixIsRowCol)
Create a
WritableRaster from a double matrix. |
static int |
factorial(int n) |
static String[] |
filesOfRasterMap(String mapsetPath,
String mapname)
Returns the list of files involved in the raster map issues.
|
static JGrassRegion |
getJGrassRegionFromGridCoverage(GridCoverage2D gridCoverage2D) |
static JGrassRegion |
getRectangleAroundPoint(JGrassRegion activeRegion,
double x,
double y)
return the rectangle of the cell of the active region, that surrounds the given coordinates
|
static int[] |
getTilesBasedOnFreeMemory(int rows,
int cols)
Calculates optimal tile size for the actual free memory.
|
static boolean |
isGrass(String path)
Checks if the given path is a GRASS raster file.
|
static void |
makeColorRulesPersistent(File colrFile,
List<String> rules,
double[] minMax,
int alpha) |
static void |
printImage(GridCoverage2D coverage2D) |
static void |
printImage(RenderedImage renderedImage) |
static Envelope |
reprojectEnvelopeByEpsg(int srcEpsg,
int destEpsg,
Envelope srcEnvelope) |
static Coordinate |
rowColToCenterCoordinates(JGrassRegion active,
int row,
int col)
Transforms row and column index of the active region into the regarding northing and easting
coordinates.
|
static double[] |
rowColToNodeboundCoordinates(JGrassRegion active,
int row,
int col)
Transforms row and column index of the active region into an array of the coordinates of the
edgaes, i.e. n, s, e, w
|
static RenderedImage |
scaleJAIImage(int requestedCols,
int requestedRows,
RenderedImage translatedImage,
Interpolation interpolation) |
public static final String NORTH
public static final String SOUTH
public static final String WEST
public static final String EAST
public static final String XRES
public static final String YRES
public static final String ROWS
public static final String COLS
public static Interpolation interpolation
public static boolean checkRasterMapConsistence(String mapsetPath, String mapname)
mapsetPath
- - the path of the mapsetmapname
- -the name of the mappublic static BufferedImage ByteBufferImage(byte[] data, int width, int height)
data
- width
- height
- public static Envelope reprojectEnvelopeByEpsg(int srcEpsg, int destEpsg, Envelope srcEnvelope) throws FactoryException, TransformException
FactoryException
TransformException
public static JGrassRegion getRectangleAroundPoint(JGrassRegion activeRegion, double x, double y)
activeRegion
- x
- the given easting coordinatey
- given northing coordinatepublic static Coordinate rowColToCenterCoordinates(JGrassRegion active, int row, int col)
NOTE: basically the inverse of coordinateToNearestRowCol(JGrassRegion, Coordinate)
active
- - the active region (can be null)row
- - row number of the point to transformcol
- - column number of the point to transformpublic static int[] coordinateToNearestRowCol(JGrassRegion active, Coordinate coord)
NOTE: basically the inverse of rowColToCenterCoordinates(JGrassRegion, int, int)
active
- the active regioncoord
- public static String[] filesOfRasterMap(String mapsetPath, String mapname)
mapsetPath
- - the path of the mapsetmapname
- -the name of the mappublic static double[] rowColToNodeboundCoordinates(JGrassRegion active, int row, int col)
active
- - the active region (can be null)row
- - row number of the point to transformcol
- - column number of the point to transformpublic static int factorial(int n)
public static void makeColorRulesPersistent(File colrFile, List<String> rules, double[] minMax, int alpha) throws IOException
IOException
public static int[] getTilesBasedOnFreeMemory(int rows, int cols)
rows
- the rows of the complete image the tiles are calculated for.cols
- the cols of the complete image the tiles are calculated for.public static JGrassRegion getJGrassRegionFromGridCoverage(GridCoverage2D gridCoverage2D) throws InvalidGridGeometryException, TransformException
public static RenderedImage scaleJAIImage(int requestedCols, int requestedRows, RenderedImage translatedImage, Interpolation interpolation)
public static GridCoverage2D buildCoverage(String name, double[][] dataMatrix, double n, double s, double w, double e, CoordinateReferenceSystem crs, boolean matrixIsRowCol)
coverage
from a double[][] matrix and the necessary
geographic Information.name
- the name of the coverage.dataMatrix
- the matrix containing the data.n
- s
- w
- e
- crs
- the CoordinateReferenceSystem
.matrixIsRowCol
- a flag to tell if the matrix has rowCol or colRow order.coverage
.public static WritableRaster createWritableRasterFromMatrix(double[][] matrix, boolean matrixIsRowCol)
WritableRaster
from a double matrix.matrix
- the matrix to take the data from.matrixIsRowCol
- a flag to tell if the matrix has rowCol or colRow order.public static WritableRaster createDoubleWritableRaster(int width, int height, Class<?> dataClass, SampleModel sampleModel, Double value)
writable raster
.width
- width of the raster to create.height
- height of the raster to create.dataClass
- data type for the raster. If null
, defaults to double.sampleModel
- the samplemodel to use. If null
, defaults to
new ComponentSampleModel(dataType, width, height, 1, width, new int[]{0});
.value
- value to which to set the raster to. If null, the default of the raster creation
is used, which is 0.writable raster
.public static boolean isGrass(String path)
Note that there is no check on the existence of the file.
path
- the path to check.public static void printImage(GridCoverage2D coverage2D)
public static void printImage(RenderedImage renderedImage)
Copyright © 1996–2019 Geotools. All rights reserved.