Top

pycrs.utils module

Misc utility functions related to crs formats and online services.

Functions

def build_crs_table(

savepath)

Build crs table of all equivalent format variations by scraping spatialreference.org. Saves table as tab-delimited text file. NOTE: Might take a while.

Arguments:

  • savepath: The absolute or relative filepath to which to save the crs table, including the ".txt" extension.

def crscode_to_string(

codetype, code, format)

Lookup crscode and return in specified format. Uses epsg.io for epsg code, or spatialreference.org for esri or sr codes.

Arguments:

  • codetype: "epsg", "esri", or "sr-org".
  • code: The code.
  • format: The crs format of the returned string. One of "ogcwkt", "esriwkt", or "proj4", but also several others...

Returns:

  • Crs string in the specified format.

def search(

text)

Searches epsg.io for a projection name or area of use. Functions as a generator that yields each result dictionary.

NOTE: a new url request has to be made every 10 results, so be careful looping through all the results if not necessary.

Each result dict include the following most relevant key entries (for more, see https://github.com/maptiler/epsg.io): - code - name - kind - bbox - wkt - proj4

def search_area(

area)

Searches epsg.io for a crs by the country or area of use. Functions as a generator that yields each result dictionary. See more details in search() docstring.

def search_name(

name)

Searches epsg.io for a crs by name. Functions as a generator that yields each result dictionary. See more details in search() docstring.

def wkt_to_epsg(

wkt)

Lookup the EPSG code of a particular WKT projection.

Returns the results dictionary from http://prj2epsg.org, with the following key entries:

  • exact: true if the provided WKT could be matched exactly to one entry in the EPSG database, false otherwise
  • totalHits: total amount of potential results found in the database. The actual codes list is always capped to 20
  • error: reports WKT parsing errors, if any
  • codes: a list of EPSG code objects, each one containg:
    • code: the EPSG code
    • name: the coordinate reference system name
    • url: the full url to the EPSG code description page