1

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.

asked Apr 20, 2021 at 22:00

1 Answer 1

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);
writer.dispose();

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.

answered Apr 21, 2021 at 7:48
4
  • Thanks @Ian. I'll try the suggested method. Commented Apr 21, 2021 at 12:34
  • so basically, rendered image is my TiFF image I suppose? Commented Apr 21, 2021 at 13:20
  • 1
    yes, depending of course on how you read it in 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! Commented Apr 21, 2021 at 13:25

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.