Research on QGIS WKT custom coordinate system and its comparison with ArcGIS

The commonly used projections in the national territory of my country are the bi-standard parallel conic projections, such as the equal-area Albers projection or the equal-angle Lambert projection. The geographic coordinate reference system used varies according to the time of data production, such as the early Beijing 54 coordinate system and Xi’an 80 coordinate system, and the national 2000 geodetic coordinate system that has been widely adopted in recent years. This article uses the 2015 provincial administrative division data obtained from the Resource and Environmental Science and Data Center of the Chinese Academy of Sciences as an example. The data is in the SHP format and uses the Albers projection based on the Beijing 54 coordinate system.

 

This combination of double standard latitude, central meridian selected according to the mapping area, geographic coordinate system, and projection method does not generally exist in the predefined coordinate systems of most GIS software. You need to define the coordinate system yourself, otherwise the layer will be Data marked as an unrecognized coordinate system often has problems such as calculation errors or failure to overlay with layers from other sources during use.

 

 

The custom projection function of QGIS is located in the menu [Settings] -> [Custom Projection], click and pop up the custom coordinate reference system dialog box:

 

 

Click the button in the upper right corner to add a new custom coordinate system, give the custom coordinate system a name in the name text box, select the description format of the coordinate system (WKT or Proj), and specify the coordinate system parameters in the parameter box. Then the creation of the custom coordinate system can be completed.

 

QGIS custom coordinate system supports WKT and Proj two description formats. Because Proj is too concise and is a lossy description, QGIS officially recommends using WKT language to describe the definition of the coordinate system.

 

Well-known text (WKT for short) is a text markup language developed by the Open Geospatial Consortium (OGC), which expresses geometric objects in geographic space with a concise grammar that is easy for people to read. This way of expressing geometric figures in words is very popular because of its advantages such as easy understanding, high readability, easy storage and easy sharing, and is widely used in coordinate system definition, coordinate transformation parameter description and so on.

 

The term " WKT coordinate system definition " used in this article specifically refers to the coordinate system definition string described in WKT markup language. Unless otherwise specified, the term " WKT coordinate system definition " in this article has this meaning.

 

However, as can be seen from the above figure, the custom coordinate system interface of QGIS is relatively simple and the operating experience is not very friendly.

 

Customizing the coordinate system itself is a complicated process. The parameters that need to be set include ellipsoid, datum plane, projection method, standard latitude, central meridian, etc. Commercial GIS software usually decomposes this process into several easy-to-use operation step guides. Users only need to click and enter the corresponding parameters. For example, the process of customizing the coordinate system in ArcMap 10.2 is as follows:

 

 

For ordinary users, the operation guide interface can greatly improve the user experience compared to the way of manually entering the code. Because whether you use WKT format or Proj format, to construct a new coordinate system definition, you need to understand the syntax structure, keywords, and values. These are almost impossible for people who do not understand the relevant language specifications and want to use QGIS to quickly map.

 

The question finally focused on how to obtain the WKT coordinate system definition description string. In addition to the hope that with the QGIS version update, the development team will provide a more friendly operation method for customizing the coordinate system. This article compares the similarities and differences between the QGIS and ArcGIS WKT coordinate system definitions. , It is concluded that by importing the WKT coordinate system definition string in the ArcGIS PRJ file, the problem that the WKT coordinate system definition string is difficult to construct in the QGIS custom coordinate system operation under the current situation is solved.

 

 01 Import the ArcGIS WKT coordinate system definition into QGIS

 

If the coordinate system of a layer is correctly defined in ArcGIS, the .PRJ file with the same name as the SHP file is a coordinate system definition text file that conforms to the WKT language specification. You can use a text editor to open and view its content. For example, in 2015 administrative division data, the content of its .PRJ file is:

 

 

Is this WKT coordinate system definition compatible with QGIS's WKT coordinate system definition? If it is compatible, it can be used as the WKT parameter of the QGIS custom projection coordinate system. In order to save everyone's reading time, I first put the conclusion here: QGIS is compatible with ArcGIS's WKT coordinate system definition string. You can directly copy the content of the .PRJ file as the WKT parameter of the new QGIS coordinate system.

 

The specific steps are as follows:

 

Click the menu [Settings] -> [Custom Projection] to open the custom coordinate system dialog box, the import process is as follows:

 

 

Return to the main window of the map, click the coordinate system area in the lower right corner, the coordinate system selection dialog box pops up, find the newly created coordinate system in the user-defined area, click [OK], and QGIS can recognize the coordinate system.

 

 

Next, let's see why QGIS is compatible with ArcGIS's WKT coordinate system definition string. To answer this question, let's start with the difference between the two.

 

 02 The difference between QGIS and ArcGIS WKT coordinate system definition

 

Open a projected coordinate system from the QGIS coordinate system selector, and observe the structure and value of the WKT coordinate system definition generated by the two software (here, select the custom coordinate system generated after importing the PRJ with the sample data for comparison):

 

 

Comparing the two strings, you can see that although both are defined in the WKT coordinate system, there are many differences between the two, which are shown in:

 

1. Different keywords

 

In the ArcGIS PRJ file, the definition of the WKT coordinate system starts with "PROJCS", indicating that the coordinate system is a projected coordinate system. The corresponding QGIS projection coordinate system uses the keyword "PROJCRS", which has an additional letter "R". Each projected coordinate system is based on the geographic coordinate system. In ArcGIS, the geographic coordinate system uses the keyword "GEOGCS", and QGIS uses the keyword "BASEGEOGCRS". The detailed comparison is as follows:

 

 

2. Different structure

 

In the definition of ArcGIS WKT coordinate system, the attributes of the projected coordinate system "PROJCS" include name, geographic coordinate system (datum, ellipsoid), central meridian, projection name and projection parameters, and coordinate system unit.

 

In the definition of WKT coordinate system of QGIS, the attributes of the projected coordinate system "PROJCRS" include name, geographic coordinate system (datum, ellipsoid), central meridian, name of projection method, projection method, projection parameters, plane coordinate system, and application scope description , And an explanation of the unit used is added after each numerical parameter. For example, the radius of an ellipsoid uses the length unit meter, which is expressed as "LENGTHUNIT["metre",1]" in the string.

 

3. Different names

 

Many elements in the definition of the WKT coordinate system have name attributes, such as the name of the projected coordinate system, the name of the geographic coordinate system, and the name of the datum. Each GIS manufacturer handles names differently. The early WKT1 standard did not clearly define the value of the name, which led to inconsistencies in the implementation of various manufacturers, which affected the data exchange. The new version of the standard WKT2 requires the value of the name to be based on EPSG.

 

In general, the definition of the WKT coordinate system of QGIS and ArcGIS is different, mainly due to the different WKT coordinate system definition standards.

 

At present, the definition of WKT coordinate system processed by GIS software is based on the following standards:

 

[1] ISO 19162:2019 , Geographic information — Well-known text representation of coordinate reference systems, the current standard for the definition of WKT coordinate system, merged the part of WKT coordinate system definition in ISO 19111:2019, referred to as WKT2.

 

[2] ISO 19111:2019 , Geographic information — Referencing by coordinates, the standard based on the definition and conversion of the Proj coordinate system, the open source project. The definition of the WKT coordinate system has been merged into ISO 19162:2019.

 

[3] OGC 01-009/ISO 19125-1:2004 , Coordinate Transformation Services, Revision 1.00, released in 2001, is an upgraded version of OGC 99-049, referred to as WKT1.

 

[4] OGC 99-049 , Simple Features Specification For SQL, Revision 1.1, WKT coordinate system definition standard first edition.

 

According to relevant information, ArcGIS is mainly based on the WKT1 coordinate system definition standard, namely OGC 01-009/ISO 19125-1:2004; QGIS conforms to the WKT2 coordinate system definition standard, namely ISO 19162:2019.

 

The WKT2 standard makes clear provisions for backward compatibility: GIS software that meets the WKT2 standard is required to be able to read and import the WKT1 coordinate system definition, but it is not required to output the WKT1 coordinate system definition, which explains why QGIS can read and import The definition of the WKT coordinate system of the ArcGIS version.

 

 03   common GIS software WKT coordinate system definitions follow the standards

 

  • QGIS/GDAL/OGR uses WKT language as the built-in coordinate system definition and description, and the import strives to be compatible with the old and new standards and ESRI format, according to WKT2 (ISO 19162:2019) standard conversion and export.

 

  • ESRI , in line with WKT1 (OGC 01-009) standard.

 

  • PostGIS , WKT coordinate system definition is generated by OGR and stored in the spatial_ref_sys table, so it follows the same standard as OGR.

 

  • FME , based on OGR, realizes the read and write operations of WKT coordinate system definition. Like QGIS/GDAL/OGR , it strives to be compatible with the new and old standards and the WKT coordinate system definition in ESRI format.

 

  • SuperMap SuperMap desktop version , the coordinate system export format is a custom XML document, and WKT coordinate system definition export is not yet supported. (It may also be that I didn't find it. If this does not match the actual situation, please leave a message to correct it.)

 

 04 Analysis of the processing mechanism of QGIS and ArcGIS on the definition of WKT coordinate system

 

  • QGIS's processing mechanism for the definition of WKT coordinate system

 

QGIS's processing of the definition of the WKT coordinate system is divided into two parts: Import and Export. Import and receive WKT format strings, split and recognize them, and convert them into QGIS coordinate reference system objects (QgsCoordinateReferenceSystem); export It converts the QGIS coordinate reference system object into a string conforming to the WTK2 standard and returns it to the user.

 

A. Import process

 

The conversion from the WKT coordinate system definition string to the QGIS coordinate reference system object is mainly realized by the createFromWktInternal() of the QgsCoordinateReferenceSystem class. It is necessary to pass in the WKT coordinate system definition string and the description information corresponding to the string, that is, the coordinates we see Department name, the process is as follows:

 

1. Determine whether the WKT coordinate system definition string is empty. If it is empty, the import fails.

 

2. Look up the WKT coordinate system definition string object in the cache.

 

3. If a match is found in the cache, the corresponding coordinate reference system object is assigned to the current coordinate reference system instance.

 

4. If there is no match in the cache, determine the source vendor defined by the WKT coordinate system. The currently compatible vendors are: epsg|esri|osgeo|ignf|zangi|iau2000|postgis|internal|user, and the corresponding standards are used according to the source vendors. Parse the incoming WKT coordinate system definition string to generate a coordinate reference system object.

 

5. If the source manufacturer cannot be matched, it will be processed according to the general WKT coordinate system definition string. Determine the currently used Proj version, the main version is greater than or equal to 6, then use the Proj4 library to find objects that match the definition of the incoming WKT coordinate system.

 

6. If the Proj version is less than 6, use the ORG library to find the definition of the incoming WKT coordinate system.

 

7. If the above process does not find a predefined coordinate system that matches the definition of the incoming WKT coordinate system, a new custom coordinate reference system is created and stored in the local custom coordinate system database.

 

Still taking the import process of the coordinate system definition of the provincial administrative division data in 2015 as an example, the corresponding PRJ file WKT string is as follows:

 

PROJCS["Krasovsky_1940_Albers",GEOGCS["GCS_Krasovsky_1940",DATUM["D_Krasovsky_1940",SPHEROID["Krasovsky_1940",6378245.0,298.3]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Albers"],PARAMETER["False_Easting",0.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",105.0],PARAMETER["Standard_Parallel_1",25.0],PARAMETER["Standard_Parallel_2",47.0],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]]

 

 

Taking the definition of the WKT coordinate system as a parameter, QGIS first makes a basic judgment on the parameter (whether it is empty), and then starts the import process:

 

The first step is to find the string in the cache, where the cache match fails.

 

The second step is to determine the source vendor. QGIS directly uses string search to match the source manufacturer. For example, if the character substring "ESRI" is found in the incoming WKT coordinate system definition string, it will judge that the definition comes from ArcGIS and parse it according to ArcGIS standards to obtain the coordinate reference system. Object. There is no compatible manufacturer identification string here, so it is parsed according to the general WKT coordinate system definition.

 

The third step, if the current Proj version, the main version is greater than or equal to 6, use the Proj library to convert the WKT coordinate system definition to the Proj definition format to generate the coordinate reference system object. The latest version of the current Proj library is 7.2. As long as QGIS is updated frequently, the version of the Proj library is generally greater than or equal to 6. That is to say, the definition of the WKT coordinate system that does not indicate the source manufacturer is generally handled by the Proj library. When the Proj version is lower than 6, use the GDAL/OGR library to parse the incoming WKT coordinate system definition parameters.

 

Whether it is the Proj library or the GDAL/OGR library, the current WKT standard is the latest WKT2 (ISO 19162:2019).

 

The fourth step, if the above process does not find a predefined coordinate system that matches the definition of the incoming WKT coordinate system, a new custom coordinate reference system is created and stored in the local custom coordinate system database.

 

The fifth step, if none of the above processes can resolve the incoming WKT coordinate system definition, the import fails, and detailed error information is printed in the message window.

 

After the import is successful, in the custom coordinate system grouping of the coordinate system selection dialog box, you will see the definition of the WKT coordinate system output according to the WTK2 standard after the analysis is successful:

 

PROJCRS["Krasovsky_1940_Albers",    BASEGEOGCRS["Unknown datum based upon the Krassowsky 1940 ellipsoid",        DATUM["Not specified (based on Krassowsky 1940 ellipsoid)",            ELLIPSOID["Krassowsky 1940",6378245,298.3,                LENGTHUNIT["metre",1]],            ID["EPSG",6024]],        PRIMEM["Greenwich",0,            ANGLEUNIT["Degree",0.0174532925199433]]],    CONVERSION["unnamed",        METHOD["Albers Equal Area",            ID["EPSG",9822]],        PARAMETER["Latitude of false origin",0,            ANGLEUNIT["Degree",0.0174532925199433],            ID["EPSG",8821]],        PARAMETER["Longitude of false origin",105,            ANGLEUNIT["Degree",0.0174532925199433],            ID["EPSG",8822]],        PARAMETER["Latitude of 1st standard parallel",25,            ANGLEUNIT["Degree",0.0174532925199433],            ID["EPSG",8823]],        PARAMETER["Latitude of 2nd standard parallel",47,            ANGLEUNIT["Degree",0.0174532925199433],            ID["EPSG",8824]],        PARAMETER["Easting at false origin",0,            LENGTHUNIT["metre",1],            ID["EPSG",8826]],        PARAMETER["Northing at false origin",0,            LENGTHUNIT["metre",1],            ID["EPSG",8827]]],    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]]]]

 

 

Since the definition of the WKT coordinate system imported by the demonstration data cannot match the original predefined coordinate system, a new custom coordinate system is generated, and the corresponding record of the created custom coordinate system can also be found in the local database.


The location of the local database is generally stored in C:\Users\Users\AppData\Roaming\QGIS\QGIS3\profiles\default\qgis.db. This is a SQLite database. Open it and you can see a total of four tables: tbl_bookmarks (storage space Bookmark), tbl_ellipsoid (predefined ellipsoid), tbl_projection (store projection method name, alias and other information), tbl_srs (store user-defined coordinate system), query tbl_srs table to see our custom coordinate system:

 

 

B. Export process

 

The export process is relatively simple. According to the WKT standard version that needs to be output, whether there is a line break and the number of indented spaces, the attributes of the coordinate reference system are combined into a string that meets the WKT standard by keywords and values. To the user.

 

  • Support the exported WKT standard

 

For compatibility reasons, QGIS divides WKT strings into 11 types:

 

 

  • ArcGIS processing the definition of WKT coordinate system

 

As mentioned above, the WKT output format of ArcGIS is WKT1, which conforms to the OGC 01-009 standard. The standard was released in 1999 and revised in 2001. There are some ambiguities in the definition, which leads to deviations in the implementation of the standard by GIS.

 

E.g:

 

In ESRI WKT, the values ​​of node names are generally connected by underscores, while the WKT1 version of GDAL/OGR is separated by spaces.

 

The name of the datum surface (DATUM) adds "D_" to the beginning of the EPSG name.

 

The name of the PARAMETER element is different. For example, the name of the first standard parallel is "Latitude of 1st standard parallel" in GDAL/OGR, and the parameter name in ESRI is changed to "standard_parallel_1". In addition, the first letter of the parameter name of GDAL/OGR is capitalized, and ESRI uses all lowercase letters. In fact, according to the OGC standard, keywords are not case-sensitive, but parameter values ​​(content in quotation marks) are case-sensitive.

 

The value of the unit UNIT element is capitalized in GDAL/OGR, such as "Degree", while ESRI is all lowercase "degree".

 

……

 

There are also some unmentioned differences. For example, for the Lambert projection, ESRI regards single standard latitude and double standard latitude as one projection type, which is only distinguished in terms of parameters, while GDAL/OGR is divided into two projections: LCC 1SP and LCC 2SP.

 

Melita Kennedy is the main member responsible for the development of ESRI map projection and datum module, and is also a member of the CRS WKT 2.0 standard drafting committee. According to her description of ESRI WKT processing methods on various occasions, we can roughly get the ArcGIS processing of WKT:

 

There are many ambiguities in the definition of the WKT1 standard, which hinders the sharing of the WTK coordinate system; she hopes to improve the implementation of WKT, and indeed supports WKT2 in ArcGIS 10.5.1 and ArcGIS pro 2.0, but The following note writes: Only implemented in GeoPackage.

 

Although ESRI WKT adds underscores to the object names and the values ​​of certain parameters to facilitate reading, in string comparisons (such as parameters and name strings), underscores and prefix strings "GCSE_" and "D_" are ignored. It is not case sensitive.

 

In order to be compatible with the WKT coordinate system of other manufacturers, ESRI maintains a comparison list of names and aliases, but does not disclose the list.

 

 05 Summary

 

As far as the custom coordinate system is concerned, QGIS is excellent in compatibility and openness, which is also the advantage of latecomers: developing code on mature standards will naturally avoid the pits that predecessors have stepped on. However, there is still a gap between QGIS and commercial GIS software in terms of user experience for custom coordinate system operations.

 

As the world leader in the GIS industry, ArcGIS has a large user group and produces and manages massive amounts of GIS data. In many cases, the way that ArcGIS handles some problems is the de facto standard of the GIS industry. Other GIS software generally needs to consider compatibility with ArcGIS in terms of compatibility. This situation should continue for some time. At the same time, as the open standards led by OGC and other institutions become more and more perfect, support for the latest open standards will become a compulsory course for all GIS software, which also means that the GIS industry is bound to move towards a more open and standard future.

 


 

Copyright Notice

 

This article welcomes reprinting, please indicate the source when reprinting.

 

 

Guess you like

Origin blog.csdn.net/QGISClass/article/details/112344243