<div dir="ltr"><div>Short version:</div><div><br></div><div>I don't understand why the below code snippet is returning TRUE.  Unless I'm missing something, EPSG 3857 is not the same as 3395, why is GDAL reporting that they are?</div><div><br></div><div><div>            auto epsg3857 = OGRSpatialReference();</div><div>            epsg3857.importFromEPSG(3857);</div><div><br></div><div>            auto epsg3395 = OGRSpatialReference();</div><div>            epsg3395.importFromEPSG(3395);</div><div><br></div><div>            if (epsg3857.IsSame(&epsg3395) == TRUE) {</div><div>                std::cout << "Bug?" << std::endl;</div><div>            }</div></div><div><br></div><div>Longer version:</div><div><br></div><div>I'm attempting to load in a GeoTIFF and detect whether it is already in EPSG:3857 or needs to be reprojected.  My function looks like this:</div><div><br></div><div><div>        bool isSpatialReferenceSystem(GDALDataset &dataset, int epsg)</div><div>        {</div><div>            std::string in_srs_wkt = dataset.GetProjectionRef();</div><div><br></div><div>            if (in_srs_wkt.length() == 0)</div><div>            {</div><div>                return false;</div><div>            }</div><div><br></div><div>            auto dataset_srs = OGRSpatialReference(in_srs_wkt.c_str());</div><div>            auto target_srs = OGRSpatialReference();</div><div>            target_srs.importFromEPSG(epsg);</div><div>            return dataset_srs.IsSame(&target_srs) == TRUE;</div><div>        }</div><div><br></div><div>This function worked as expected until a few days ago when I was given a GeoTIFF with the following information (via gdalinfo): </div><div><br></div><div><div>Driver: GTiff/GeoTIFF</div><div>Files: data.tif</div><div>Size is 11779, 8832</div><div>Coordinate System is:</div><div>PROJCS["WGS 84 / World Mercator",</div><div>    GEOGCS["WGS 84",</div><div>        DATUM["WGS_1984",</div><div>            SPHEROID["WGS 84",6378137,298.257223563,</div><div>                AUTHORITY["EPSG","7030"]],</div><div>            AUTHORITY["EPSG","6326"]],</div><div>        PRIMEM["Greenwich",0,</div><div>            AUTHORITY["EPSG","8901"]],</div><div>        UNIT["degree",0.0174532925199433,</div><div>            AUTHORITY["EPSG","9122"]],</div><div>        AUTHORITY["EPSG","4326"]],</div><div>    PROJECTION["Mercator_1SP"],</div><div>    PARAMETER["central_meridian",0],</div><div>    PARAMETER["scale_factor",1],</div><div>    PARAMETER["false_easting",0],</div><div>    PARAMETER["false_northing",0],</div><div>    UNIT["metre",1,</div><div>        AUTHORITY["EPSG","9001"]],</div><div>    AXIS["Easting",EAST],</div><div>    AXIS["Northing",NORTH],</div><div>    AUTHORITY["EPSG","3395"]]</div><div>Origin = (723576.685867484660000,5474400.172804606100000)</div><div>Pixel Size = (33.077567560570841,-33.077567560572312)</div><div>Metadata:</div><div>  AREA_OR_POINT=Area</div><div>Image Structure Metadata:</div><div>  INTERLEAVE=PIXEL</div><div>Corner Coordinates:</div><div>Upper Left  (  723576.686, 5474400.173) (  6d30' 0.00"E, 44d15' 0.34"N)</div><div>Lower Left  (  723576.686, 5182259.096) (  6d30' 0.00"E, 42d20' 0.00"N)</div><div>Upper Right ( 1113197.354, 5474400.173) ( 10d 0' 0.08"E, 44d15' 0.34"N)</div><div>Lower Right ( 1113197.354, 5182259.096) ( 10d 0' 0.08"E, 42d20' 0.00"N)</div><div>Center      (  918387.020, 5328329.634) (  8d15' 0.04"E, 43d17'57.55"N)</div><div>Band 1 Block=11779x1 Type=Byte, ColorInterp=Red</div><div>  Mask Flags: PER_DATASET ALPHA</div><div>Band 2 Block=11779x1 Type=Byte, ColorInterp=Green</div><div>  Mask Flags: PER_DATASET ALPHA</div><div>Band 3 Block=11779x1 Type=Byte, ColorInterp=Blue</div><div>  Mask Flags: PER_DATASET ALPHA</div><div>Band 4 Block=11779x1 Type=Byte, ColorInterp=Alpha</div></div><div><br></div></div><div>Creating a GDALDataset from the image and calling my function returns TRUE when I expect it to return false, after some debugging, I traced it back to my simpler code snippet that shows 3857 and 3395 being treated as the same.</div><div><br></div><div>The odd thing is that if I tell GDAL to reproject the image to 3857 (via a VRT), everything works.  So GDAL clearly knows they are different under the hood.</div><div><br></div><div>I assume my understanding of IsSame is flawed so any clarification would be a big help.</div><div><br></div><div>Thanks,</div><div><br></div><div>Matt</div><div><br></div></div>