@Override protected Void doInBackground(ProgressMonitor pm) throws Exception { final GeoCoding pixelGeoCoding = GeoCodingFactory.createPixelGeoCoding(latBand, lonBand, validMask, searchRadius, pm); product.setGeoCoding(pixelGeoCoding); return null; }
private static void addGeoCodingToProduct(Product product) { initTiePointGeoCoding(product); final boolean usePixeGeoCoding = Boolean.getBoolean(SYSPROP_ENVISAT_USE_PIXEL_GEO_CODING); if (usePixeGeoCoding) { Band latBand = product.getBand(EnvisatConstants.LAT_DS_NAME); if (latBand == null) { latBand = product.getBand(EnvisatConstants.MERIS_AMORGOS_L1B_CORR_LATITUDE_BAND_NAME); } Band lonBand = product.getBand(EnvisatConstants.LON_DS_NAME); if (lonBand == null) { lonBand = product.getBand(EnvisatConstants.MERIS_AMORGOS_L1B_CORR_LONGITUDE_BAND_NAME); } if (latBand != null && lonBand != null) { String validMask; if (EnvisatConstants.MERIS_L1_TYPE_PATTERN.matcher(product.getProductType()).matches()) { validMask = "NOT l1_flags.INVALID"; } else { validMask = "l2_flags.LAND or l2_flags.CLOUD or l2_flags.WATER"; } product.setGeoCoding(GeoCodingFactory.createPixelGeoCoding(latBand, lonBand, validMask, 6)); } } }
private static void testIllegalArgumentExceptionNotThrownByConstructor(Band b1, Band b2, String validMask, int searchRadius) { try { GeoCodingFactory.createPixelGeoCoding(b1, b2, validMask, searchRadius, ProgressMonitor.NULL); } catch (IOException e) { fail(); } catch (IllegalArgumentException e) { fail(); } }
private static GeoCoding readPixelGeoCoding(Product product) throws IOException { Band lonBand = product.getBand(Constants.LON_VAR_NAME); if (lonBand == null) { lonBand = product.getBand(Constants.LONGITUDE_VAR_NAME); } Band latBand = product.getBand(Constants.LAT_VAR_NAME); if (latBand == null) { latBand = product.getBand(Constants.LATITUDE_VAR_NAME); } if (latBand != null && lonBand != null) { return GeoCodingFactory.createPixelGeoCoding(latBand, lonBand, latBand.getValidMaskExpression(), 5); } return null; }
public void addGeocoding(final Product product) throws ProductIOException { final String longitude = "scat_beam_clon"; final String latitude = "scat_beam_clat"; Band latBand = null; Band lonBand = null; if (product.containsBand(latitude) && product.containsBand(longitude)) { latBand = product.getBand(latitude); lonBand = product.getBand(longitude); } if (latBand != null && lonBand != null) { product.setGeoCoding(GeoCodingFactory.createPixelGeoCoding(latBand, lonBand, null, 5)); } } }
private static GeoCoding createPixelGeoCoding(Product product, Datum datum, Element geoPosElem) { final String latBandName = geoPosElem.getChildTextTrim(DimapProductConstants.TAG_LATITUDE_BAND); final String lonBandName = geoPosElem.getChildTextTrim(DimapProductConstants.TAG_LONGITUDE_BAND); final Band latBand = product.getBand(latBandName); final Band lonBand = product.getBand(lonBandName); final Element searchRadiusElem = geoPosElem.getChild(DimapProductConstants.TAG_SEARCH_RADIUS); int searchRadius = Integer.parseInt(searchRadiusElem.getTextTrim()); if (searchRadius == 0) { searchRadius = 6; } String validMask = null; if (geoPosElem.getChild(DimapProductConstants.TAG_VALID_MASK_EXPRESSION) != null) { validMask = geoPosElem.getChildTextTrim(DimapProductConstants.TAG_VALID_MASK_EXPRESSION); } final Element posEstimatorElement = geoPosElem.getChild(DimapProductConstants.TAG_PIXEL_POSITION_ESTIMATOR); if (posEstimatorElement != null) { final Content posEstimatorContent = posEstimatorElement.detach(); final Document dom = new Document(); dom.addContent(posEstimatorContent); product.setGeoCoding(createGeoCoding(dom, product)[0]); } return GeoCodingFactory.createPixelGeoCoding(latBand, lonBand, validMask, searchRadius); }
public void addGeocoding(final Product product) throws ProductIOException { final String longitude = "longitude"; final String latitude = "latitude"; Band latBand = product.getBand(latitude); Band lonBand = product.getBand(longitude); latBand.setNoDataValue(-999.); lonBand.setNoDataValue(-999.); latBand.setNoDataValueUsed(true); lonBand.setNoDataValueUsed(true); product.setGeoCoding(GeoCodingFactory.createPixelGeoCoding(latBand, lonBand, null, 5)); } }
private void initGeoCodings(Document dom) { final GeoCoding[] geoCodings = DimapProductHelpers.createGeoCoding(dom, product); if (geoCodings != null) { if (geoCodings.length == 1) { product.setGeoCoding(geoCodings[0]); } else { for (int i = 0; i < geoCodings.length; i++) { product.getBandAt(i).setGeoCoding(geoCodings[i]); } } } else { final Band lonBand = product.getBand("longitude"); final Band latBand = product.getBand("latitude"); if (latBand != null && lonBand != null) { final GeoCoding geoCoding = GeoCodingFactory.createPixelGeoCoding(latBand, lonBand, null, 6); product.setGeoCoding(geoCoding); } } }
@Before public void setUp() throws Exception { sourceP = new Product("test", "test", 6, 7); final Band latBand = sourceP.addBand(bandNameLat, ProductData.TYPE_FLOAT32); fillWithData(latBand, 0.03f, 30f); final Band lonBand = sourceP.addBand(bandNameLon, ProductData.TYPE_FLOAT32); fillWithData(lonBand, 0.047f, 50f); pixelGeoCoding = GeoCodingFactory.createPixelGeoCoding(latBand, lonBand, null, 5); sourceP.setGeoCoding(pixelGeoCoding); }
/** * Transfers the geo-coding of the {@link org.esa.beam.framework.datamodel.Scene srcScene} to the {@link org.esa.beam.framework.datamodel.Scene destScene} with respect to the given * {@link org.esa.beam.framework.dataio.ProductSubsetDef subsetDef}. * * @param srcScene the source scene * @param destScene the destination scene * @param subsetDef the definition of the subset, may be <code>null</code> * @return true, if the geo-coding could be transferred. */ @Override public boolean transferGeoCoding(final Scene srcScene, final Scene destScene, final ProductSubsetDef subsetDef) { BowtiePixelGeoCoding srcGeocoding = (BowtiePixelGeoCoding) srcScene.getGeoCoding(); final String latBandName = srcGeocoding._latBand.getName(); final String lonBandName = srcGeocoding._lonBand.getName(); ensureLatLonBands(destScene, subsetDef); final Band targetLatBand = destScene.getProduct().getBand(latBandName); final Band targetLonBand = destScene.getProduct().getBand(lonBandName); if (subsetDef != null) { if (subsetDef.getSubSamplingY() != 1) { destScene.setGeoCoding(GeoCodingFactory.createPixelGeoCoding(targetLatBand, targetLonBand, null, 5)); return true; } } if (targetLatBand != null && targetLonBand != null) { destScene.setGeoCoding(new BowtiePixelGeoCoding(targetLatBand, targetLonBand, srcGeocoding._scanlineHeight)); return true; } return false; }
Band latBand = p.getBand(Constants.LAT_VAR_NAME); if (latBand != null && lonBand != null) { geoCoding = GeoCodingFactory.createPixelGeoCoding(latBand, lonBand, latBand.getValidMaskExpression(), 5);
lonBand.setData(lonRawData); product.setGeoCoding(GeoCodingFactory.createPixelGeoCoding(latBand, lonBand, null, 5));
@Test public void testGetPixelPos() throws IOException { Product product = createProduct(); TiePointGeoCoding tiePointGeoCoding = (TiePointGeoCoding) product.getGeoCoding(); GeoCoding pixelGeoCoding = GeoCodingFactory.createPixelGeoCoding(product.getBand("latBand"), product.getBand("lonBand"), null, 2, ProgressMonitor.NULL); product.setGeoCoding(pixelGeoCoding); TiePointGrid latGrid = tiePointGeoCoding.getLatGrid(); TiePointGrid lonGrid = tiePointGeoCoding.getLonGrid(); GeoPos gp = new GeoPos(latGrid.getTiePoints()[0], lonGrid.getTiePoints()[0]); PixelPos pixelPos = pixelGeoCoding.getPixelPos(gp, null); assertEquals(new PixelPos(0.5f, 0.5f), pixelPos); System.out.println("----"); gp = new GeoPos((latGrid.getTiePoints()[0] + latGrid.getTiePoints()[1]) / 2, (lonGrid.getTiePoints()[0] + lonGrid.getTiePoints()[1]) / 2); pixelPos = pixelGeoCoding.getPixelPos(gp, null); assertEquals(new PixelPos(2.5f, 0.5f), pixelPos); }
private void doTestTransferGeoCoding_WithSpatialSubset() throws IOException { Product sourceProduct = createProduct(); GeoCoding pixelGeoCoding = GeoCodingFactory.createPixelGeoCoding(sourceProduct.getBand("latBand"), sourceProduct.getBand("lonBand"), "flagomat.valid", 5,
product.setGeoCoding(GeoCodingFactory.createPixelGeoCoding(latBand, lonBand, null, 5));
ProductData lons = ProductData.createInstance(longitudes); lonBand.setData(lons); product.setGeoCoding(GeoCodingFactory.createPixelGeoCoding(latBand, lonBand, null, 10));
Product product = createProduct(); TiePointGeoCoding tiePointGeoCoding = (TiePointGeoCoding) product.getGeoCoding(); GeoCoding pixelGeoCoding = GeoCodingFactory.createPixelGeoCoding(product.getBand("latBand"), product.getBand("lonBand"), null, 5, ProgressMonitor.NULL); product = createProduct(); tiePointGeoCoding = (TiePointGeoCoding) product.getGeoCoding(); pixelGeoCoding = GeoCodingFactory.createPixelGeoCoding(product.getBand("latBand"), product.getBand("lonBand"), null, 5, ProgressMonitor.NULL);
private void doTestGetGeoPos() throws IOException { Product product = createProduct(); TiePointGeoCoding tiePointGeoCoding = (TiePointGeoCoding) product.getGeoCoding(); GeoCoding pixelGeoCoding = GeoCodingFactory.createPixelGeoCoding(product.getBand("latBand"), product.getBand("lonBand"), null, 5, ProgressMonitor.NULL); product.setGeoCoding(pixelGeoCoding); String gp; gp = new GeoPos(tiePointGeoCoding.getLatGrid().getTiePoints()[0], tiePointGeoCoding.getLonGrid().getTiePoints()[0]).toString(); assertEquals(gp, tiePointGeoCoding.getGeoPos(new PixelPos(0.5f, 0.5f), null).toString()); assertEquals(gp, pixelGeoCoding.getGeoPos(new PixelPos(0.5f, 0.5f), null).toString()); gp = new GeoPos(tiePointGeoCoding.getLatGrid().getTiePoints()[GW - 1], tiePointGeoCoding.getLonGrid().getTiePoints()[GW - 1]).toString(); assertEquals(gp, tiePointGeoCoding.getGeoPos(new PixelPos(PW - 0.5f, 0.5f), null).toString()); assertEquals(gp, pixelGeoCoding.getGeoPos(new PixelPos(PW - 0.5f, 0.5f), null).toString()); gp = new GeoPos(tiePointGeoCoding.getLatGrid().getTiePoints()[GW * (GH - 1)], tiePointGeoCoding.getLonGrid().getTiePoints()[GW * (GH - 1)]).toString(); assertEquals(gp, tiePointGeoCoding.getGeoPos(new PixelPos(0.5f, PH - 0.5f), null).toString()); assertEquals(gp, pixelGeoCoding.getGeoPos(new PixelPos(0.5f, PH - 0.5f), null).toString()); gp = new GeoPos(tiePointGeoCoding.getLatGrid().getTiePoints()[GW * GH - 1], tiePointGeoCoding.getLonGrid().getTiePoints()[GW * GH - 1]).toString(); assertEquals(gp, tiePointGeoCoding.getGeoPos(new PixelPos(PW - 0.5f, PH - 0.5f), null).toString()); assertEquals(gp, pixelGeoCoding.getGeoPos(new PixelPos(PW - 0.5f, PH - 0.5f), null).toString()); }