[gdal-dev] How do I add a projection to proj 8?

Even Rouault even.rouault at spatialys.com
Sun Apr 14 04:03:11 PDT 2024


Stephen,

there are 2 possiblities:

- you may reuse your modified /usr/share/proj/epsg file from PROJ.4. But 
in this case, the EPSG entries of proj.db will not be used, so you will 
use only legacy CRS and transformations

- or you add a custom entry in proj.db

For the later, the following will output SQL statements that should be 
put in the DB, but they need a bit of tweaking given that the logic that 
suggests the SQL statements try to set a "proper" CRS definition which 
lacks the PROJ.4 +over or +nadgrids=@null hack

projinfo --output-id EPSG:900914 -o SQL -q "+proj=merc +a=6371001 
+b=6371001 +lat_ts=0.0 +lon_0=0.0 +x_0=-4448 +y_0=-4448 +k=1.0 +units=m 
+over +nadgrids=@null +no_defs +type=crs"

With a bit of hand tuning, if you run the following statements in your 
proj.db,

INSERT INTO ellipsoid 
VALUES('EPSG','ELLPS_GEODETIC_DATUM_GEODETIC_CRS_900914','unknown','','IAU_2015','399',6371001,'EPSG','9001',NULL,6371001,0);
INSERT INTO geodetic_datum 
VALUES('EPSG','GEODETIC_DATUM_GEODETIC_CRS_900914','unknown using 
nadgrids=@null','','EPSG','ELLPS_GEODETIC_DATUM_GEODETIC_CRS_900914','EPSG','8901',NULL,NULL,NULL,NULL,NULL,0);
INSERT INTO usage 
VALUES('EPSG','USAGE_GEODETIC_DATUM_GEODETIC_CRS_900914','geodetic_datum','EPSG','GEODETIC_DATUM_GEODETIC_CRS_900914','PROJ','EXTENT_UNKNOWN','PROJ','SCOPE_UNKNOWN');
INSERT INTO geodetic_crs 
VALUES('EPSG','GEODETIC_CRS_900914','unknown','','geographic 
2D','EPSG','6424','EPSG','GEODETIC_DATUM_GEODETIC_CRS_900914',NULL,0);
INSERT INTO usage 
VALUES('EPSG','USAGE_GEODETIC_CRS_900914','geodetic_crs','EPSG','GEODETIC_CRS_900914','PROJ','EXTENT_UNKNOWN','PROJ','SCOPE_UNKNOWN');
INSERT INTO projected_crs VALUES('EPSG','900914','unknown 
(900914)','',NULL,NULL,'EPSG','GEODETIC_CRS_900914',NULL,NULL,'+proj=merc 
+a=6371001 +b=6371001 +lat_ts=0.0 +lon_0=0.0 +x_0=-4448 +y_0=-4448 
+k=1.0 +units=m +over +nadgrids=@null +no_defs',0);
INSERT INTO usage 
VALUES('EPSG','USAGE_PROJECTED_CRS_900914','projected_crs','EPSG','900914','PROJ','EXTENT_UNKNOWN','PROJ','SCOPE_UNKNOWN');

you'll get:

PROJ_DATA=/tmp bin/projinfo EPSG:900914
PROJ.4 string:
+proj=merc +a=6371001 +b=6371001 +lat_ts=0 +lon_0=0 +x_0=-4448 
+y_0=-4448 +k=1 +units=m +nadgrids=@null +wktext +no_defs +type=crs

WKT2:2019 string:
PROJCRS["unknown (900914)",
     BASEGEOGCRS["unknown",
         DATUM["unknown using nadgrids=@null",
             ELLIPSOID["unknown",6371001,0,
                 LENGTHUNIT["metre",1]]],
         PRIMEM["Greenwich",0,
             ANGLEUNIT["degree",0.0174532925199433]]],
     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",-4448,
             LENGTHUNIT["metre",1],
             ID["EPSG",8806]],
         PARAMETER["False northing",-4448,
             LENGTHUNIT["metre",1],
             ID["EPSG",8807]]],
     CS[Cartesian,2],
         AXIS["(E)",east,
             ORDER[1],
             LENGTHUNIT["metre",1]],
         AXIS["(N)",north,
             ORDER[2],
             LENGTHUNIT["metre",1]],
     ID["EPSG",900914]]

Even

Le 12/04/2024 à 23:24, Stephen Woodbridge via gdal-dev a écrit :
> Hi all,
>
> I've been gone for a while, but got called back to update a site I 
> built and need to move from proj4 to proj 8 on Ubuntu 22.04. In the 
> past I just added the following to /usr/share/proj/epsg
>
> # HYCOM Mercator projection
> <900914> +proj=merc +a=6371001 +b=6371001 +lat_ts=0.0 +lon_0=0.0 
> +x_0=-4448 +y_0=-4448 +k=1.0 +units=m +over +nadgrids=@null +no_defs  <>
>
> and was able to access it in gdal, mapserver, postgis, etc with 
> "EPSG:900914"
>
> How does one do that with the new system?
>
> Thanks,
>   -Steve W
>
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient> 
> 	Virus-free.www.avast.com 
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient> 
>
>
> <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/gdal-dev

-- 
http://www.spatialys.com
My software is free, but my time generally not.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20240414/dec40c70/attachment.htm>


More information about the gdal-dev mailing list