Although I got a hint from Ian, I still have a problem to read a GeoTIFF in Geotools. I ask this as a new question so that I can put all info.
The GeoTIFF is from http://cidportal.jrc.ec.europa.eu/ftp/jrc-opendata/GHSL/GHS_POP_GPW4_GLOBE_R2015A/GHS_POP_GPW42015_GLOBE_R2015A_54009_1k/V1-0/
gdalinfo GHS_POP_GPW42015_GLOBE_R2015A_54009_1k_v1_0.tif
Driver: GTiff/GeoTIFF
Files: GHS_POP_GPW42015_GLOBE_R2015A_54009_1k_v1_0.tif
GHS_POP_GPW42015_GLOBE_R2015A_54009_1k_v1_0.tif.ovr
GHS_POP_GPW42015_GLOBE_R2015A_54009_1k_v1_0.tif.aux.xml
Size is 35497, 15236
Coordinate System is:
PROJCS["World_Mollweide",
GEOGCS["GCS_WGS_1984",
DATUM["D_WGS_1984",
SPHEROID["WGS_1984",6378137.0,298.257223563]],
PRIMEM["Greenwich",0.0],
UNIT["Degree",0.017453292519943295]],
PROJECTION["Mollweide"],
PARAMETER["False_Easting",0.0],
PARAMETER["False_Northing",0.0],
PARAMETER["Central_Meridian",0.0],
UNIT["Meter",1.0]]
As it is a Mollweide projection, I add the EPGS definition.
epsg.properties file:
54009=PROJCS["World_Mollweide",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Mollweide"],PARAMETER["Central_Meridian",0.0],UNIT["Meter",1.0]]
URL epsg = getClass().getClassLoader().getResource("epsg.properties");
Hints hints = new Hints(Hints.CRS_AUTHORITY_FACTORY, PropertyAuthorityFactory.class);
ReferencingFactoryContainer referencingFactoryContainer = ReferencingFactoryContainer.instance(hints);
PropertyAuthorityFactory factory;
factory = new PropertyAuthorityFactory(referencingFactoryContainer, Citations.fromName("EPSG"), epsg);
ReferencingFactoryFinder.addAuthorityFactory(factory);
ReferencingFactoryFinder.scanForPlugins();
This prints correctly:
System.out.println(CRS.decode("EPSG:54009"));
PROJCS["World_Mollweide",
GEOGCS["GCS_WGS_1984",
DATUM["D_WGS_1984",
SPHEROID["WGS_1984", 6378137.0, 298.257223563]],
PRIMEM["Greenwich", 0.0],
UNIT["degree", 0.017453292519943295],
AXIS["Longitude", EAST],
AXIS["Latitude", NORTH]],
PROJECTION["Mollweide"],
PARAMETER["semi_minor", 6378137.0],
PARAMETER["false_easting", 0.0],
PARAMETER["false_northing", 0.0],
PARAMETER["central_meridian", 0.0],
UNIT["m", 1.0],
AXIS["x", EAST],
AXIS["y", NORTH],
AUTHORITY["EPSG","54009"]]
But
String fileName = "/home/XXX/GHS_POP_GPW42015_GLOBE_R2015A_54009_1k_v1_0.tif";
new GeoTiffReader(new FileInputStream(new File(fileName)));
still throws an error
GeoTiffMetadata2CRSAdapter::createCoordinateSystem:Only Geographic & Projected Systems are supported.
at org.geotools.coverage.grid.io.imageio.geotiff.GeoTiffMetadata2CRSAdapter.createCoordinateSystem(GeoTiffMetadata2CRSAdapter.java:186)
at org.geotools.gce.geotiff.GeoTiffReader.getHRInfo(GeoTiffReader.java:329)
... 4 more
geotools version 21.0 maven
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-main</artifactId>
<version>${geotools.version}</version>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-referencing</artifactId>
<version>${geotools.version}</version>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-epsg-wkt</artifactId>
<version>${geotools.version}</version>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-geotiff</artifactId>
<version>${geotools.version}</version>
</dependency>