I am new to GIS and I want to read population data from a GeoTiff Grid using the java geotools library.
The following throws a runtime error
GridCoverage2D image = new GeoTiffReader(f);
gives
Error message: GeoTiffMetadata2CRSAdapter::createCoordinateSystem:Only
Geographic & Projected Systems are supported.
Is there a way to have geotools to use Mollweide ? Or can I convert the tiff file ?
Below is the gdalinfo.
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]]
Origin = (-17619594.547443531453609,8751029.461868489161134)
Pixel Size = (1000.000000000000000,-1000.000000000000000)
Metadata:
AREA_OR_POINT=Area
Image Structure Metadata:
COMPRESSION=LZW
INTERLEAVE=BAND
Corner Coordinates:
Upper Left (-17619594.547, 8751029.462) ( 5d15'16.97"W, 83d38'22.73"N)
Lower Left (-17619594.547,-6484970.538) (107d 3'58.73"E, 55d59' 2.97"S)
Upper Right (17877405.453, 8751029.462) ( 15d52' 0.05"E, 83d38'22.73"N)
Lower Right (17877405.453,-6484970.538) (103d21'55.35"W, 55d59' 2.97"S)
Center ( 128905.453, 1133029.462) ( 1d17'47.25"E, 9d10'43.07"N)
SOLUTION from @IanTurton:
I created a epsg.properties file with the line indicated by Ian. And added the following code:
URL epsg = getClass().getClassLoader().getResource("epsg.properties");
if (epsg != null) {
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();
}
else throw new IOException("properties not found");