wktstring

Well-known text string

Description

example

str = wktstring(crs) returns the well-known text (WKT) string representation of the specified projected or geographic coordinate reference system. By default, wktstring uses the WKT 2 standard and does not apply formatting.

example

str = wktstring(crs,Name,Value) specifies version and formatting options using one or more Name,Value pair arguments. For example, 'Format','formatted' includes line breaks and indentations in the WKT string.

Examples

collapse all

Return information about projected data as a RasterInfo object. Find the projected CRS for the data by accessing its CoordinateReferenceSystem property.

info = georasterinfo('MtWashington-ft.grd');
p = info.CoordinateReferenceSystem;

Return the WKT as a string.

str = wktstring(p)
str = 
"PROJCRS["UTM Zone 19, Northern Hemisphere",BASEGEOGCRS["NAD27",DATUM["North American Datum 1927",ELLIPSOID["Clarke_1866",6378206.4,294.978698213898,LENGTHUNIT["metre",1]],ID["EPSG",6267]],PRIMEM["Greenwich",0,ANGLEUNIT["Degree",0.0174532925199433]]],CONVERSION["UTM zone 19N",METHOD["Transverse Mercator",ID["EPSG",9807]],PARAMETER["Latitude of natural origin",0,ANGLEUNIT["Degree",0.0174532925199433],ID["EPSG",8801]],PARAMETER["Longitude of natural origin",-69,ANGLEUNIT["Degree",0.0174532925199433],ID["EPSG",8802]],PARAMETER["Scale factor at natural origin",0.9996,SCALEUNIT["unity",1],ID["EPSG",8805]],PARAMETER["False easting",500000,LENGTHUNIT["Meter",1],ID["EPSG",8806]],PARAMETER["False northing",0,LENGTHUNIT["Meter",1],ID["EPSG",8807]],ID["EPSG",16019]],CS[Cartesian,2],AXIS["easting",east,ORDER[1],LENGTHUNIT["Meter",1]],AXIS["northing",north,ORDER[2],LENGTHUNIT["Meter",1]]]"

Return information about geographic data as a RasterInfo object. Find the geographic CRS for the data by accessing its CoordinateReferenceSystem property.

[Z,R] = readgeoraster('n39_w106_3arc_v2.dt1');
g = R.GeographicCRS;

Return the WKT as a string.

wkt = wktstring(g)
wkt = 
"GEOGCRS["WGS 84",DATUM["World Geodetic System 1984",ELLIPSOID["WGS 84",6378137,298.257223563,LENGTHUNIT["metre",1]]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199433]],CS[ellipsoidal,2],AXIS["geodetic latitude (Lat)",north,ORDER[1],ANGLEUNIT["degree",0.0174532925199433]],AXIS["geodetic longitude (Lon)",east,ORDER[2],ANGLEUNIT["degree",0.0174532925199433]],ID["EPSG",4326]]"

Return information about a data set as a RasterInfo object. Find the projected CRS for the data by accessing the CoordinateReferenceSystem property.

info = georasterinfo('MtWashington-ft.grd');
p = info.CoordinateReferenceSystem;

Return the WKT as a formatted string by using the 'Format' name-value pair.

str = wktstring(p,'Format','formatted')
str = 
    "PROJCRS["UTM Zone 19, Northern Hemisphere",
         BASEGEOGCRS["NAD27",
             DATUM["North American Datum 1927",
                 ELLIPSOID["Clarke_1866",6378206.4,294.978698213898,
                     LENGTHUNIT["metre",1]],
                 ID["EPSG",6267]],
             PRIMEM["Greenwich",0,
                 ANGLEUNIT["Degree",0.0174532925199433]]],
         CONVERSION["UTM zone 19N",
             METHOD["Transverse Mercator",
                 ID["EPSG",9807]],
             PARAMETER["Latitude of natural origin",0,
                 ANGLEUNIT["Degree",0.0174532925199433],
                 ID["EPSG",8801]],
             PARAMETER["Longitude of natural origin",-69,
                 ANGLEUNIT["Degree",0.0174532925199433],
                 ID["EPSG",8802]],
             PARAMETER["Scale factor at natural origin",0.9996,
                 SCALEUNIT["unity",1],
                 ID["EPSG",8805]],
             PARAMETER["False easting",500000,
                 LENGTHUNIT["Meter",1],
                 ID["EPSG",8806]],
             PARAMETER["False northing",0,
                 LENGTHUNIT["Meter",1],
                 ID["EPSG",8807]],
             ID["EPSG",16019]],
         CS[Cartesian,2],
             AXIS["easting",east,
                 ORDER[1],
                 LENGTHUNIT["Meter",1]],
             AXIS["northing",north,
                 ORDER[2],
                 LENGTHUNIT["Meter",1]]]"

Return information about a data set as a RasterInfo object. Find the projected CRS for the data by accessing the CoordinateReferenceSystem property. Return the WKT as a string using the WKT 1 standard.

info = georasterinfo('MtWashington-ft.grd');
p = info.CoordinateReferenceSystem;
str = wktstring(p,'Version','wkt1');

Create a projection file called mtwash.prj and open it for writing using the fopen function. Then, print the WKT to the file using the fprintf function. Close the file.

fileID = fopen('mtwash.prj','w');
fprintf(fileID,str);
fclose(fileID);

Input Arguments

collapse all

Coordinate reference system, specified as a projcrs object or geocrs object.

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: 'Version','wkt1' specifies the WKT 1 standard for the output well-known text string.

Format of the WKT string, specified as the comma-separated pair consisting of 'Format' and one of these values:

  • 'compact' – Do not include formatting.

  • 'formatted' – Include line breaks and indentations.

Example: 'Format','formatted'

Data Types: char | string

WKT version, specified as the comma-separated pair consisting of 'Version' and one of these values:

Example: 'Version','wkt1'

Data Types: char | string

See Also

Objects

Introduced in R2020b