osgearth icon indicating copy to clipboard operation
osgearth copied to clipboard

SRS xform errors trying to use layers on spherical bodies

Open robspearman opened this issue 3 years ago • 12 comments

I am unable to load layers on spherical bodies. I get errors such as this where it seems like there actually should be enough information to work:

[osgEarth]* [SpatialReference] SRS xform not possible:
    From => unknown
    To   => unnamed ellipse
[osgEarth]* [SpatialReference] INPUT: GEOGCS["unknown",DATUM["unknown",SPHEROID["unknown",2439700,0]],PRIMEM["Reference meridian",0],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AXIS["Longitude",EAST],AXIS["Latitude",NORTH]]
OUTPUT: GEOGCS["unnamed ellipse",DATUM["unknown",SPHEROID["unnamed",24397000,0]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AXIS["Latitude",NORTH],AXIS["Longitude",EAST]]
[osgEarth]* [SpatialReference] ERROR: Cannot find coordinate operations from `GEOGCRS["unknown",DATUM["unknown",ELLIPSOID["unknown",2439700,0,LENGTHUNIT["metre",1,ID["EPSG",9001]]]],PRIMEM["Reference meridian",0,ANGLEUNIT["degree",0.0174532925199433,ID["EPSG",9122]]],CS[ellipsoidal,2],AXIS["longitude",east,ORDER[1],ANGLEUNIT["degree",0.0174532925199433,ID["EPSG",9122]]],AXIS["latitude",north,ORDER[2],ANGLEUNIT["degree",0.0174532925199433,ID["EPSG",9122]]]]' to `GEOGCRS["unnamed ellipse",DATUM["unknown",ELLIPSOID["unnamed",24397000,0,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]]]]'


robspearman avatar May 31 '21 00:05 robspearman

Also, same layers work on older osgEarth versions with no problems.

robspearman avatar May 31 '21 00:05 robspearman

Please report your osgEarth version, GDAL version, earth file snippet, and gdalinfo output on the source data.

gwaldron avatar May 31 '21 13:05 gwaldron

osgEarth master branch GDAL 3.0.4

Earth file:

<map name="Mercury" type="geocentric" version="2"> 
   <options> 
      <profile> 
        <srs>+proj=latlong +a=2439700 +b=2439700</srs> 
      </profile> 
      <terrain driver="rex" 
       lighting="false" 
       cluster_culling="true" 
       tile_pixel_size="135" 
       range_mode="PIXEL_SIZE_ON_SCREEN" 
       morph_imagery="true" 
       morph_terrain="true" 
       normal_maps="true" 
       high_resolution_first="false" 
       first_lod="2" 
       skirt_ratio="0.1" 
       tile_size="17" 
       progressive="true"/> 
   </options> 
</map>

gdalinfo:

Driver: GTiff/GeoTIFF
Files: /home/admin/ng/model/mercury-imagery-messenger-color-8k.tif
Size is 8192, 4096
Coordinate System is:
GEOGCRS["unnamed ellipse",
    DATUM["unknown",
        ELLIPSOID["unnamed",24397000,0,
            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]]]]
Data axis to CRS axis mapping: 2,1
Origin = (-180.000000000000000,90.000000000000000)
Pixel Size = (0.043945312500000,-0.043945312500000)
Metadata:
  AREA_OR_POINT=Area
  TIFFTAG_DATETIME=2013:05:08 09:56:28
  TIFFTAG_DOCUMENTNAME=mercury-cropped.tif
  TIFFTAG_RESOLUTIONUNIT=2 (pixels/inch)
  TIFFTAG_SOFTWARE=Adobe Photoshop CS6 (Windows)
  TIFFTAG_XRESOLUTION=72
  TIFFTAG_YRESOLUTION=72
Image Structure Metadata:
  COMPRESSION=JPEG
  INTERLEAVE=PIXEL
Corner Coordinates:
Upper Left  (-180.0000000,  90.0000000) (180d 0' 0.00"W, 90d 0' 0.00"N)
Lower Left  (-180.0000000, -90.0000000) (180d 0' 0.00"W, 90d 0' 0.00"S)
Upper Right ( 180.0000000,  90.0000000) (180d 0' 0.00"E, 90d 0' 0.00"N)
Lower Right ( 180.0000000, -90.0000000) (180d 0' 0.00"E, 90d 0' 0.00"S)
Center      (   0.0000000,   0.0000000) (  0d 0' 0.01"E,  0d 0' 0.01"N)
Band 1 Block=256x256 Type=Byte, ColorInterp=Red
  Overviews: 4096x2048, 2048x1024, 1024x512, 512x256, 256x128
Band 2 Block=256x256 Type=Byte, ColorInterp=Green
  Overviews: 4096x2048, 2048x1024, 1024x512, 512x256, 256x128
Band 3 Block=256x256 Type=Byte, ColorInterp=Blue
  Overviews: 4096x2048, 2048x1024, 1024x512, 512x256, 256x128

robspearman avatar May 31 '21 14:05 robspearman

The ellipsoids don't match (the one in the WKT has an extra zero)

gwaldron avatar Jun 03 '21 14:06 gwaldron

Good eye.  That resolved the error message.

I still am not seeing imagery, but it could be from #1710.

robspearman avatar Jun 03 '21 18:06 robspearman

Are you able to share the GeoTIFF?

gwaldron avatar Jun 03 '21 18:06 gwaldron

My geotiffs are OK, it's just that plain JPEG layers don't load anymore using a GdalLayer.  Is there some other way to load these?

robspearman avatar Jun 03 '21 22:06 robspearman

Rob, you can convert to georeferenced GeoTIFFs with this command (for example)

gdal_translate -a_srs "+proj=latlong +a=2439700 +b=2439700" -a_ullr -180 90 180 -90 -of GTiff input.jpg output.tif

gwaldron avatar Jun 04 '21 14:06 gwaldron

I know, but that's not easy on our users.  Is there no longer a way to load non-geocoded plain images as layers?

robspearman avatar Jun 04 '21 14:06 robspearman

You can put the projection (+proj=latlong +a=2439700 +b=2439700) in a .prj file as well (a.g., input.prj necxt to input.jpg).

There was a bug preventing this from working, which I just pushed a fix for to master.

gwaldron avatar Jun 04 '21 15:06 gwaldron

prj files also do not work for me.  I just get white bodies with no layers and no errors when I try to use a jpeg layer.  Geotiffs load.

robspearman avatar Jun 16 '21 18:06 robspearman

Try using gdal_translate to assign georeferencing information to the file.

gdal_translate -of VRT -a_srs epsg:4326 -a_ullr -180 90 180 -90 cloud_combined_2048.jpg cloud_combined_2048.jpg.vrt

gwaldron avatar Jul 15 '21 12:07 gwaldron