Created
August 29, 2019 21:32
-
-
Save alpha-beta-soup/cdea8f8a0b089db2c7f6778c6d12a5a8 to your computer and use it in GitHub Desktop.
Cartopy CRS definition for NZTM2000
This file contains 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
import cartopy | |
import shapely.geometry as sgeom | |
class NZTM(cartopy.crs.TransverseMercator): | |
def __init__(self): | |
''' | |
https://epsg.io/2193 | |
https://www.linz.govt.nz/data/geodetic-system/datums-projections-and-heights/geodetic-datums/new-zealand-geodetic-datum-2000-nzgd2000 | |
''' | |
inverse_flattening = 298.257222101 | |
semimajor_axis = 6378137 | |
semiminor_axis = -((inverse_flattening*semimajor_axis)-semimajor_axis) | |
globe = cartopy._crs.Globe( | |
semimajor_axis=semimajor_axis, | |
semiminor_axis=semiminor_axis | |
) | |
super(NZTM, self).__init__(central_longitude=173, | |
central_latitude=0, | |
scale_factor=0.9996, | |
false_easting=1600000, | |
false_northing=10000000, | |
globe=globe) | |
@property | |
def boundary(self): | |
x0, x1 = self.x_limits | |
y0, y1 = self.y_limits | |
return sgeom.LineString([(x0, y0), (x0, y1), | |
(x1, y1), (x1, y0), | |
(x0, y0)]) | |
@property | |
def x_limits(self): | |
return (827933.23, 3195373.59) | |
@property | |
def y_limits(self): | |
return (3729820.29, 7039943.58) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For example, in a Flask application, to return a PNG of NZ in NZTM to the client at
http://host:port/map
: