/** * Installs an Envisat-specific tie-point geo-coding in the given product. */ public static void initTiePointGeoCoding(final Product product) { TiePointGrid latGrid = product.getTiePointGrid(EnvisatConstants.LAT_DS_NAME); TiePointGrid lonGrid = product.getTiePointGrid(EnvisatConstants.LON_DS_NAME); if (latGrid != null && lonGrid != null) { product.setGeoCoding(new TiePointGeoCoding(latGrid, lonGrid, Datum.WGS_84)); } }
private GeoCoding createStripeGeocode(float[] lats, float[] lons, int y, int stripeW, int stripeH, float offsetX, float offsetY, float subSamplingX, float subSamplingY) throws IOException { final Range range = Range.computeRangeFloat(lats, IndexValidator.TRUE, null, ProgressMonitor.NULL); if (range.getMin() < -90) { return null; } else { final ModisTiePointGrid latGrid = new ModisTiePointGrid("lat" + y, stripeW, stripeH, offsetX, offsetY, subSamplingX, subSamplingY, lats); final ModisTiePointGrid lonGrid = new ModisTiePointGrid("lon" + y, stripeW, stripeH, offsetX, offsetY, subSamplingX, subSamplingY, lons, TiePointGrid.DISCONT_AT_180); final TiePointGeoCoding geoCoding = new TiePointGeoCoding(latGrid, lonGrid, getDatum()); _cross180 = _cross180 || geoCoding.isCrossingMeridianAt180(); return geoCoding; } }
product.addTiePointGrid(tpLon); product.setGeoCoding(new TiePointGeoCoding(tpLat, tpLon));
private TiePointGeoCoding createTestGeoCoding() { GeoPos[] targetCoords = createCoords(); int numCoords = targetCoords.length; float[] lats = new float[numCoords]; float[] lons = new float[numCoords]; for (int i = 0; i < numCoords; i++) { lats[i] = targetCoords[i].lat; lons[i] = targetCoords[i].lon; } TiePointGrid latGrid = new TiePointGrid("lat", gridW, gridH, 0.0f, 0.0f, stepX, stepY, lats); TiePointGrid lonGrid = new TiePointGrid("lon", gridW, gridH, 0.0f, 0.0f, stepX, stepY, lons, TiePointGrid.DISCONT_AT_180); return new TiePointGeoCoding(latGrid, lonGrid, Datum.WGS_84); }
protected void addTiePointGrids() throws IOException { int tpSubsampling = avhrrFile.getTiePointSubsampling(); final int gridHeight = avhrrFile.getProductHeight() / tpSubsampling + 1; String[] tiePointNames = avhrrFile.getTiePointNames(); float[][] tiePointData = avhrrFile.getTiePointData(); final int numGrids = tiePointNames.length; TiePointGrid grid[] = new TiePointGrid[numGrids]; for (int i = 0; i < grid.length; i++) { grid[i] = createTiePointGrid(tiePointNames[i], TP_GRID_WIDTH, gridHeight, TP_OFFSET_X, TP_OFFSET_Y, tpSubsampling, tpSubsampling, tiePointData[i]); grid[i].setUnit(UNIT_DEG); product.addTiePointGrid(grid[i]); } GeoCoding geoCoding = new TiePointGeoCoding(grid[numGrids - 2], grid[numGrids - 1], Datum.WGS_72); product.setGeoCoding(geoCoding); }
private static void setTiePointGeoCoding(final Product product) { final TiePointGrid latGrid = new TiePointGrid("lat", 3, 3, 0.5f, 0.5f, 5, 5, new float[]{ 85, 84, 83, 75, 74, 73, 65, 64, 63 }); final TiePointGrid lonGrid = new TiePointGrid("lon", 3, 3, 0.5f, 0.5f, 5, 5, new float[]{ -15, -5, 5, -16, -6, 4, -17, -7, 3 }); product.addTiePointGrid(latGrid); product.addTiePointGrid(lonGrid); product.setGeoCoding(new TiePointGeoCoding(latGrid, lonGrid, org.esa.beam.framework.dataop.maptransf.Datum.WGS_84)); }
public void addGeocoding(final Product product) throws ProductIOException { String navGroup = "Scan-Line_Attributes"; final String longitude = "lon"; final String latitude = "lat"; int susampX = 16; int subsampY = 2; Variable lats = ncFile.findVariable(navGroup + "/" +latitude); Variable lons = ncFile.findVariable(navGroup + "/" +longitude); int[] dims = lats.getShape(); float[] latTiePoints; float[] lonTiePoints; try { Array latarr = lats.read(); Array lonarr = lons.read(); latTiePoints = (float[]) latarr.getStorage(); lonTiePoints = (float[]) lonarr.getStorage(); final TiePointGrid latGrid = new TiePointGrid("latitude", dims[1], dims[0], 0, 0, susampX, subsampY, latTiePoints); product.addTiePointGrid(latGrid); final TiePointGrid lonGrid = new TiePointGrid("longitude", dims[1], dims[0], 0, 0, susampX, subsampY, lonTiePoints, TiePointGrid.DISCONT_AT_180); product.addTiePointGrid(lonGrid); product.setGeoCoding(new TiePointGeoCoding(latGrid, lonGrid, Datum.WGS_84)); } catch (IOException e) { throw new ProductIOException(e.getMessage(), e); } }
if (latGrid != null && lonGrid != null) { resultProduct.setGeoCoding( new TiePointGeoCoding(latGrid, lonGrid, sourceProduct.getGeoCoding().getDatum()));
final TiePointGrid lonGrid2 = new TiePointGrid("lon", 2, 2, 0, 0, 1, 1, new float[]{2, 3, 4, 5}); final TiePointGeoCoding geoCoding1 = new TiePointGeoCoding(latGrid, lonGrid, Datum.WGS_84); final TiePointGeoCoding geoCoding2 = new TiePointGeoCoding(latGrid, lonGrid2, Datum.WGS_84);
public void testRequiresGeoCoding() { final TiePointGrid latGrid = new TiePointGrid("lat", 2, 2, 0, 0, 1, 1, new float[]{1, 2, 3, 4}); final TiePointGrid lonGrid = new TiePointGrid("lon", 2, 2, 0, 0, 1, 1, new float[]{1, 2, 3, 4}); final TiePointGeoCoding geoCoding = new TiePointGeoCoding(latGrid, lonGrid, Datum.WGS_84); try { new TiePointGridPointing(geoCoding, null, null, null, null, null); // OK } catch (Exception e) { fail(); } try { new TiePointGridPointing(null, null, null, null, null, null); fail(); } catch (Exception e) { // OK } }
static Product createSourceProduct(int sourceProductCounter, float value) { final Product p = new Product("P" + sourceProductCounter, "T", 2, 2); final TiePointGrid latitude = new TiePointGrid("latitude", 2, 2, 0.5F, 0.5F, 1.0F, 1.0F, new float[]{ 1.0F, 1.0F, 0.0F, 0.0F, }); final TiePointGrid longitude = new TiePointGrid("longitude", 2, 2, 0.5F, 0.5F, 1.0F, 1.0F, new float[]{ 0.0F, 1.0F, 0.0F, 1.0F, }); p.addTiePointGrid(latitude); p.addTiePointGrid(longitude); p.setGeoCoding(new TiePointGeoCoding(latitude, longitude)); p.addBand("chl", value + ""); return p; }
private static Product createTestProduct() { final float[] longitudes = new float[]{ 9.512839f, 9.690325f, 9.867694f, 10.044944f, 10.2220745f, 10.399086f, 9.475174f, 9.65231f, 9.829329f, 10.006232f, 10.183016f, 10.359681f, 9.437564f, 9.614353f, 9.791027f, 9.967584f, 10.144024f, 10.320345f, 9.40001f, 9.576455f, 9.752785f, 9.929f, 10.105098f, 10.281079f, 9.362511f, 9.538614f, 9.714604f, 9.890479f, 10.066238f, 10.241882f, 9.325066f, 9.50083f, 9.676482f, 9.85202f, 10.027444f, 10.202752f, 9.287674f, 9.463103f, 9.638419f, 9.813623f, 9.988713f, 10.163689f, 9.250335f, 9.42543f, 9.600414f, 9.775286f, 9.950046f, 10.124692f, 9.213048f, 9.387812f, 9.562466f, 9.737009f, 9.911441f, 10.08576f }; final float[] latitudes = new float[]{ 34.254475f, 34.22662f, 34.198513f, 34.170143f, 34.14152f, 34.11264f, 34.088284f, 34.060417f, 34.032295f, 34.00392f, 33.975292f, 33.946407f, 33.922085f, 33.894207f, 33.866077f, 33.837692f, 33.809055f, 33.780163f, 33.755875f, 33.72799f, 33.69985f, 33.67145f, 33.642807f, 33.61391f, 33.589664f, 33.56176f, 33.53361f, 33.505207f, 33.476555f, 33.447655f, 33.423443f, 33.395527f, 33.367367f, 33.338955f, 33.310295f, 33.281387f, 33.257214f, 33.229286f, 33.201115f, 33.172695f, 33.144028f, 33.115112f, 33.090977f, 33.06304f, 33.034855f, 33.006424f, 32.977753f, 32.948833f, 32.924736f, 32.896786f, 32.868587f, 32.84015f, 32.811466f, 32.78254f }; final Product product = new Product("testName", "TEST_TYPE", 50, 100); final TiePointGrid lonGrid = new TiePointGrid("longitudes", 6, 9, -3.5f, -7.5f, 16, 16, longitudes); product.addTiePointGrid(lonGrid); final TiePointGrid latGrid = new TiePointGrid("latitudes", 6, 9, -3.5f, -7.5f, 16, 16, latitudes); product.addTiePointGrid(latGrid); final TiePointGeoCoding tpGeoCoding = new TiePointGeoCoding(latGrid, lonGrid); product.setGeoCoding(tpGeoCoding); return product; }
destScene.setGeoCoding(new TiePointGeoCoding(latGrid, lonGrid, getDatum())); return true; } else {
@Before public void setUp() throws Exception { product = new Product("p", "t", PRODUCT_WIDTH, PRODUCT_HEIGHT); TiePointGrid lat = new TiePointGrid("t1", 3, 3, 0, 0, 5, 5, new float[]{ 2.0f, 2.0f, 2.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f}); product.addTiePointGrid(lat); TiePointGrid lon = new TiePointGrid("t2", 3, 3, 0, 0, 5, 5, new float[]{ 0.0f, 1.0f, 2.0f, 0.0f, 1.0f, 2.0f, 0.0f, 1.0f, 2.0f}); product.addTiePointGrid(lon); product.setGeoCoding(new TiePointGeoCoding(lat, lon, Datum.WGS_84)); attachIndexCodedBand(); attachColoredBand(); }
private static Product createProduct() throws Exception { Product product = new Product("p", "t", 32, 256); final TiePointGrid lat = new TiePointGrid("lat", 2, 2, 0f, 0f, 32f, 256f, new float[]{+40f, +40f, -40f, -40f}); final TiePointGrid lon = new TiePointGrid("lon", 2, 2, 0f, 0f, 32f, 256f, new float[]{-80f, +80f, -80f, +80f}); product.addTiePointGrid(lat); product.addTiePointGrid(lon); product.setGeoCoding(new TiePointGeoCoding(lat, lon)); product.setPreferredTileSize(32, 16); product.setStartTime(ProductData.UTC.parse("2003-01-01", "yyyy-MM-dd")); product.setEndTime(ProductData.UTC.parse("2003-01-02", "yyyy-MM-dd")); return product; }
@BeforeClass public static void setup() { product = new Product("p", "t", 14, 16); TiePointGrid t1 = new TiePointGrid("t1", 3, 3, 0, 0, 5, 5, new float[]{ 0.6f, 0.3f, 0.4f, 0.8f, 0.9f, 0.4f, 0.3f, 0.2f, 0.4f }); product.addTiePointGrid(t1); TiePointGrid t2 = new TiePointGrid("t2", 3, 3, 0, 0, 5, 5, new float[]{ 0.9f, 0.2f, 0.3f, 0.6f, 0.1f, 0.4f, 0.2f, 0.9f, 0.5f }); product.addTiePointGrid(t2); product.setGeoCoding(new TiePointGeoCoding(t1, t2, Datum.WGS_84)); TiePointGrid t3 = new TiePointGrid("t3", 3, 3, 1, 1, 3, 3, new float[]{ 1, 2, 3, 4, 5, 6, 7, 8, 9 }); product.addTiePointGrid(t3); geoBoundaryPath = ProductUtils.createGeoBoundaryPaths(product); }
private Product createProduct() { Product product = new Product("test", "test", PW, PH); TiePointGrid latGrid = new TiePointGrid("latGrid", GW, GH, 0.5f, 0.5f, S, S, createLatGridData()); TiePointGrid lonGrid = new TiePointGrid("lonGrid", GW, GH, 0.5f, 0.5f, S, S, createLonGridData()); product.addTiePointGrid(latGrid); product.addTiePointGrid(lonGrid); Band latBand = product.addBand("latBand", ProductData.TYPE_FLOAT32); Band lonBand = product.addBand("lonBand", ProductData.TYPE_FLOAT32); latBand.setRasterData(ProductData.createInstance(createBandData(latGrid))); lonBand.setRasterData(ProductData.createInstance(createBandData(lonGrid))); product.setGeoCoding(new TiePointGeoCoding(latGrid, lonGrid, Datum.WGS_84)); return product; }
private void createSourceProduct() throws Exception { sourceProduct = new Product("source", "t", 50, 50); final TiePointGrid latGrid = new TiePointGrid("latGrid", 2, 2, 0.5f, 0.5f, 49, 49, LATS); final TiePointGrid lonGrid = new TiePointGrid("lonGrid", 2, 2, 0.5f, 0.5f, 49, 49, LONS); sourceProduct.addTiePointGrid(latGrid); sourceProduct.addTiePointGrid(lonGrid); sourceProduct.setGeoCoding(new TiePointGeoCoding(latGrid, lonGrid)); sourceProduct.setStartTime(ProductData.UTC.parse("02-Jan-2008 10:15:10")); sourceProduct.setEndTime(ProductData.UTC.parse("02-Jan-2008 10:45:50")); Band floatDataBand = sourceProduct.addBand(FLOAT_BAND_NAME, ProductData.TYPE_FLOAT32); floatDataBand.setRasterData(createDataFor(floatDataBand)); floatDataBand.setSynthetic(true); Band intDataBand = sourceProduct.addBand(INT_BAND_NAME, ProductData.TYPE_INT16); intDataBand.setRasterData(createDataFor(intDataBand)); intDataBand.setSynthetic(true); }
private Product createSourceProduct(int w, int h) throws ParseException { Product sourceProduct = new Product("TEST.N1", "MER_RR__1P", w, h); sourceProduct.setStartTime(ProductData.UTC.parse("17-Jan-2008 12:13:27")); sourceProduct.setEndTime(ProductData.UTC.parse("17-Jan-2008 13:16:28")); Band rad08 = sourceProduct.addBand("radiance_8", ProductData.TYPE_INT16); Band rad10 = sourceProduct.addBand("radiance_10", ProductData.TYPE_INT16); rad08.setSourceImage(ConstantDescriptor.create(1.0f * w, 1.0f * h, new Short[]{2000}, null)); rad10.setSourceImage(ConstantDescriptor.create(1.0f * w, 1.0f * h, new Short[]{3000}, null)); rad08.setScalingFactor(0.01); rad10.setScalingFactor(0.01); TiePointGrid lat = new TiePointGrid("latitude", w, h, 0, 0, 1, 1, new float[w * h]); TiePointGrid lon = new TiePointGrid("longitude", w, h, 0, 0, 1, 1, new float[w * h]); sourceProduct.addTiePointGrid(lat); sourceProduct.addTiePointGrid(lon); sourceProduct.setGeoCoding(new TiePointGeoCoding(lat, lon)); return sourceProduct; }
private Product createProduct() { Product product = new Product("test", "test", PW, PH); TiePointGrid latGrid = new TiePointGrid("latGrid", GW, GH, 0.5f, 0.5f, S, S, createLatGridData()); TiePointGrid lonGrid = new TiePointGrid("lonGrid", GW, GH, 0.5f, 0.5f, S, S, createLonGridData()); product.addTiePointGrid(latGrid); product.addTiePointGrid(lonGrid); Band latBand = product.addBand("latBand", ProductData.TYPE_FLOAT32); Band lonBand = product.addBand("lonBand", ProductData.TYPE_FLOAT32); latBand.setRasterData(ProductData.createInstance(createBandData(latGrid))); lonBand.setRasterData(ProductData.createInstance(createBandData(lonGrid))); final FlagCoding flagCoding = new FlagCoding("flags"); flagCoding.addFlag("valid", 0, "valid pixel"); product.getFlagCodingGroup().add(flagCoding); Band flagomatBand = product.addBand("flagomat", ProductData.TYPE_UINT8); flagomatBand.setRasterData(ProductData.createInstance(ProductData.TYPE_UINT8, PW * PH)); flagomatBand.setSampleCoding(flagCoding); product.setGeoCoding(new TiePointGeoCoding(latGrid, lonGrid, Datum.WGS_84)); return product; }