Just to add for the interested that the check I didn't remember in the previous email is done here: org.geotools.coverage.grid.io.imageio.geotiff.CRS2GeoTiffMetadataAdapter.getEPSGCode(IdentifiedObject)
On Fri, Aug 20, 2021 at 1:45 PM andrea antonello <andrea.antone...@gmail.com> wrote: > Hi geotoolers, > I wanted to layout an issue I encountered and am not sure about. > > I have a shp file created with QGIS in 4326, which results into having a > prj like: > > 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]] > > If I use the crs object from the featurestore's schema (when reading the > shp) to create a geotiff, I results into having a crs (from gdalinfo): > > GEOGCRS["Greenwich", DATUM["unnamed", ELLIPSOID["unnamed",6378137, > 298.257223563, LENGTHUNIT["metre",1, ID["EPSG",9001]]]], PRIMEM[ > "Greenwich",0, ANGLEUNIT["degree",0.0174532925199433, ID["EPSG",9122]]], > CS[ellipsoidal,2], AXIS["latitude",north, ORDER[1], ANGLEUNIT["degree", > 0.0174532925199433, ID["EPSG",9122]]], AXIS["longitude",east, ORDER[2], > ANGLEUNIT["degree",0.0174532925199433, ID["EPSG",9122]]]] > > Funny enough, even if the parameters seem to be right, QGIS then is not > able to understand the crs. > > I dived into the Geotiff writer and found (gosh I can't find where right > now, sorry) that the test done to get the epsg code is: > > *final* Set< ? *extends* Identifier> identifiers = crs > .getIdentifiers(); > > *final* Iterator< ? *extends* Identifier> it = identifiers > .iterator(); > > String code = ""; > > *while* (it.hasNext()) { > > *final* Identifier identifier = it.next(); > > *final* Citation cite = identifier.getAuthority(); > > *if* (Citations.*identifierMatches*(cite, "EPSG")) { > > code = identifier.getCode(); > > *break*; > > } > > } > > which breaks in case there is no epsg definition. > > I am currentl double-checking this with: > > Integer epsg = CRS.*lookupEpsgCode*(crs, *false*); > > which gives the right epsg. > > So all in all things do work, but for some cases it might not? > I probably forgot what my original question was at this point, so I will > just go with: did anyone experience something like that? > > Thanks for any input, > Cheers, > Andrea > > > > > >
_______________________________________________ GeoTools-GT2-Users mailing list GeoTools-GT2-Users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users