pyprecag.crs¶
-
class
pyprecag.crs.
crs
[source]¶ -
-
getEPSGFromSRS
(osr_srs, bOnlineLookup=False, bUpdateToCorrectDefn=False)[source]¶ Get the EPSG number for a Spatial Reference System.
If the Spatial reference system does not contain an EPSG number it will attempt to find one.
If bOnlineLookup is set to True it will use the online lookup service at http://prj2epsg.org to attempt to identify the EPSG. This service will return a list of potential EPSG numbers. If a direct match is not found, then it will return None.
If bOnlineLookup is set to False OR the online lookup fails, then it will attempt to match the input spatial reference system by looping through the list and attempting a proj4 string match if this still fails, then it will attempt a match to australian projected coordinate system
adapted from : https://gis.stackexchange.com/a/8888
Parameters: - osr_srs (osgeo.osr.SpatialReference) –
- bOnlineLookup (bool) – Use the Open Geo Lookup Service
- bUpdateToCorrectDefn (bool) – overwrite existing with the found definition
Returns: EPSG Number for the matched Spatial Reference System.
Return type: int
-
getFromEPSG
(epsg)[source]¶ Create OGR Spatial Reference Object for an epsg_number number :param epsg: A Valid EPSG Number :type epsg: int
Returns: The Spatial Reference Object for the input EPSG Return type: osgeo.osr.SpatialReference
-
getFromWKT
(crs_wkt, bUpdateByEPSG=False)[source]¶ - Get crs attributes via a coordinate systems WKT.
- Used for gathering coordinate system attributes from fiona.crs.crs_wkt. If the EPSG number can be determined, bUpdateByEPSG provides the option to update the proj4, crs_wkt and SRS attributes to match the official EPSG database attributes
Parameters: - crs_wkt (unicode) – A string representing the coordinate system well known text
- bUpdateByEPSG (bool) – If True and the epsg_number is predicted, overwrite crs attributes with those from official epsg_number database.
-
-
pyprecag.crs.
distance_metres_to_dd
(longitude, latitude, distance_metres)[source]¶ Converts a distance in metres to decimal degrees. It presumes the longitude/lats are in WGS84.
- Workflow -> using a Long/Lat, reproject to UTM
- -> Add distance to the easting -> reproject back to WGS84. -> Calculate distance between the two sets of coordinates.
Parameters: - longitude (float) – a floating number representing longitude
- latitude (float) – a floating number representing latitude
- distance_metres (float) – a distance in metres to convert.
Returns: the distance in decimal degrees.
Return type: float
-
pyprecag.crs.
getCRSfromRasterFile
(raster_file)[source]¶ Create a CRS object from a raster file.
Parameters: raster_file (str) – The path and filename to a raster file Returns: An object representing the raster file’s coordinate system. Return type: pyprecag.crs.crs
-
pyprecag.crs.
getCoordTransformation
(inSR, outSR)[source]¶ Get the coordinate transformation between two input spatial references :param inSR: Input Spatial Reference System :type inSR: osgeo.osr.SpatialReference :param outSR: Output Spatial Reference System :type outSR: osgeo.osr.SpatialReference
Returns: The Coordinate Transformation object Return type: osgeo.osr.CoordinateTransformation
-
pyprecag.crs.
getProjectedCRSForXY
(x_coord, y_coord, xy_epsg=4326)[source]¶ Calculate the Zonal projected coordinate system from a set of xy coordinates.
Coordinates will be reprojected to geographics wgs84(4326) if required to identify the correct projected coordinate system.
utm for WGS84 is selected as it is global, and wgs84 is commonly used as the GPS coordinate system.
If input coordinates are within Australia the result will be in Map Grid of Australia(MGA) GDA 1994 coordinate system, otherwise the appropriate zonal utm WGS84 projected coordinate system will be used.
- This is useful for
- converting decimal degrees to metres for area perimeter etc.
- converting sUTM to GDA mga
Parameters: - x_coord (float) – A floating number representing an easting, x or longitude
- y_coord (float) – A floating number representing a northing, y or latitude
- xy_epsg (int) – The epsg_number for the x_coord & y_coord coordinates. This could geographic(WGS84, or GDA94) or projected(UTM or MGA GDA)
Returns: A pyprecag.crs object defining the WGS84 Zone Projected Coordinate System
Return type: pyprecag.crs
-
pyprecag.crs.
getUTMfromWGS84
(longitude, latitude)[source]¶ Calculate the UTM Zonal projection from a set of lats&longs
This is useful for converting decimal degrees to metres for area perimeter etc. utm for WGS84 is selected as it is global, and wgs84 is commonly used as the GPS coordinate system.
It will return the zone, and the spatial reference objects for the utm & wgs84 projections required for coordinate or feature transformation.
Parameters: - longitude (float) – a floating number representing longitude
- latitude (float) – a floating number representing latitude
Returns: UTM Zone, utm SRS, WGS84 SRS
Return type: Tuple[int, osgeo.osr.SpatialReference, osgeo.osr.SpatialReference]