GRASS GIS 8 Programmer's Manual 8.4.1(2025)-45ca3179ab
Loading...
Searching...
No Matches
get_projinfo.c File Reference

GIS Library - Get projection info. More...

#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <stdio.h>
#include <grass/gis.h>
#include <grass/glocale.h>
Include dependency graph for get_projinfo.c:

Go to the source code of this file.

Macros

#define PERMANENT   "PERMANENT"
 

Functions

struct Key_Value * G_get_projunits (void)
 Gets units information for location.
 
struct Key_Value * G_get_projinfo (void)
 Gets projection information for location.
 
struct Key_Value * G_get_projepsg (void)
 Gets EPSG information for the current location.
 
char * G_get_projwkt (void)
 Get WKT information for the current location.
 
char * G_get_projsrid (void)
 Get srid (spatial reference id) for the current location.
 

Detailed Description

GIS Library - Get projection info.

(C) 1999-2014 by the GRASS Development Team

This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

Definition in file get_projinfo.c.

Macro Definition Documentation

◆ PERMANENT

#define PERMANENT   "PERMANENT"

Function Documentation

◆ G_get_projepsg()

struct Key_Value * G_get_projepsg ( void )

Gets EPSG information for the current location.

DEPRECATED: Use G_get_projsrid() instead.

Note: Allocated Key_Value structure should be freed by G_free_key_value().

Returns
pointer to Key_Value structure with key/value pairs
NULL when EPSG code is not defined for location

Definition at line 102 of file get_projinfo.c.

References G_debug(), G_file_name(), G_location(), G_projection(), G_read_key_value_file(), NULL, and PERMANENT.

Referenced by G_get_projinfo(), and G_get_projsrid().

◆ G_get_projinfo()

struct Key_Value * G_get_projinfo ( void )

Gets projection information for location.

Note: Allocated Key_Value structure should be freed by G_free_key_value().

Prints a warning if no projection information available.

Returns
pointer to Key_Value structure with key/value pairs
NULL on failure

Definition at line 61 of file get_projinfo.c.

References G_file_name(), G_find_key_value(), G_free_key_value(), G_get_projepsg(), G_location(), G_projection(), G_read_key_value_file(), G_set_key_value(), G_warning(), NULL, and PERMANENT.

Referenced by GPJ_get_datum_params(), and GPJ_get_ellipsoid_params().

◆ G_get_projsrid()

char * G_get_projsrid ( void )

Get srid (spatial reference id) for the current location.

Typically an srid will be of the form authority NAME:CODE, e.g. EPSG:4326

This srid is passed to proj_create() using PROJ or OSRSetFromUserInput() using GDAL. Therefore various other forms of srid are possible, e.g. in OSRSetFromUserInput():

  1. Well Known Text definition - passed on to importFromWkt().
  2. "EPSG:n" - number passed on to importFromEPSG().
  3. "EPSGA:n" - number passed on to importFromEPSGA().
  4. "AUTO:proj_id,unit_id,lon0,lat0" - WMS auto projections.
  5. "urn:ogc:def:crs:EPSG::n" - ogc urns
  6. PROJ.4 definitions - passed on to importFromProj4().
  7. filename - file read for WKT, XML or PROJ.4 definition.
  8. well known name accepted by SetWellKnownGeogCS(), such as NAD27, NAD83, WGS84 or WGS72.
  9. "IGNF:xxxx", "ESRI:xxxx", etc. from definitions from the PROJ database;
  10. PROJJSON (PROJ >= 6.2)
Returns
pointer to srid string
NULL when srid is not available for the current location

Definition at line 237 of file get_projinfo.c.

References G_asprintf(), G_chop(), G_debug(), G_fatal_error(), G_file_name(), G_find_key_value(), G_free(), G_free_key_value(), G_get_projepsg(), G_location(), G_projection(), and NULL.

◆ G_get_projunits()

struct Key_Value * G_get_projunits ( void )

Gets units information for location.

Note: Allocated Key_Value structure should be freed by G_free_key_value().

Prints a warning if no units information available.

Returns
pointer to Key_Value structure with key/value pairs
NULL on failure

Definition at line 32 of file get_projinfo.c.

References G_file_name(), G_location(), G_projection(), G_read_key_value_file(), G_warning(), NULL, and PERMANENT.

◆ G_get_projwkt()

char * G_get_projwkt ( void )

Get WKT information for the current location.

Returns
pointer to WKT string
NULL when WKT is not available for the current location

Definition at line 127 of file get_projinfo.c.

References G_chop(), G_debug(), G_fatal_error(), G_file_name(), G_free(), G_location(), G_projection(), and NULL.