Class GeoUtils

java.lang.Object
org.esa.snap.core.util.GeoUtils

public class GeoUtils extends Object
  • Constructor Details

    • GeoUtils

      public GeoUtils()
  • Method Details

    • createGeoBoundary

      public static GeoPos[] createGeoBoundary(Product product, int step)
      Creates the geographical boundary of the given product and returns it as a list of geographical coordinates.
      Parameters:
      product - the input product, must not be null
      step - the step given in pixels
      Returns:
      an array of geographical coordinates
      Throws:
      IllegalArgumentException - if product is null or if the product's GeoCoding is null
    • createGeoBoundary

      public static GeoPos[] createGeoBoundary(Product product, Rectangle region, int step, boolean usePixelCenter)
      Creates the geographical boundary of the given region within the given product and returns it as a list of geographical coordinates.
      Parameters:
      product - the input product, must not be null
      region - the region rectangle in product pixel coordinates, can be null for entire product
      step - the step given in pixels
      usePixelCenter - true if the pixel center should be used to create the boundary
      Returns:
      an array of geographical coordinates
      Throws:
      IllegalArgumentException - if product is null or if the product's GeoCoding is null
    • createGeoBoundary

      public static GeoPos[] createGeoBoundary(RasterDataNode raster, Rectangle region, int step)
      Creates the geographical boundary of the given region within the given raster and returns it as a list of geographical coordinates.
      Parameters:
      raster - the input raster, must not be null
      region - the region rectangle in raster pixel coordinates, can be null for entire raster
      step - the step given in pixels
      Returns:
      an array of geographical coordinates
      Throws:
      IllegalArgumentException - if raster is null or if the raster has no GeoCoding is null
      See Also:
    • createGeoBoundary

      public static GeoPos[] createGeoBoundary(RasterDataNode rasterDataNode, Rectangle region, int step, boolean usePixelCenter)
      Creates the geographical boundary of the given region within the given RasterDataNode and returns it as a list of geographical coordinates.
      Parameters:
      rasterDataNode - the input rasterDataNode, must not be null
      region - the region rectangle in product pixel coordinates, can be null for entire product
      step - the step given in pixels
      usePixelCenter - true if the pixel center should be used to create the boundary
      Returns:
      an array of geographical coordinates
      Throws:
      IllegalArgumentException - if product is null or if the product's GeoCoding is null
    • createGeoBoundaryPaths

      public static GeneralPath[] createGeoBoundaryPaths(Product product)
      Converts the geographic boundary entire product into one, two or three shape objects. If the product does not intersect the 180 degree meridian, a single general path is returned. Otherwise two or three shapes are created and returned in the order from west to east.

      The geographic boundary of the given product are returned as shapes comprising (longitude,latitude) pairs.

      Parameters:
      product - the input product
      Returns:
      an array of shape objects
      Throws:
      IllegalArgumentException - if product is null or if the product's GeoCoding is null
      See Also:
    • createGeoBoundaryPaths

      public static GeneralPath[] createGeoBoundaryPaths(RasterDataNode rasterDataNode)
      Converts the geographic boundary entire raster data node into one, two or three shape objects. If the data does not intersect the 180 degree meridian, a single general path is returned. Otherwise two or three shapes are created and returned in the order from west to east.

      The geographic boundary of the given raster data node are returned as shapes comprising (longitude,latitude) pairs.

      Parameters:
      rasterDataNode - the input raster data node
      Returns:
      an array of shape objects
      Throws:
      IllegalArgumentException - if product is null or if the product's GeoCoding is null
      See Also:
    • createGeoBoundaryPaths

      public static GeneralPath[] createGeoBoundaryPaths(Product product, Rectangle region, int step)
      Converts the geographic boundary of the region within the given product into one, two or three shape objects. If the product does not intersect the 180 degree meridian, a single general path is returned. Otherwise two or three shapes are created and returned in the order from west to east.

      This method delegates to createGeoBoundaryPaths(Product, Rectangle, int, boolean) and the additional parameter usePixelCenter is true.

      The geographic boundary of the given product are returned as shapes comprising (longitude,latitude) pairs.

      Parameters:
      product - the input product
      region - the region rectangle in product pixel coordinates, can be null for entire product
      step - the step given in pixels
      Returns:
      an array of shape objects
      Throws:
      IllegalArgumentException - if product is null or if the product's GeoCoding is null
    • createGeoBoundaryPaths

      public static GeneralPath[] createGeoBoundaryPaths(Product product, Rectangle region, int step, boolean usePixelCenter)
      Converts the geographic boundary of the region within the given product into one, two or three shape objects. If the product does not intersect the 180 degree meridian, a single general path is returned. Otherwise two or three shapes are created and returned in the order from west to east.

      The geographic boundary of the given product are returned as shapes comprising (longitude,latitude) pairs.

      Parameters:
      product - the input product
      region - the region rectangle in product pixel coordinates, can be null for entire product
      step - the step given in pixels
      usePixelCenter - true if the pixel center should be used to create the pathes
      Returns:
      an array of shape objects
      Throws:
      IllegalArgumentException - if product is null or if the product's GeoCoding is null
      See Also:
    • createGeoBoundaryPaths

      public static GeneralPath[] createGeoBoundaryPaths(RasterDataNode rasterDataNode, Rectangle region, int step, boolean usePixelCenter)
      Converts the geographic boundary of the region within the given rastrer data node into one, two or three shape objects. If the data node does not intersect the 180 degree meridian, a single general path is returned. Otherwise two or three shapes are created and returned in the order from west to east.

      The geographic boundary of the given raster data node are returned as shapes comprising (longitude,latitude) pairs.

      Parameters:
      rasterDataNode - the input raster data node
      region - the region rectangle in product pixel coordinates, can be null for entire product
      step - the step given in pixels
      usePixelCenter - true if the pixel center should be used to create the pathes
      Returns:
      an array of shape objects
      Throws:
      IllegalArgumentException - if product is null or if the product's GeoCoding is null
      See Also:
    • createPixelBoundary

      public static PixelPos[] createPixelBoundary(RasterDataNode raster, Rectangle rect, int step)
      Creates a rectangular boundary expressed in pixel positions for the given source rectangle. If the source rect is 100 x 50 pixels and step is 10 the returned array will countain exactly 2 * 10 + 2 * (5 - 2) = 26 pixel positions.

      This method is used for an intermediate step when determining a raster boundary expressed in geographical co-ordinates.

      Parameters:
      raster - the raster
      rect - the source rectangle
      step - the mean distance from one pixel position to the other in the returned array
      Returns:
      the rectangular boundary
    • createPixelBoundary

      public static PixelPos[] createPixelBoundary(int rasterWidth, int rasterHeight, Rectangle rect, int step)
      Creates a rectangular boundary expressed in pixel positions for the given source rectangle. If the source rect is 100 x 50 pixels and step is 10 the returned array will contain exactly 2 * 10 + 2 * (5 - 2) = 26 pixel positions.

      This method is used for an intermediate step when determining a raster boundary expressed in geographical co-ordinates.

      Parameters:
      rasterWidth - the raster width in pixels
      rasterHeight - the raster height in pixels
      rect - the source rectangle
      step - the mean distance from one pixel position to the other in the returned array
      Returns:
      the rectangular boundary
    • createPixelBoundaryFromRect

      public static PixelPos[] createPixelBoundaryFromRect(Rectangle rect, int step)
      Creates a rectangular boundary expressed in pixel positions for the given source rectangle. If the source rect is 100 x 50 pixels and step is 10 the returned array will contain exactly 2 * 10 + 2 * (5 - 2) = 26 pixel positions.

      This method is used for an intermediate step when determining a product boundary expressed in geographical co-ordinates.

      This method delegates to createPixelBoundaryFromRect(Rectangle, int, boolean) and the additional boolean parameter usePixelCenter is true.

      Parameters:
      rect - the source rectangle
      step - the mean distance from one pixel position to the other in the returned array
      Returns:
      the rectangular boundary
    • createPixelBoundaryFromRect

      public static PixelPos[] createPixelBoundaryFromRect(Rectangle rect, int step, boolean usePixelCenter)
      Creates a rectangular boundary expressed in pixel positions for the given source rectangle. If the source rect is 100 x 50 pixels and step is 10 the returned array will countain exactly 2 * 10 + 2 * (5 - 2) = 26 pixel positions.

      This method is used for an intermediate step when determining a product boundary expressed in geographical co-ordinates.

      Parameters:
      rect - the source rectangle
      step - the mean distance from one pixel position to the other in the returned array
      usePixelCenter - true if the pixel center should be used
      Returns:
      the rectangular boundary
    • areaToSubPaths

      public static List<GeneralPath> areaToSubPaths(Area area, double deltaX)
      Turns an area into one or multiple paths.
      Parameters:
      area - the area to convert
      deltaX - the value is used to translate the x-cordinates
      Returns:
      the list of paths
    • computePixelRegionUsingGeometry

      public static Rectangle computePixelRegionUsingGeometry(GeoCoding rasterGeoCoding, int rasterWidth, int rasterHeight, org.locationtech.jts.geom.Geometry geometryRegion, int numBorderPixels, boolean roundPixelRegion, boolean multiSize)
    • computeGeometryUsingPixelRegion

      public static org.locationtech.jts.geom.Geometry computeGeometryUsingPixelRegion(GeoCoding rasterGeoCoding, Rectangle pixelRegion)
    • computeRasterGeometry

      public static org.locationtech.jts.geom.Geometry computeRasterGeometry(GeoCoding rasterGeoCoding, int rasterWidth, int rasterHeight)
    • computeRasterGeometry

      public static org.locationtech.jts.geom.Geometry computeRasterGeometry(GeoCoding rasterGeoCoding, int rasterWidth, int rasterHeight, boolean usePixelCenter, boolean multiSize)
    • projectPolygonToGeocoding

      public static org.locationtech.jts.geom.Polygon projectPolygonToGeocoding(org.locationtech.jts.geom.Polygon polygon, GeoCoding polygonGeoCoding, GeoCoding geoCoding)
      Projects the polygon from its geocoding to the target geocoding
      Parameters:
      polygon - the polygon in pixel coordinates (X,Y)
      polygonGeoCoding - the polygon geocoding
      geoCoding - the target geocoding
      Returns:
      the polygon in pixel coordinates (X,Y), projected to the target geocoding
    • projectPolygonToImage

      public static org.locationtech.jts.geom.Polygon projectPolygonToImage(org.locationtech.jts.geom.Polygon polygon, GeoCoding geoCoding)
      Projects the polygon from geo coordinates (Lat,Lon) to pixel coordinates (X,Y) using its geocoding
      Parameters:
      polygon - the polygon with geo coordinates (Lat,Lon)
      geoCoding - the polygon geocoding
      Returns:
      the polygon with pixel coordinates (X,Y)
    • computePolygonExtent

      public static Rectangle computePolygonExtent(org.locationtech.jts.geom.Polygon polygon)
      Calculates the polygon extent (the rectangle which contains all the points of the polygon)
      Parameters:
      polygon - the polygon to which the extent will be calculated
      Returns:
      the polygon extent (the rectangle which contains all the points of the polygon)