/** * Add GeoReferencing information to the writer, * starting from the CoordinateReferenceSystem and the MathTransform * * @param writer * @param crs * @param transform */ public void updateProjectionInformation(NetCDFCoordinateReferenceSystemType crsType, NetcdfFileWriter writer, CoordinateReferenceSystem crs, MathTransform transform) { NetCDFProjection projection = crsType.getNetCDFProjection(); // Projection may be exposed as standard NetCDF CF GridMapping (if available) // as well as through SPATIAL_REF and GeoTransform attributes (GDAL way) if (projection != null) { String name = projection.getName(); Variable var = writer.findVariable(name); setGridMappingVariableAttributes(writer, crs, var, projection); setGeoreferencingAttributes(writer, crs, transform, var); } else { addGlobalAttributes(writer, crs, transform); } }
/** * Add GeoReferencing global attributes (GDAL's spatial_ref and GeoTransform). They will be used * for datasets with unsupported NetCDF CF projection. * * @param writer * @param crs * @param transform */ private void addGlobalAttributes( NetcdfFileWriter writer, CoordinateReferenceSystem crs, MathTransform transform) { writer.addGroupAttribute(null, getSpatialRefAttribute(crs)); writer.addGroupAttribute(null, getGeoTransformAttribute(transform)); }
/** * Initialize the dimensions by creating NetCDF Dimensions of the proper type. */ private void initializeDimensions() { initializeHigherRankDimensions(); // Initialize the lat,lon/y,x 2D dimensions and coordinates dimensionsManager.addDimensions(crsWriter.initialize2DCoordinatesDimensions()); }
/** * Basic NetCDF Initialization */ private void initializeNetCDF() { // Initialize the coordinates writer crsWriter = new NetCDFCRSWriter(writer, sampleGranule); // Initialize the Dimensions and coordinates variable initializeDimensions(); // Initialize the variable by setting proper coordinates and attributes initializeVariable(); initializeGlobalAttributes(); }
/** * Write the NetCDF file * @throws IOException * @throws InvalidRangeException */ public void write() throws IOException, InvalidRangeException { // end of define mode writer.create(); // Setting values for (NetCDFDimensionMapping mapper : dimensionsManager.getDimensions()) { crsWriter.setCoordinateVariable(mapper); } writeDataValues(); // Close the writer writer.close(); }
addCoordinateVariable(axisCoordinates[0], height, ymin, periodY); addCoordinateVariable(axisCoordinates[1], width, xmin, periodX); return coordinatesDimensions;
/** Basic NetCDF Initialization */ protected void initializeNetCDF() { // Initialize the coordinates writer crsWriter = new NetCDFCRSWriter(writer, sampleGranule); // Initialize the Dimensions and coordinates variable initializeDimensions(); // Initialize the variable by setting proper coordinates and attributes initializeVariables(); initializeGlobalAttributes(); }
/** * Write the NetCDF file * * @throws IOException * @throws InvalidRangeException */ public void write() throws IOException, ucar.ma2.InvalidRangeException { // end of define mode writer.create(); try { // Setting values for (NetCDFDimensionsManager.NetCDFDimensionMapping mapper : dimensionsManager.getDimensions()) { crsWriter.setCoordinateVariable(mapper); } writeDataValues(); } finally { // Close the writer writer.close(); } }
addCoordinateVariable(axisCoordinates[0], height, ymin, periodY); addCoordinateVariable(axisCoordinates[1], width, xmin, periodX); return coordinatesDimensions;
/** * Add GeoReferencing information to the writer, starting from the CoordinateReferenceSystem and * the MathTransform * * @param writer * @param crs * @param transform */ public void updateProjectionInformation( NetCDFCoordinateReferenceSystemType crsType, NetcdfFileWriter writer, CoordinateReferenceSystem crs, MathTransform transform) { NetCDFProjection projection = crsType.getNetCDFProjection(); // Projection may be exposed as standard NetCDF CF GridMapping (if available) // as well as through SPATIAL_REF and GeoTransform attributes (GDAL way) if (projection != null) { String name = projection.getName(); Variable var = writer.findVariable(name); setGridMappingVariableAttributes(writer, crs, var, projection); setGeoreferencingAttributes(writer, crs, transform, var); } else { addGlobalAttributes(writer, crs, transform); } }
/** * Add GeoReferencing global attributes (GDAL's spatial_ref and GeoTransform). * They will be used for datasets with unsupported NetCDF CF projection. * @param writer * @param crs * @param transform */ private void addGlobalAttributes(NetcdfFileWriter writer, CoordinateReferenceSystem crs, MathTransform transform) { writer.addGroupAttribute(null, getSpatialRefAttribute(crs)); writer.addGroupAttribute(null, getGeoTransformAttribute(transform)); }
/** Initialize the dimensions by creating NetCDF Dimensions of the proper type. */ protected void initializeDimensions() { initializeHigherRankDimensions(); // Initialize the lat,lon/y,x 2D dimensions and coordinates dimensionsManager.addDimensions(crsWriter.initialize2DCoordinatesDimensions()); }
/** * Add the gridMapping attribute * * @param writer * @param crs * @param transform * @param var * @param gridMapping */ private void setGeoreferencingAttributes(NetcdfFileWriter writer, CoordinateReferenceSystem crs, MathTransform transform, Variable var) { // Adding GDAL Attributes spatial_ref and GeoTransform writer.addVariableAttribute(var, getSpatialRefAttribute(crs)); writer.addVariableAttribute(var, getGeoTransformAttribute(transform)); }
/** * Add the gridMapping attribute * * @param writer * @param crs * @param transform * @param var * @param gridMapping */ private void setGeoreferencingAttributes( NetcdfFileWriter writer, CoordinateReferenceSystem crs, MathTransform transform, Variable var) { // Adding GDAL Attributes spatial_ref and GeoTransform writer.addVariableAttribute(var, getSpatialRefAttribute(crs)); writer.addVariableAttribute(var, getGeoTransformAttribute(transform)); }