from cartography.spatial.referencing import Transformation from cartography.spatial.referencing import SpatialReference from cartography.spatial import Point utm15 = '+proj=lcc +lat_1=22.5 +lat_0=22.5 +lon_0=-5.4 +k_0=0.999616437 +x_0=1500000 +y_0=400000 +a=6378249.2 +b=6356515 +towgs84=31,146,47,0,0,0,0 +units=m +no_defs ' pt = 'POINT (-93.000 42.000)' # create a point with a spatial reference pt_w_ref = Point(wkt=pt, epsg=4326) # create a point without a spatial reference pt_no_ref = Point(wkt=pt) # define utm and a lat/lon spatial references outref = SpatialReference(proj=utm15) inref = SpatialReference(epsg=4326) # define a transformation that goes from 4326 to UTM N Zone 15 transformation = Transformation(inref, outref) # transform a point with an already defined spatial reference to UTM utmpt = pt_w_ref.transformTo(outref) # transform a point with an undefined spatial reference to UTM utmpt = pt_no_ref.transform(transformation)
