From 113da6b6120f404196d6a0322b3e9e56da41bf15 Mon Sep 17 00:00:00 2001 From: Tisham Dhar Date: Wed, 26 May 2021 01:49:03 +0000 Subject: [PATCH] #8 Add reprojection code --- .../notebooks/WIT_WPS_Dispatcher.ipynb | 29 +++++++++++++++++-- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/wps_dispatcher/notebooks/WIT_WPS_Dispatcher.ipynb b/wps_dispatcher/notebooks/WIT_WPS_Dispatcher.ipynb index 76f150f..6e6f3a0 100644 --- a/wps_dispatcher/notebooks/WIT_WPS_Dispatcher.ipynb +++ b/wps_dispatcher/notebooks/WIT_WPS_Dispatcher.ipynb @@ -7,7 +7,7 @@ "metadata": {}, "outputs": [], "source": [ - "import osgeo.ogr as ogr\n", + "import osgeo.ogr as ogr, osr\n", "from tqdm import tqdm" ] }, @@ -34,6 +34,20 @@ { "cell_type": "code", "execution_count": 4, + "id": "6de28833", + "metadata": {}, + "outputs": [], + "source": [ + "inSpatialRef = osr.SpatialReference()\n", + "inSpatialRef.ImportFromEPSG(3577)\n", + "outSpatialRef = osr.SpatialReference()\n", + "outSpatialRef.ImportFromEPSG(4326)\n", + "coordTrans = osr.CoordinateTransformation(inSpatialRef, outSpatialRef)" + ] + }, + { + "cell_type": "code", + "execution_count": 5, "id": "7f509211", "metadata": {}, "outputs": [ @@ -41,7 +55,7 @@ "name": "stderr", "output_type": "stream", "text": [ - "100%|██████████| 270421/270421 [09:42<00:00, 464.35it/s] \n" + "100%|██████████| 270421/270421 [01:16<00:00, 3532.45it/s]\n" ] } ], @@ -50,8 +64,17 @@ "feature_n = layer.GetFeatureCount()\n", "for feature in tqdm(layer):\n", " geom = feature.GetGeometryRef()\n", + " geom.Transform(coordTrans)\n", " centroid = geom.Centroid().ExportToWkt()" ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f7dbe6af", + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { @@ -70,7 +93,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.2" + "version": "3.8.10" } }, "nbformat": 4,