Get WKT for coordinate system from epsg.io

A while ago I came across a post on GeospatialPython for retrieving the WKT for a coordinate system from Spatial Reference.

I adapted the script to retrieve the ESRI WKT for a coordinate system from epsg.io instead.

#
# @date 04/03/2015
# @author Cindy Williams
#
# Returns the ESRI WKT for a given EPSG from epsg.io
# Adapted from http://geospatialpython.com/2014/12/wkt-epsg-strings-made-easy.html
#
def getPRJwkt(epsg):
import urllib
sr_site = "http://epsg.io"
spatial_vendor = "esriwkt" # ESRI
f=urllib.urlopen("{0}/{1}.{2}".format(sr_site, epsg, spatial_vendor))
return (f.read())
print getPRJwkt(4326)
# returns GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]

view raw
getEsriWKT.py
hosted with ❤ by GitHub

There are a variety of output options, so it’s just a matter of changing spatial_vendor to suit your needs.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.