Tabnine Logo
GeoTiff
Code IndexAdd Tabnine to your IDE (free)

How to use
GeoTiff
in
ucar.nc2.geotiff

Best Java code snippets using ucar.nc2.geotiff.GeoTiff (Showing top 20 results out of 315)

origin: edu.ucar/netcdf

/**
 * test
 */
public static void main(String[] argv) {
 try {
  GeoTiff geotiff = new GeoTiff("/home/yuanho/tmp/ilatlon_float.tif");
  //GeoTiff geotiff = new GeoTiff("/home/yuanho/tmp/maxtemp.tif");
  //GeoTiff geotiff = new GeoTiff("/home/yuanho/tmp/test.tif");
  //GeoTiff geotiff = new GeoTiff("C:/data/geotiff/c41078a1.tif");
  //GeoTiff geotiff = new GeoTiff("C:/data/geotiff/L7ETMbands147.tif");
  //GeoTiff geotiff = new GeoTiff("data/blueTest.tiff");
  /*GeoTiff geotiff = new GeoTiff("data/testWrite.tiff");
  geotiff.addTag( new IFDEntry(Tag.SampleFormat, FieldType.SHORT, 3));
  geotiff.write();
  geotiff.close();
  geotiff = new GeoTiff("data/testWrite.tiff"); */
  geotiff.read();
  geotiff.showInfo(System.out);
  geotiff.testReadData();
  geotiff.close();
 } catch (Exception e) {
  e.printStackTrace();
 }
}
origin: edu.ucar/netcdf

void testReadData() throws IOException {
 IFDEntry tileOffsetTag = findTag(Tag.TileOffsets);
 if (tileOffsetTag != null) {
  int tileOffset = tileOffsetTag.value[0];
  IFDEntry tileSizeTag = findTag(Tag.TileByteCounts);
  int tileSize = tileSizeTag.value[0];
  System.out.println("tileOffset =" + tileOffset + " tileSize=" + tileSize);
  testReadData(tileOffset, tileSize);
 } else {
  IFDEntry stripOffsetTag = findTag(Tag.StripOffsets);
  if (stripOffsetTag != null) {
   int stripOffset = stripOffsetTag.value[0];
   IFDEntry stripSizeTag = findTag(Tag.StripByteCounts);
   int stripSize = stripSizeTag.value[0];
   System.out.println("stripOffset =" + stripOffset + " stripSize=" + stripSize);
   testReadData(stripOffset, stripSize);
  }
 }
}
origin: Unidata/thredds

private void addLatLonTags1() {
 geotiff.addGeoKey(new GeoKey(GeoKey.Tag.GTModelTypeGeoKey,
     GeoKey.TagValue.ModelType_Geographic));
 geotiff.addGeoKey(new GeoKey(GeoKey.Tag.GeogGeodeticDatumGeoKey,
     GeoKey.TagValue.GeogGeodeticDatum6267));
}
origin: Unidata/thredds

/**
 * Read the geotiff file, using the filename passed in the constructor.
 *
 * @throws IOException on read error
 */
public void read() throws IOException {
 file = new RandomAccessFile(filename, "r");
 channel = file.getChannel();
 if (debugRead) System.out.println("Opened file to read:'" + filename + "', size=" + channel.size());
 readonly = true;
 int nextOffset = readHeader(channel);
 while (nextOffset > 0) {
  nextOffset = readIFD(channel, nextOffset);
  parseGeoInfo();
 }
 //parseGeoInfo();
}
origin: Unidata/thredds

void writeMetadata(int imageNumber) throws IOException {
 if (file == null)
  init();
 // geokeys all get added at once
 writeGeoKeys();
 // tags gotta be in order
 Collections.sort(tags);
 if (imageNumber == 1) {
  writeHeader(channel);
 } else {
  //now this is not the first image we need to fill the Offset of nextIFD
  channel.position(lastIFD);
  ByteBuffer buffer = ByteBuffer.allocate(4);
  if (debugRead)
   System.out.println("position before writing nextIFD= " + channel.position() + " IFD is " + firstIFD);
  buffer.putInt(firstIFD);
  buffer.flip();
  channel.write(buffer);
 }
 writeIFD(channel, firstIFD);
}
origin: edu.ucar/netcdf

 nextStart = geotiff.writeData((byte[]) result.getStorage(), imageNumber);
} else {
 ArrayFloat result = replaceMissingValues(grid, data);
 nextStart = geotiff.writeData((float[]) result.getStorage(), imageNumber);
int width = data.getShape()[1];         // X
int size = elemSize * height * width;  // size in bytes
geotiff.addTag(new IFDEntry(Tag.ImageWidth, FieldType.SHORT).setValue(width));
geotiff.addTag(new IFDEntry(Tag.ImageLength, FieldType.SHORT).setValue(height));
geotiff.addTag(new IFDEntry(Tag.NewSubfileType, FieldType.SHORT).setValue(ff));
geotiff.addTag(new IFDEntry(Tag.PageNumber, FieldType.SHORT).setValue(page, 2));
geotiff.addTag(new IFDEntry(Tag.RowsPerStrip, FieldType.SHORT).setValue(1));  //height));
geotiff.addTag(new IFDEntry(Tag.StripByteCounts, FieldType.LONG, width).setValue(sbytecount));
geotiff.addTag(new IFDEntry(Tag.StripOffsets, FieldType.LONG, width).setValue(soffset));
geotiff.addTag(new IFDEntry(Tag.Orientation, FieldType.SHORT).setValue(1));
geotiff.addTag(new IFDEntry(Tag.Compression, FieldType.SHORT).setValue(1));  // no compression
geotiff.addTag(new IFDEntry(Tag.Software, FieldType.ASCII).setValue("nc2geotiff"));
geotiff.addTag(new IFDEntry(Tag.PhotometricInterpretation, FieldType.SHORT).setValue(1));  // black is zero : not used?
geotiff.addTag(new IFDEntry(Tag.PlanarConfiguration, FieldType.SHORT).setValue(1));
 geotiff.addTag(new IFDEntry(Tag.BitsPerSample, FieldType.SHORT).setValue(8));  // 8 bits per sample
 geotiff.addTag(new IFDEntry(Tag.SamplesPerPixel, FieldType.SHORT).setValue(1));
 geotiff.addTag(new IFDEntry(Tag.XResolution, FieldType.RATIONAL).setValue(1, 1));
 geotiff.addTag(new IFDEntry(Tag.YResolution, FieldType.RATIONAL).setValue(1, 1));
origin: Unidata/thredds

@Test
public void testRead() throws IOException {
 try (GeoTiff geotiff = new GeoTiff(filename)) {
  geotiff.read();
  StringWriter sw = new StringWriter();
  geotiff.showInfo(new PrintWriter(sw));
  logger.debug(sw.toString());
  IFDEntry tileOffsetTag = geotiff.findTag(Tag.TileOffsets);
  if (tileOffsetTag != null) {
   int tileOffset = tileOffsetTag.value[0];
   IFDEntry tileSizeTag = geotiff.findTag(Tag.TileByteCounts);
   int tileSize = tileSizeTag.value[0];
   logger.debug("tileOffset={} tileSize={}", tileOffset, tileSize);
  } else {
   IFDEntry stripOffsetTag = geotiff.findTag(Tag.StripOffsets);
   if (stripOffsetTag != null) {
    int stripOffset = stripOffsetTag.value[0];
    IFDEntry stripSizeTag = geotiff.findTag(Tag.StripByteCounts);
    if (stripSizeTag == null) throw new IllegalStateException();
    int stripSize = stripSizeTag.value[0];
    logger.debug("stripOffset={} stripSize={}", stripOffset, stripSize);
   }
  }
 }
}
origin: Unidata/thredds

try (GeoTiff geotiff = new GeoTiff(gridOut)) {
 geotiff.read();
 logger.debug("{}", geotiff.showInfo());
 try (GeoTiff geotiff2 = new GeoTiff(gridOut2)) {
  geotiff2.read();
  logger.debug("{}", geotiff2.showInfo());
  geotiff.compare(geotiff2, out);
  logger.debug("{}", out.toString());
origin: Unidata/thredds

 @Test
 public void testWrite() throws IOException {
  String fileOut = tempFolder.newFile().getAbsolutePath();

  try (GeoTiffWriter2 writer = new GeoTiffWriter2(fileOut)) {
   writer.writeGrid(filename, field, 0, 0, true, llbb);
  }

  // read it back in
  try (GeoTiff geotiff = new GeoTiff(fileOut)) {
   geotiff.read();
   System.out.println("geotiff read in = " + geotiff.showInfo());
   //geotiff.testReadData();
  }
 }
}
origin: Unidata/thredds

geotiff.addTag(new IFDEntry(Tag.ImageWidth, FieldType.SHORT).setValue(width));
geotiff.addTag(new IFDEntry(Tag.ImageLength, FieldType.SHORT).setValue(height));
geotiff.addTag(new IFDEntry(Tag.NewSubfileType, FieldType.SHORT).setValue(ff));
geotiff.addTag(new IFDEntry(Tag.PageNumber, FieldType.SHORT).setValue(page, 2));
geotiff.addTag(new IFDEntry(Tag.RowsPerStrip, FieldType.SHORT).setValue(1));  //height));
geotiff.addTag(new IFDEntry(Tag.StripByteCounts, FieldType.LONG, width).setValue(sbytecount));
geotiff.addTag(new IFDEntry(Tag.StripOffsets, FieldType.LONG, width).setValue(soffset));
geotiff.addTag(new IFDEntry(Tag.Orientation, FieldType.SHORT).setValue(1));
geotiff.addTag(new IFDEntry(Tag.Compression, FieldType.SHORT).setValue(1));  // no compression
geotiff.addTag(new IFDEntry(Tag.Software, FieldType.ASCII).setValue("nc2geotiff"));
geotiff.addTag(new IFDEntry(Tag.PhotometricInterpretation, FieldType.SHORT).setValue(1));  // black is zero : not used?
geotiff.addTag(new IFDEntry(Tag.PlanarConfiguration, FieldType.SHORT).setValue(1));
 geotiff.addTag(new IFDEntry(Tag.BitsPerSample, FieldType.SHORT).setValue(8));  // 8 bits per sample
 geotiff.addTag(new IFDEntry(Tag.SamplesPerPixel, FieldType.SHORT).setValue(1));
 geotiff.addTag(new IFDEntry(Tag.XResolution, FieldType.RATIONAL).setValue(1, 1));
 geotiff.addTag(new IFDEntry(Tag.YResolution, FieldType.RATIONAL).setValue(1, 1));
 geotiff.addTag(new IFDEntry(Tag.ResolutionUnit, FieldType.SHORT).setValue(1));
 geotiff.addTag(new IFDEntry(Tag.BitsPerSample, FieldType.SHORT).setValue(32));  // 32 bits per sample
 geotiff.addTag(new IFDEntry(Tag.SampleFormat, FieldType.SHORT).setValue(3));  // Sample Format
 geotiff.addTag(new IFDEntry(Tag.SamplesPerPixel, FieldType.SHORT).setValue(1));
 float min = (float) (dataMinMax.min);
 float max = (float) (dataMinMax.max);
origin: Unidata/thredds

geotiff.initTags();
origin: edu.ucar/netcdf

void setTransform(double xStart, double yStart, double xInc, double yInc) {
 // tie the raster 0, 0 to xStart, yStart
 addTag(new IFDEntry(Tag.ModelTiepointTag, FieldType.DOUBLE).setValue(
   new double[]{0.0, 0.0, 0.0, xStart, yStart, 0.0}));
 // define the "affine transformation" : requires grid to be regular (!)
 addTag(new IFDEntry(Tag.ModelPixelScaleTag, FieldType.DOUBLE).setValue(
   new double[]{xInc, yInc, 0.0}));
}
origin: edu.ucar/cdm

int writeData(byte[] data, int imageNumber) throws IOException {
 if (file == null)
  init();
 if (imageNumber == 1)
  channel.position(headerSize);
 else
  channel.position(nextOverflowData);
 ByteBuffer buffer = ByteBuffer.wrap(data);
 channel.write(buffer);
 if (imageNumber == 1)
  firstIFD = headerSize + data.length;
 else
  firstIFD = data.length + nextOverflowData;
 return nextOverflowData;
}
origin: edu.ucar/cdm

/**
 * Constructor
 *
 * @param fileOut name of output file.
 */
public GeotiffWriter(String fileOut) {
 geotiff = new GeoTiff(fileOut);
}
origin: edu.ucar/cdm

/**
 * Write the geotiff Tag information to a String.
 */
public String showInfo() {
 StringWriter sw = new StringWriter(5000);
 showInfo(new PrintWriter(sw));
 return sw.toString();
}
origin: edu.ucar/netcdf

private void parseGeoInfo() {
 IFDEntry keyDir = findTag(Tag.GeoKeyDirectoryTag);
 IFDEntry dparms = findTag(Tag.GeoDoubleParamsTag);
 IFDEntry aparams = findTag(Tag.GeoAsciiParamsTag);
   IFDEntry data = findTag(Tag.get(location));
   if (data == null) {
    System.out.println("********ERROR parseGeoInfo: cant find Tag code = " + location);
origin: Unidata/thredds

 geotiff.initTags();
if (greyScale) {
 ArrayByte result = replaceMissingValuesAndScale(array, data, dataMinMax);
 nextStart = geotiff.writeData((byte[]) result.getStorage(), pageNumber);
} else {
 ArrayFloat result = replaceMissingValues(array, data, dataMinMax);
 nextStart = geotiff.writeData((float[]) result.getStorage(), pageNumber);
origin: edu.ucar/cdm

public void close() throws IOException {
 geotiff.close();
}
origin: edu.ucar/cdm

void writeMetadata(int imageNumber) throws IOException {
 if (file == null)
  init();
 // geokeys all get added at once
 writeGeoKeys();
 // tags gotta be in order
 Collections.sort(tags);
 if (imageNumber == 1) {
  writeHeader(channel);
 } else {
  //now this is not the first image we need to fill the Offset of nextIFD
  channel.position(lastIFD);
  ByteBuffer buffer = ByteBuffer.allocate(4);
  if (debugRead)
   System.out.println("position before writing nextIFD= " + channel.position() + " IFD is " + firstIFD);
  buffer.putInt(firstIFD);
  buffer.flip();
  channel.write(buffer);
 }
 writeIFD(channel, firstIFD);
}
origin: edu.ucar/cdm

 nextStart = geotiff.writeData((byte[]) result.getStorage(), imageNumber);
} else {
 ArrayFloat result = replaceMissingValues(grid, data);
 nextStart = geotiff.writeData((float[]) result.getStorage(), imageNumber);
int height = data.getShape()[0];         // Y
int width = data.getShape()[1];         // X
geotiff.addTag(new IFDEntry(Tag.ImageWidth, FieldType.SHORT).setValue(width));
geotiff.addTag(new IFDEntry(Tag.ImageLength, FieldType.SHORT).setValue(height));
geotiff.addTag(new IFDEntry(Tag.NewSubfileType, FieldType.SHORT).setValue(ff));
geotiff.addTag(new IFDEntry(Tag.PageNumber, FieldType.SHORT).setValue(page, 2));
geotiff.addTag(new IFDEntry(Tag.RowsPerStrip, FieldType.SHORT).setValue(1));  //height));
geotiff.addTag(new IFDEntry(Tag.StripByteCounts, FieldType.LONG, width).setValue(sbytecount));
geotiff.addTag(new IFDEntry(Tag.StripOffsets, FieldType.LONG, width).setValue(soffset));
geotiff.addTag(new IFDEntry(Tag.Orientation, FieldType.SHORT).setValue(1));
geotiff.addTag(new IFDEntry(Tag.Compression, FieldType.SHORT).setValue(1));  // no compression
geotiff.addTag(new IFDEntry(Tag.Software, FieldType.ASCII).setValue("nc2geotiff"));
geotiff.addTag(new IFDEntry(Tag.PhotometricInterpretation, FieldType.SHORT).setValue(1));  // black is zero : not used?
geotiff.addTag(new IFDEntry(Tag.PlanarConfiguration, FieldType.SHORT).setValue(1));
 geotiff.addTag(new IFDEntry(Tag.BitsPerSample, FieldType.SHORT).setValue(8));  // 8 bits per sample
 geotiff.addTag(new IFDEntry(Tag.SamplesPerPixel, FieldType.SHORT).setValue(1));
 geotiff.addTag(new IFDEntry(Tag.XResolution, FieldType.RATIONAL).setValue(1, 1));
 geotiff.addTag(new IFDEntry(Tag.YResolution, FieldType.RATIONAL).setValue(1, 1));
ucar.nc2.geotiffGeoTiff

Javadoc

Low level read/write geotiff files.

Most used methods

  • <init>
    Constructor. Does not open or create the file.
  • findTag
  • showInfo
    Write the geotiff Tag information to out.
  • addGeoKey
  • addTag
  • close
    Close the Geotiff file.
  • init
  • initTags
  • parseGeoInfo
  • readHeader
  • readIFD
  • readIFDEntry
  • readIFD,
  • readIFDEntry,
  • readIntValue,
  • readSValue,
  • readUShortValue,
  • readValues,
  • setTransform,
  • writeData,
  • writeGeoKeys,
  • writeHeader

Popular in Java

  • Parsing JSON documents to java classes using gson
  • getResourceAsStream (ClassLoader)
  • runOnUiThread (Activity)
  • requestLocationUpdates (LocationManager)
  • ObjectMapper (com.fasterxml.jackson.databind)
    ObjectMapper provides functionality for reading and writing JSON, either to and from basic POJOs (Pl
  • UnknownHostException (java.net)
    Thrown when a hostname can not be resolved.
  • Date (java.sql)
    A class which can consume and produce dates in SQL Date format. Dates are represented in SQL as yyyy
  • UUID (java.util)
    UUID is an immutable representation of a 128-bit universally unique identifier (UUID). There are mul
  • JTable (javax.swing)
  • FileUtils (org.apache.commons.io)
    General file manipulation utilities. Facilities are provided in the following areas: * writing to a
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now