anuga.Geo_reference
- class anuga.Geo_reference(zone=None, xllcorner=0.0, yllcorner=0.0, datum='wgs84', projection='UTM', units='m', false_easting=None, false_northing=None, hemisphere='undefined', epsg=None, NetCDFObject=None, ASCIIFile=None, read_title=None)[source]
Bases:
objectCoordinate reference system for an ANUGA domain.
- Variables:
zone (int) – UTM zone (1–60), or -1 (DEFAULT_ZONE) for non-UTM / arbitrary origin (e.g. a wave-tank simulation).
hemisphere (str) –
'southern','northern', or'undefined'.xllcorner (float) – X coordinate (easting) of the local origin relative to the UTM grid.
yllcorner (float) – Y coordinate (northing) of the local origin relative to the UTM grid.
datum (str) – Geodetic datum (default
'wgs84').projection (str) – Map projection (default
'UTM').units (str) – Units of measurement (default
'm').false_easting (int) – False easting offset (500 000 m for WGS84 UTM).
false_northing (int) – False northing offset (10 000 000 m southern, 0 m northern).
epsg (int or None) – EPSG code for the coordinate reference system. For WGS84 UTM this is auto-computed from zone and hemisphere (32600 + zone for northern, 32700 + zone for southern). Returns
Nonewhen the zone is DEFAULT_ZONE or the CRS cannot be determined.
- __init__(zone=None, xllcorner=0.0, yllcorner=0.0, datum='wgs84', projection='UTM', units='m', false_easting=None, false_northing=None, hemisphere='undefined', epsg=None, NetCDFObject=None, ASCIIFile=None, read_title=None)[source]
- Parameters:
zone (int, optional) – UTM zone (1–60) or -1 for no UTM framework. Inferred from epsg when possible if not supplied.
xllcorner (float, optional) – X (easting) of the local origin in metres.
yllcorner (float, optional) – Y (northing) of the local origin in metres.
datum (str, optional) – Geodetic datum. Default
'wgs84'.projection (str, optional) – Map projection. Default
'UTM'.units (str, optional) – Distance units. Default
'm'.false_easting (int, optional) – Override the default false easting for the hemisphere.
false_northing (int, optional) – Override the default false northing for the hemisphere.
hemisphere (str, optional) –
'southern','northern', or'undefined'. Inferred from epsg when possible if not supplied.epsg (int, optional) – EPSG code. For WGS84 UTM codes (32601–32660 northern, 32701–32760 southern), zone and hemisphere are inferred automatically when they have not been set explicitly.
NetCDFObject (file handle, optional) – Open NetCDF file to read geo-reference attributes from.
ASCIIFile (file handle, optional) – Open text file to read geo-reference attributes from.
read_title (str, optional) – Title line already read from ASCIIFile (pass if the caller has already consumed it).
Methods
__init__([zone, xllcorner, yllcorner, ...])change_points_geo_ref(points[, points_geo_ref])Change points to be absolute wrt new georef 'points_geo_ref'.
get_absolute(points)Given a set of points geo referenced to this instance, return the points as absolute values.
get_epsg()Return the EPSG code for this coordinate reference system.
Check if this georef has a defined hemisphere.
Get origin of this geo_reference.
get_relative(points)Convert points to relative measurement.
Get the X coordinate of the origin of this georef.
Get the Y coordinate of the origin of this georef.
get_zone()Get the zone of this georef.
Test if points in georef are absolute.
Return True if this geo-reference describes a real, located CRS.
read_ASCII(fd[, read_title])Set georef attribtes from open text file.
read_NetCDF(infile)Set georef attributes from open NetCDF file.
reconcile_zones(other)set_false_easting_northing([false_easting, ...])set_hemisphere(hemisphere)set_zone(zone)Set zone as an integer in [1,60] or -1 (DEFAULT_ZONE = unlocated).
write_ASCII(fd)Write georef attriutes to an open text file.
write_NetCDF(outfile)Write georef attributes to an open NetCDF file.
Attributes
EPSG code for this coordinate reference system.
- change_points_geo_ref(points, points_geo_ref=None)[source]
Change points to be absolute wrt new georef ‘points_geo_ref’.
points the points to change points_geo_ref the new georef to make points absolute wrt
Returns the changed points data. If the points do not have a georef, assume ‘absolute’ values.
- property epsg
EPSG code for this coordinate reference system.
For WGS84 UTM projections the code is computed automatically from zone and hemisphere when it has not been set explicitly:
Northern hemisphere:
32600 + zone(e.g. zone 55N → EPSG 32655)Southern hemisphere:
32700 + zone(e.g. zone 55S → EPSG 32755)
Returns
Nonewhen the zone is DEFAULT_ZONE (-1) or the CRS cannot be determined.- Return type:
int or None
- get_absolute(points)[source]
Given a set of points geo referenced to this instance, return the points as absolute values.
- get_epsg()[source]
Return the EPSG code for this coordinate reference system.
- Returns:
EPSG code, or
Noneif unknown.- Return type:
int or None
- get_relative(points)[source]
Convert points to relative measurement.
points Points to convert to relative measurements
Returns a set of points relative to the geo_reference instance.
This is the inverse of get_absolute().
- is_absolute()[source]
Test if points in georef are absolute.
Return True if xllcorner==yllcorner==0 indicating that points in question are absolute.
- is_located()[source]
Return True if this geo-reference describes a real, located CRS.
A geo-reference is located when either:
zone is a valid UTM zone (1–60), or
an EPSG code has been set (covers national grids, geographic CRS, and any other projected CRS that does not use UTM zones, e.g. EPSG:28992 Netherlands RD New, EPSG:27700 British National Grid).
A geo-reference with
zone == DEFAULT_ZONE(-1) and no EPSG code is unlocated — this is the case for wavetank or other hypothetical simulations with an arbitrary local origin.- Return type:
bool
- read_ASCII(fd, read_title=None)[source]
Set georef attribtes from open text file.
fd handle to open text file
- read_NetCDF(infile)[source]
Set georef attributes from open NetCDF file.
- Parameters:
infile (file handle) – Handle to an open NetCDF file.
- set_zone(zone)[source]
Set zone as an integer in [1,60] or -1 (DEFAULT_ZONE = unlocated).
A negative zone in [-60, -2] is interpreted as a southern hemisphere shorthand: the zone number is taken as abs(zone) and hemisphere is set to ‘southern’ when it is currently ‘undefined’.
Note: zone=-1 is reserved for DEFAULT_ZONE (unlocated simulation) and is NOT interpreted as zone 1 southern hemisphere. For zone 1 south, pass zone=1 with hemisphere=’southern’ explicitly.