1

I am trying to create a custom projection in GeoServer, but I see nothing (from the logs, neither in the SRS_list) coming out. The projection I'm trying to create is a Mercator for Mercury.

I start from the following proj4 string:

+proj=merc +a=2439700 +b=2439700 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext  +no_defs

Then, in Python, I use pyproj to convert it to WKT:

>>> from pyproj.crs import CRS
>>> merc = CRS('+proj=merc +a=2439700 +b=2439700 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext  +no_defs')
>>> merc.to_wkt()                                                                                                   
'PROJCRS["unknown",BASEGEOGCRS["unknown",DATUM["unknown",ELLIPSOID["unknown",2439700,0,LENGTHUNIT["metre",1,ID["EPSG",9001]]]],PRIMEM["Reference meridian",0,ANGLEUNIT["degree",0.0174532925199433,ID["EPSG",9122]]]],CONVERSION["unknown",METHOD["Popular Visualisation Pseudo Mercator",ID["EPSG",1024]],PARAMETER["Latitude of natural origin",0,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8801]],PARAMETER["Longitude of natural origin",0,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8802]],PARAMETER["False easting",0,LENGTHUNIT["metre",1],ID["EPSG",8806]],PARAMETER["False northing",0,LENGTHUNIT["metre",1],ID["EPSG",8807]]],CS[Cartesian,2],AXIS["(E)",east,ORDER[1],LENGTHUNIT["metre",1,ID["EPSG",9001]]],AXIS["(N)",north,ORDER[2],LENGTHUNIT["metre",1,ID["EPSG",9001]]]]'

Which I then append to my GeoServer's /usr/local/tomcat/webapps/ROOT/data/user_projections/epsg.properties as:

90000000=PROJCRS["Mercator / Mercury", \
    BASEGEOGCRS["unknown", \
        DATUM["unknown", \
            ELLIPSOID["unknown",2439700,0, \
                LENGTHUNIT["metre",1, \
                    ID["EPSG",9001] \
                ] \
            ] \
        ], \
        PRIMEM["Reference meridian",0, \
            ANGLEUNIT["degree",0.0174532925199433, \
                ID["EPSG",9122] \
            ] \
        ] \
    ], \
    CONVERSION["unknown", \
        METHOD["Popular Visualisation Pseudo Mercator", \
            ID["EPSG",1024] \
        ], \
        PARAMETER["Latitude of natural origin",0, \
            ANGLEUNIT["degree",0.0174532925199433], \
            ID["EPSG",8801] \
        ], \
        PARAMETER["Longitude of natural origin",0, \
            ANGLEUNIT["degree",0.0174532925199433], \
            ID["EPSG",8802] \
        ], \
        PARAMETER["False easting",0, \
            LENGTHUNIT["metre",1], \
            ID["EPSG",8806] \
        ], \
        PARAMETER["False northing",0, \
            LENGTHUNIT["metre",1], \
            ID["EPSG",8807] \
        ] \
    ], \
    CS[Cartesian,2], \
    AXIS["(E)",east,ORDER[1], \
        LENGTHUNIT["metre",1, \
            ID["EPSG",9001] \
        ] \
    ], \
    AXIS["(N)",north,ORDER[2], \
        LENGTHUNIT["metre",1, \
            ID["EPSG",9001] \
        ] \
    ] \
]

I then restart GeoServer but nothing comes out in the logs (no error) neither in the Demos/SRS_list. It is like the projection/file is not read.

Clearly, I'm missing something obvious here...Any thoughts?

  • try putting it all on one line, I'm not sure the parser supports \ for line continuation – Ian Turton May 22 at 16:36
  • Hi @IanTurton, thanks but it didn't help. Same thing, nothing happens. Maybe geoserver is just not reading that file... – Brandt May 22 at 18:18
2

Andrea Aime answered it in the geoserver-users list, which I quote here for the records:

the syntax looks like a WKT2 representation, which GeoServer is not able to parse (code contributions or funding to get it going more than welcomed). I believe you'll have to rewrite it using WKT compatible sytanx instead (I'm not aware of an automatic conversion tool, if anyone knows one, could you please let us know?)

Pyproj CRS' to_wkt() returns a WKT2 string by default, to change that we may use the version argument; from CRS.to_wkt docs:

to_wkt(...) method of pyproj.crs.CRS instance
    Convert the projection to a WKT string.

    Version options:
      - WKT2_2015
      - WKT2_2015_SIMPLIFIED
      - WKT2_2018
      - WKT2_2018_SIMPLIFIED
      - WKT1_GDAL
      - WKT1_ESRI


    Parameters
    ----------
    version: str
        The version of the WKT output. Default is WKT2_2018.

    Returns
    -------
    str: The WKT string.

Indeed, I had GeoServer successfully reading my projection using WKT1_ESRI:

>>> merc.to_wkt('WKT1_ESRI')                                                                                       
'PROJCS["unknown",GEOGCS["GCS_unknown",DATUM["D_unknown",SPHEROID["unknown",2439700.0,0.0]],PRIMEM["Reference meridian",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]]'

and with WKT1_GDAL too -- after a small editing: remove the EXTENSION field, GS doesn't like it.


Update

For further info about WKT versions:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.