Created
March 27, 2017 06:43
-
-
Save debboutr/79f0bec7e2cf5561fbcaeab1e0f7d355 to your computer and use it in GitHub Desktop.
Get WKT from either epsg.io OR spatialreference.org
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def getWKTio(epsg) : | |
import urllib | |
from bs4 import BeautifulSoup | |
html = 'http://epsg.io/{}'.format(epsg) | |
r = urllib.urlopen(html) | |
data = r.read() | |
soup = BeautifulSoup(data, "html") | |
for tag in soup.find_all('pre'): | |
if tag.get('id') == 's_esriwkt_text': | |
return tag.contents | |
getWKTio(4326) | |
def getPRJwkt(epsg): | |
""" | |
Grab an WKT version of an EPSG code | |
usage getPRJwkt(4326) | |
This makes use of links like | |
http://spatialreference.org/ref/epsg/4326/prettywkt/ | |
""" | |
import urllib | |
sr = "http://spatialreference.org" | |
f=urllib.urlopen(sr + "/ref/epsg/{0}/prettywkt/".format(epsg)) | |
return (f.read()) | |
getPRJwkt(5070) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment