Package org.esa.snap.core.dataio
Class ProductSubsetByPolygon
java.lang.Object
org.esa.snap.core.dataio.ProductSubsetByPolygon
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears the polygon and its corresponding geocodingProvides the extent of the polygon (the rectangle which contains all the points of the polygon)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 geocodingorg.locationtech.jts.geom.PolygonProvides the loaded polygon (in geographic coordinates)org.locationtech.jts.geom.PolygonProvides the loaded polygon (in pixel coordinates)org.locationtech.jts.geom.PolygongetSubsetPolygonProjectedToGeocoding(GeoCoding geoCoding) Provides the loaded polygon (in pixel coordinates) projected to the specified geocodingProvides the filter used by SNAP File Chooser to show only the supported vector files from which the polygon can be loadedbooleanisLoaded()Checks whether the polygon is loadedvoidloadPolygonFromVectorFile(File vectorFile, MetadataInspector.Metadata targetProductMetadata, ProgressMonitor pm) Loads the polygon from the provided vector file for the specified product metadatavoidloadPolygonFromWKTString(String wktString, boolean pixelCoordinates, MetadataInspector.Metadata targetProductMetadata, ProgressMonitor pm) Loads the polygon from the WKT string
-
Constructor Details
-
ProductSubsetByPolygon
public ProductSubsetByPolygon()
-
-
Method Details
-
isLoaded
public boolean isLoaded()Checks whether the polygon is loaded- Returns:
truewhen the polygon is loaded and ready to use
-
clear
public void clear()Clears the polygon and its corresponding geocoding -
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 loadedpm- 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 mixedpixelCoordinates- the boolean flag which will indicate how the coordinates from the WKT string will be interpreted.truethe coordinates from the WKT string will be interpreted as pixel coordinates (X,Y)falsethe 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 loadedpm- 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
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
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
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
-