EPSG Tables =========== VERSION: 9.2 The .csv files in this directory are an extract of tables from the EPSG projection database in CSV (comma separated value) format. These same files come with the source distribution in the libgeotiff/csv directory. Detailed information on the EPSG database can be found at: http://www.epsg.org/ Most EPSG tables have been dumped to csv. Unlike earlier dumps (4.3) these are intended to be "true" csv files. In particular quotes within quoted strings are doubled to escape them, rather than using backslash quoting. Newlines may appear within quoted field values (as real raw newline characters). All table names are converted to lower case, and spaces replaced with underscores to make them more easily worked with. In addition to the EPSG tables dumped to csv, the following additional items are present: stateplane.csv: my own effort to related "USGS" state plane numbers with their currently preferred EPSG coordinate reference system counterpart. pcs.csv: An attempt to collect most information about a PCS, including the projection parameters into one fast access file. gcs.csv: An attempt to collect most information about a GCS, including the WGS84 shift parameters (if there is only one path in EPSG). projop_wparm.csv: Projection operations with projection parameters. Essentially the coordinate_operation.csv table with the parameters from coordinate_operation_parameter_values.csv appended to each record. build_pcs.py: a python script to build pcs.csv and gcs.csv from the other EPSG files. csv_tools.py: supportting python functions for build_pcs.py. csv.txt: A definition of the csv format. Libgeotiff uses the following tables. The rest are present for completeness. pcs.csv gcs.csv ellipsoid.csv prime_meridian.csv unit_of_measure.csv datum.csv projop_wparm.csv Overrides --------- In some cases we wish to override the EPSG definition - often to provide a single preferred towgs84 transformation for datums. Overrides to GCS and PCS definitions should be put in the files: gcs.override.csv pcs.override.csv vertcs.override.csv esri_datum_override.csv in a format the same as the pcs.csv and gcs.csv files. Additions to these tables should normally be accompanied by detailed comments and references to any relevant tickets. Note that we deliberately keep alterations separate from the EPSG definitions in gcs.csv and pcs.csv to avoid violating the EPSG distribution license which requires that the definitions be distributed in unaltered form. Generating CSV Files with Docker --------------------------------- The section below describes how to manually generate the EPSG definitions for GDAL, Proj.4, libgeotiff, and PostGIS. A Dockerfile encapsulating the entire process is available in csv/Dockerfile To build using it, - cd into the csv/ directory, - edit it to point to the current URL of the EPSG database - download ESRI FileGDB SDK 1.3 and put in csv/filegdb_api_1_3-64.tar.gz - and build the image: docker build -t hobu/proj.4 . Once built (it will grind for a while, and it will build the latest Proj.4, GDAL, and libgeotiff in the process), copy the files out by running the container: ./extract_docker_artifacts.sh Then copy artifacts/* data into their respective project directories. Generating CSV Files -------------------- The csv files are generated from the Postgres dump provided by EPSG. 1) Load epsg database into postgres instance named "epsg". 1a) Insert a line "\encoding WIN1252" at start of the _Data_ sql file. 1b) Modify the _Tables_ sql file, changing every occurance of (254) to (300). This is to ensure that text fields are still big enough after Latin1 special characters are expanded into multi-byte UTF8 characters. 1c) run "load_pg.sh" in the directory where the .sql files are found. eg. ../load_pg.sh >& log 1d) Make sure you search the log file for "error" in case something went wrong. 2) Dump the database to .csv files in the libgeotiff/csv directory. python pg_to_csv.py Puts the results in the out directory. After some inspection move them into this directory (libgeotiff/csv). 3) Build the pcs.csv, gcs.csv, compdcs.csv and geoccs.csv files. python build_pcs.py 4) Update this file to note the current version of the ESPG database being used. 5) Commit the changes in libgeotiff repository. It may be necessary to manually remove cntl-M (DOS LF) from some files, such as coordinate_operation_method.csv, if svn balks with a the error: svn: Inconsistent line ending style Generating Downstream Products - GDAL ------------------------------------- Rebuild gdal_datum.csv. Unfortunately this depends on a set of ArcGIS .prj files that are usually only available on Frank's machine. But it can also work with an alternate method if you have OGR configured with both the FileGDB and OpenFileGDB drivers (GDAL >= 1.11) : python add_esri_column.py Copy the following files from libgeotiff/csv to gdal/data: coordinate_axis.csv ellipsoid.csv gcs.csv gcs.override.csv gdal_datum.csv pcs.csv pcs.override.csv prime_meridian.csv projop_wparm.csv stateplane.csv unit_of_measure.csv geoccs.csv compdcs.csv datum_shift.csv vertcs.csv vertcs.override.csv svn commit these files. Generating Downstream Products - PROJ.4 --------------------------------------- From the GDAL distribution (do after updating GDAL) do the following in the gdal/data directory (with GDAL Python scripts operational): rm epsg epsg_tr.py --config OVERRIDE_PROJ_DATUM_WITH_TOWGS84 FALSE -proj4 -skip -list gcs.csv > epsg epsg_tr.py --config OVERRIDE_PROJ_DATUM_WITH_TOWGS84 FALSE -proj4 -skip -list pcs.csv >> epsg epsg_tr.py --config OVERRIDE_PROJ_DATUM_WITH_TOWGS84 FALSE -proj4 -skip -list geoccs.csv >> epsg epsg_tr.py --config OVERRIDE_PROJ_DATUM_WITH_TOWGS84 FALSE -proj4 -skip -list compdcs.csv >> epsg Commit this in proj/nad. Generating Downstream Products - PostGIS ---------------------------------------- From the GDAL distribution (do after updating GDAL) do the following in the gdal/data directory (with GDAL Python scripts operational): rm spatial_ref_sys.sql epsg_tr.py --config OVERRIDE_PROJ_DATUM_WITH_TOWGS84 FALSE -postgis -skip -list gcs.csv > spatial_ref_sys.sql epsg_tr.py --config OVERRIDE_PROJ_DATUM_WITH_TOWGS84 FALSE -postgis -skip -list pcs.csv >> spatial_ref_sys.sql epsg_tr.py --config OVERRIDE_PROJ_DATUM_WITH_TOWGS84 FALSE -postgis -skip -list geoccs.csv >> spatial_ref_sys.sql epsg_tr.py --config OVERRIDE_PROJ_DATUM_WITH_TOWGS84 FALSE -postgis -skip -list compdcs.csv >> spatial_ref_sys.sql