I am reading a shapefile using org.geotols
9.4
and trying to get CRS
code but org.opengis.referencing.crs.CoordinateReferenceSystem
is null
:
FileDataStore store = FileDataStoreFinder.getDataStore(shpFile);
CoordinateReferenceSystem crs = store.getFeatureSource().getSchema().getCoordinateReferenceSystem();
// crs is null
and parsing .prj
throws an error:
String wkt = new String(Files.readAllBytes(Paths.get(shpFile.getAbsolutePath().replace(".shp", ".prj"))));
crs = CRS.parseWKT(wkt);
// throws org.opengis.referencing.NoSuchIdentifierException: No transform for classification "Mercator_Auxiliary_Sphere"
Projection file is:
PROJCS["WGS_1984_Web_Mercator_Auxiliary_Sphere",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Mercator_Auxiliary_Sphere"],PARAMETER["False_Easting",0.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",0.0],PARAMETER["Standard_Parallel_1",0.0],PARAMETER["Auxiliary_Sphere_Type",0.0],UNIT["Meter",1.0]]
I am looking for an answer to why geotools
can not determine the CRS and for a solution to determine all CRS rather than a workaround with this particular projection/file.