Search code examples
javagradlegeotools

Java impossible to import class GridCoverage from Geotools


I'm trying to import some class from Geotools but its seems objects are not recognize:

public Coverage() {
        File file = new File("test.tiff");

        AbstractGridFormat format = GridFormatFinder.findFormat(file);
        GridCoverage2DReader reader = format.getReader(file);

        GridCoverage2D coverage = reader.read(null);

    }

I already import this lib :

geotools_version = '25'
implementation "org.geotools:gt-coverage:${geotools_version}"

Source : https://docs.geotools.org/latest/userguide/library/coverage/grid.html


Solution

  • In case of build.gradle, use the following.

    In case of higher version of gradle like 6, use below.

    implementation 'org.geotools:gt-coverage:24.2'

    In case of lower version of gradle like 4, use the below.

    compile group: 'org.geotools', name: 'gt-coverage', version: '24.2'

    After making changes, use your favorite ide, refresh the gradle project. Once it is done, you will be able to import the class.