Skip to content

Instantly share code, notes, and snippets.

@kirkmawa
Created February 23, 2018 14:44
Show Gist options
  • Save kirkmawa/fc25592e094bfcf490b3e88a1e6b5140 to your computer and use it in GitHub Desktop.
Save kirkmawa/fc25592e094bfcf490b3e88a1e6b5140 to your computer and use it in GitHub Desktop.
CGI script to convert lat/long to cartesian coordinates for the Lambert Conformal Conic projection
#!/usr/bin/env python
# This file gets raw cartesian coordinates for the Lambert Conformal Conic projection given a latitude/longitude pair.
# It is used to cross reference a user's location with an ESRI shapefile database.
import os
from urlparse import parse_qs
print "Content-type: text/html\n\n"
from pyproj import Proj
p = Proj(proj='lcc',ellps='WGS84')
qs = parse_qs(os.environ['QUERY_STRING'])
cdt = p(qs['lon'][0], qs['lat'][0])
print '{0},{1}'.format(cdt[0], cdt[1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment