Class FeatureGrid
Surrounds a geometry (called a feature in this context to help distinguish it from other uses of the word geometry) with a grid to allow it to be cut or sampled in to cells as defined by the grid.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doubleGridGeometry2D typically models the grid withAsciiGridsImageMetadata.RasterSpaceType.PixelIsArea, so we must shunt our coordinates by half at various times during gridding -
Constructor Summary
ConstructorsConstructorDescriptionFeatureGrid(org.locationtech.jts.geom.Geometry feature, org.geotools.referencing.CRS.AxisOrder axisOrder, org.geotools.coverage.grid.GridGeometry2D gridGeometry) -
Method Summary
Modifier and TypeMethodDescriptionIterate over the points of the grid formed by intersection of the feature's bounds and the grid.doubleThe number of crs units between grid cells in the vertical direction, e.g.doubleThe number of crs units between grid cells in the horizontal direction, e.g.protected doubleprotected doubleorg.locationtech.jts.geom.EnvelopeThe envelope of the feature in grid space, snapped to the grid, so that is the smallest possible size that surrounds the feature.org.locationtech.jts.geom.GeometryThe geometry that is being surrounded by the gridorg.locationtech.jts.geom.Envelopeorg.geotools.geometry.Position2DThe top left position of the feature within the grid in crs space.org.locationtech.jts.geom.GeometryFactoryintThe number of columns in the grid, i.e.org.geotools.coverage.grid.GridGeometry2DThe geometry of the overall grid, e.g.intThe x position in the original grid where this feature grid startsintThe y position in the original grid where this feature grid startsintThe number of rows in the grid, i.e.org.geotools.api.referencing.operation.MathTransformA maths transformation from grid coordinates to world crs space
-
Field Details
-
HALF_A_PIXEL
public static final double HALF_A_PIXELGridGeometry2D typically models the grid with
AsciiGridsImageMetadata.RasterSpaceType.PixelIsArea, so we must shunt our coordinates by half at various times during gridding- See Also:
-
-
Constructor Details
-
FeatureGrid
public FeatureGrid(org.locationtech.jts.geom.Geometry feature, org.geotools.referencing.CRS.AxisOrder axisOrder, org.geotools.coverage.grid.GridGeometry2D gridGeometry) throws org.geotools.api.geometry.MismatchedDimensionException, org.geotools.api.referencing.operation.TransformException Construct a new
FeatureGridthat applies aGridGeometry2Dto aGeometryobject. No re-projection is done by this class, it is up to the caller to ensure that theCoordinateReferenceSystemof the gridGeometry'sworldmatches theCoordinateReferenceSystemof the feature.- Throws:
org.geotools.api.geometry.MismatchedDimensionExceptionorg.geotools.api.referencing.operation.TransformException
-
-
Method Details
-
getGeometryFactory
public org.locationtech.jts.geom.GeometryFactory getGeometryFactory() -
getFeatureGridEnvelopeInWorldCrs
public org.locationtech.jts.geom.Envelope getFeatureGridEnvelopeInWorldCrs()- Returns:
- an Envelope based on convering the grid's dimensions to the world's - note that this will not add the extra pixel on to width and height that the geometry does - this method is really here for tests and sanity checking
-
cellIterator
Iterate over the points of the grid formed by intersection of the feature's bounds and the grid.
-
getCellWorldX
protected double getCellWorldX()- Returns:
- the cell dimension for the x axis in the World CRS. This will be cellWidth or cellHeight depending on the CRS axis order
-
getCellWorldY
protected double getCellWorldY()- Returns:
- the cell dimension for the y axis in the World CRS. This will be cellWidth or cellHeight depending on the CRS axis order
-
getFeature
public org.locationtech.jts.geom.Geometry getFeature()The geometry that is being surrounded by the grid
-
getGridGeometry
public org.geotools.coverage.grid.GridGeometry2D getGridGeometry()The geometry of the overall grid, e.g. this is the grid that we are applying over the top of our feature.
-
getEnvelope
public org.locationtech.jts.geom.Envelope getEnvelope()The envelope of the feature in grid space, snapped to the grid, so that is the smallest possible size that surrounds the feature.
-
getGridToWorld
public org.geotools.api.referencing.operation.MathTransform getGridToWorld()A maths transformation from grid coordinates to world crs space
-
getGridColumns
public int getGridColumns()The number of columns in the grid, i.e. the width, formed by the intersection of the feature and the grid geometry.
-
getGridRows
public int getGridRows()The number of rows in the grid, i.e. the height, formed by the intersection of the feature and the grid geometry.
-
getGridOffsetY
public int getGridOffsetY()The y position in the original grid where this feature grid starts
-
getGridOffsetX
public int getGridOffsetX()The x position in the original grid where this feature grid starts
-
getCellWidth
public double getCellWidth()The number of crs units between grid cells in the horizontal direction, e.g. you can add
cellWidthtofeatureTopLeftto move across one grid cell column. -
getCellHeight
public double getCellHeight()The number of crs units between grid cells in the vertical direction, e.g. you can add
cellHeighttofeatureTopLeftto move down one grid cell row. -
getFeatureTopLeft
public org.geotools.geometry.Position2D getFeatureTopLeft()The top left position of the feature within the grid in crs space. The is 'snapped' to the grid geometry and is the maximum position it can be while still encompassing the entire feature.
-