I have 4000+ raw .tif images. For each image, I have the four corner coordinates in Irish Grid System. I'd like to know how I can use GeoTools to georeference each .tif image using the coordinate values I have.

After following some search, I noted that GeoTools have functionalities for my specific need. But I'm still unable to find a concrete example.

1 Answer 1


You need a GridCoverageFactory, some data and a bounding box to make what GeoTools calls a coverage. Once you have a coverage writing it out as a GeoTiff is easy.

GridCoverageFactory gcf = new GridCoverageFactory();
CoordinateReferenceSystem crs = CRS.decode("EPSG:27700");
int llx = 500000;
int lly = 105000;
int urx = 501000;
int ury = 106000;

ReferencedEnvelope referencedEnvelope = new ReferencedEnvelope(llx, urx, lly, ury, crs);
GridCoverage2D gc = gcf.create("name", data, referencedEnvelope);
String url = "random.tif";
File file = new File(url);
GeoTiffWriter writer = new GeoTiffWriter(file);
writer.write(gc, null);

In the above code data could be a 2 dimensional array of values or a RenderedImage or a WritableRaster. Which you use depends on how you want to read in your tiffs.

I've used EPSG:27700 (OSGB) as my reference system but you would need to use the correct EPSG code for the Irish Grid (probably EPSG:29901). Also I hardcoded the corners but you would need to read those in too.

  • Thanks @Ian. I'll try the suggested method.
    – 0xMinCha
    Commented Apr 21, 2021 at 12:34
  • so basically, rendered image is my TiFF image I suppose?
    – 0xMinCha
    Commented Apr 21, 2021 at 13:20
  • 1
    yes, depending of course on how you read it in
    – Ian Turton
    Commented Apr 21, 2021 at 13:21
  • thanks, may I know what is exactly meant by "how you read it". apologies, it's my first few attempts with Tiffs and Geotools. thanks!
    – 0xMinCha
    Commented Apr 21, 2021 at 13:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.