Class ProductSubsetByPolygon

java.lang.Object
org.esa.snap.core.dataio.ProductSubsetByPolygon

public class ProductSubsetByPolygon extends Object
This class provides the core components for the new subset feature, that is Polygon Subset. It provides the functionality to build a subset polygon for a product which can be defined by the one of the following: - a WKT polygon with geographic coordinates (Lat,Lon) - a WKT polygon with pixel coordinates (X,Y) - a vector file in supported formats (SHAPEFILE, KML, KMZ, GEOJSON, WKT, TXT, PLACEMARK, PNX)
  • Constructor Details

    • ProductSubsetByPolygon

      public ProductSubsetByPolygon()
  • Method Details

    • isLoaded

      public boolean isLoaded()
      Checks whether the polygon is loaded
      Returns:
      true when the polygon is loaded and ready to use
    • clear

      public void clear()
      Clears the polygon and its corresponding geocoding
    • getVectorFileFilter

      public SnapFileFilter getVectorFileFilter()
      Provides the filter used by SNAP File Chooser to show only the supported vector files from which the polygon can be loaded
      Returns:
      the filter used by SNAP File Chooser to show only the supported vector files from which the polygon can be loaded
    • loadPolygonFromVectorFile

      public void loadPolygonFromVectorFile(File vectorFile, MetadataInspector.Metadata targetProductMetadata, ProgressMonitor pm) throws Exception
      Loads the polygon from the provided vector file for the specified product metadata
      Parameters:
      vectorFile - the vector file from which the polygon will be loaded, with the one of the following supported formats:
        SHAPEFILE (*.shp)
        KML (*.kml)
        KMZ (*.kmz)
        GEOJSON (*.json)
        WKT (*.wkt)
        TXT (*.txt)
        PLACEMARK (*.placemark)
        PNX (*.pnx)
      targetProductMetadata - the metadata of the product for which the polygon will be loaded
      pm - the progress monitor object to show the progress of the operation
      Throws:
      Exception - when an error occurs while loading the polygon from the vector file
    • loadPolygonFromWKTString

      public void loadPolygonFromWKTString(String wktString, boolean pixelCoordinates, MetadataInspector.Metadata targetProductMetadata, ProgressMonitor pm) throws Exception
      Loads the polygon from the WKT string
      Parameters:
      wktString - the WKT string from which the polygon will be loaded, in which all the coordinates can be pixel coordinates (X,Y) or geo coordinates (Lat,Lon), but not mixed
      pixelCoordinates - the boolean flag which will indicate how the coordinates from the WKT string will be interpreted.
        true the coordinates from the WKT string will be interpreted as pixel coordinates (X,Y)
        false the coordinates from the WKT string will be interpreted as geo coordinates (Lat,Lon)
      targetProductMetadata - the metadata of the product for which the polygon will be loaded
      pm - the progress monitor object to show the progress of the operation
      Throws:
      Exception - when an error occurs while loading the polygon from the WKT string
    • getExtentOfPolygon

      public Rectangle getExtentOfPolygon()
      Provides the extent of the polygon (the rectangle which contains all the points of the polygon)
      Returns:
      the extent of the polygon (the rectangle which contains all the points of the polygon)
    • getExtentOfPolygonProjectedToGeocoding

      public Rectangle getExtentOfPolygonProjectedToGeocoding(GeoCoding geoCoding)
      Provides the extent of the polygon (the rectangle which contains all the points of the polygon) with the coordinates projected to the specified geocoding
      Parameters:
      geoCoding - the target geocoding to which the coordinates of the extent will be projected
      Returns:
      Provides the extent of the polygon (the rectangle which contains all the points of the polygon) with the coordinates projected to the specified geocoding
    • getSubsetPolygon

      public org.locationtech.jts.geom.Polygon getSubsetPolygon()
      Provides the loaded polygon (in pixel coordinates)
      Returns:
      the loaded polygon (in pixel coordinates)
    • getSubsetGeoPolygon

      public org.locationtech.jts.geom.Polygon getSubsetGeoPolygon()
      Provides the loaded polygon (in geographic coordinates)
      Returns:
      the loaded polygon (in geographic coordinates)
    • getSubsetPolygonProjectedToGeocoding

      public org.locationtech.jts.geom.Polygon getSubsetPolygonProjectedToGeocoding(GeoCoding geoCoding)
      Provides the loaded polygon (in pixel coordinates) projected to the specified geocoding
      Parameters:
      geoCoding - the target geocoding to which the coordinates of the polygon will be projected
      Returns:
      the loaded polygon (in pixel coordinates) projected to the specified geocoding