CityofToronto / bdit_congestion

Determining most congested streets and days in Toronto
https://github.com/orgs/CityofToronto/teams/bigdatainnovationteam
GNU General Public License v3.0
0 stars 0 forks source link

Create function to transform geometry for mapping in geopandas #47

Closed chmnata closed 4 years ago

chmnata commented 4 years ago

Rotating geometry with geopandas is a little bit buggy and complicated when plotting multi features. Create a function in postgres to transform input geometry using the centroid of city of Toronto boundary with ST_rotate().

chmnata commented 4 years ago

Function created in gis.geopandas_transform(geometry)

CREATE OR REPLACE FUNCTION gis.geopandas_transform(geom geometry) RETURNS geometry AS $$
        BEGIN
                RETURN (st_dump(ST_rotate(ST_transform(geom, 26917), -pi()/10, ST_setsrid(ST_geomfromtext('POINT(-79.3902683939991 43.7268356102524)'), 26917)) )).geom ;
        END;
$$ LANGUAGE plpgsql;