From a8871755e5e43214f9fd68641b0693bb1693d141 Mon Sep 17 00:00:00 2001 From: Joshua Cortez Date: Tue, 10 Sep 2024 23:56:32 +0800 Subject: [PATCH 1/5] fix typo and wording in gridding tutorial and 15_polygon_fill --- notebooks/15_polygon_fill.ipynb | 2 +- notebooks/tutorial.grids.ipynb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/notebooks/15_polygon_fill.ipynb b/notebooks/15_polygon_fill.ipynb index a02694a..47ae481 100644 --- a/notebooks/15_polygon_fill.ipynb +++ b/notebooks/15_polygon_fill.ipynb @@ -1075,7 +1075,7 @@ "\n", "- *Won't there be a performance slowdown from using a geometric intersection operation?* Despite error correction relying on geometry intersection, the performance slowdown should be minimal since we're doing a linestring to polygon intersection (not a polygon to polygon intersection), and the off-boundary pixels should be a small fraction of the total pixels.\n", "\n", - "- *Why is error correction note implemented in this notebook?* In this particular notebook we're only working with pixel coordinates, so the loss of precision problem isn't a concern and we don't need error correction. It's a concern when you're starting off with geographic coordinates, as used in [FastSquareGridGenerator](https://geowrangler.thinkingmachin.es/grids.html#fastsquaregridgenerator) and [FastBingTileGridGenerator](https://geowrangler.thinkingmachin.es/grids.html#fastbingtilegridgenerator). \n" + "- *Why is error correction not implemented in this notebook?* In this particular notebook we're only working with pixel coordinates, so the loss of precision problem isn't a concern and we don't need error correction. It's a concern when you're starting off with geographic coordinates, as shown in [FastSquareGridGenerator](https://geowrangler.thinkingmachin.es/grids.html#fastsquaregridgenerator) and [FastBingTileGridGenerator](https://geowrangler.thinkingmachin.es/grids.html#fastbingtilegridgenerator). \n" ] }, { diff --git a/notebooks/tutorial.grids.ipynb b/notebooks/tutorial.grids.ipynb index 3316474..9ce83b5 100644 --- a/notebooks/tutorial.grids.ipynb +++ b/notebooks/tutorial.grids.ipynb @@ -1471,7 +1471,7 @@ "id": "06901bcb-487d-4632-829f-b96e71ba8f8d", "metadata": {}, "source": [ - "We check that `SquareGridGenerator` and `FastSquareGridGenerator` have an exact match in tiles. Since they use different underlying algorithms, it isn't a 100% guarantee that they will always have the exact same match in tiles due to floating point errors, but they should be extremely close most of the time." + "We check that `SquareGridGenerator` and `FastSquareGridGenerator` have an exact match in tiles. Since they use different underlying algorithms, it isn't a 100% guarantee that they will always have the exact same match in tiles due to floating point differences, but they should be extremely close most of the time." ] }, { @@ -2269,7 +2269,7 @@ "id": "550d2c31-881f-4305-99dc-2740cc930a62", "metadata": {}, "source": [ - "We check that `BingTileGridGenerator` and `FastBingTileGridGenerator` have an exact match in tiles. Since they use different underlying algorithms, it isn't a 100% guarantee that they will always have the exact same match in tiles due to floating point errors, but they should be extremely close most of the time." + "We check that `BingTileGridGenerator` and `FastBingTileGridGenerator` have an exact match in tiles. Since they use different underlying algorithms, it isn't a 100% guarantee that they will always have the exact same match in tiles due to floating point differences, but they should be extremely close most of the time." ] }, { From 6df63e8a015990f870754109fa4329c537df54c6 Mon Sep 17 00:00:00 2001 From: Joshua Cortez Date: Wed, 11 Sep 2024 02:19:06 +0800 Subject: [PATCH 2/5] update off-boundary pixel description --- notebooks/15_polygon_fill.ipynb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/notebooks/15_polygon_fill.ipynb b/notebooks/15_polygon_fill.ipynb index 47ae481..0482746 100644 --- a/notebooks/15_polygon_fill.ipynb +++ b/notebooks/15_polygon_fill.ipynb @@ -1065,7 +1065,9 @@ "\n", "Off-boundary pixels are pixels that have at least one corner tangential to an AOI polygon's edge. They are useful for gridding error correction in [FastSquareGridGenerator](https://geowrangler.thinkingmachin.es/grids.html#fastsquaregridgenerator) and [FastBingTileGridGenerator](https://geowrangler.thinkingmachin.es/grids.html#fastbingtilegridgenerator). \n", "\n", - "Since there are loss in precision errors from translating geographic coordinates to pixel coordinates, the polygon fill algorithm sometimes misses out on pixels tangential to the AOI polygon. To correct this error, we need to add some of the off-boundary pixels.\n", + "When we translate a polygon from geographic coordinates to pixel coordinates, we inevitably have to round the polygon vertex coordinates to the nearest higher or lower integer. This rounding sometimes results in translated polygon edges that pass exactly along the pixel diagonal, when it would have been slightly off the pixel diagonal if it were in geographic coordinates. \n", + "\n", + "Thus, there will sometimes be pixels that when in geographic coordinates actually intersect the AOI, but when in pixel coordinates are only tangential to the AOI polygon. When we use the fast polygon fill algorithm, it doesn't consider these tangential pixels, also called off-boundary pixels, as part of the polygon interior (i.e. the main pixel set). So to correct this error, we need to first identify the off-boundary pixels and then select which among them to add to the main pixel set.\n", "\n", "### How is error correction implemented?\n", "\n", From 76bed83c7dfbc50fd60f521a2f1455f7f0d6a78d Mon Sep 17 00:00:00 2001 From: Joshua Cortez Date: Wed, 11 Sep 2024 10:26:52 +0800 Subject: [PATCH 3/5] improve markdown describing off-boundary pixel error correction --- notebooks/15_polygon_fill.ipynb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/notebooks/15_polygon_fill.ipynb b/notebooks/15_polygon_fill.ipynb index 0482746..937dad8 100644 --- a/notebooks/15_polygon_fill.ipynb +++ b/notebooks/15_polygon_fill.ipynb @@ -1065,19 +1065,19 @@ "\n", "Off-boundary pixels are pixels that have at least one corner tangential to an AOI polygon's edge. They are useful for gridding error correction in [FastSquareGridGenerator](https://geowrangler.thinkingmachin.es/grids.html#fastsquaregridgenerator) and [FastBingTileGridGenerator](https://geowrangler.thinkingmachin.es/grids.html#fastbingtilegridgenerator). \n", "\n", - "When we translate a polygon from geographic coordinates to pixel coordinates, we inevitably have to round the polygon vertex coordinates to the nearest higher or lower integer. This rounding sometimes results in translated polygon edges that pass exactly along the pixel diagonal, when it would have been slightly off the pixel diagonal if it were in geographic coordinates. \n", + "When we translate a polygon from geographic coordinates to pixel coordinates, we inevitably have to round the polygon vertex coordinates to the nearest higher or lower integer. For some pixels, this rounding results in the translated polygon boundary to be tangent to one of the pixel's corners. But if it were in the original geographic coordinates, the boundary would have had intersected a portion of the pixel's interior.\n", "\n", - "Thus, there will sometimes be pixels that when in geographic coordinates actually intersect the AOI, but when in pixel coordinates are only tangential to the AOI polygon. When we use the fast polygon fill algorithm, it doesn't consider these tangential pixels, also called off-boundary pixels, as part of the polygon interior (i.e. the main pixel set). So to correct this error, we need to first identify the off-boundary pixels and then select which among them to add to the main pixel set.\n", + "Thus, there will sometimes be pixels that when in geographic coordinates actually intersect the AOI, but when in pixel coordinates are only tangential to the AOI polygon. When we use the fast polygon fill algorithm, it doesn't consider these tangential pixels, also called off-boundary pixels, as part of the filled-in pixel set. So to correct this error, we need to first identify the off-boundary pixels and then select which ones to add to the filled-in pixel set.\n", "\n", - "### How is error correction implemented?\n", + "### How do we determine which off-boundary pixels to add?\n", "\n", - "We determine which pixels to add to the main pixel set by intersecting the polygon boundary linestring with the off-boundary pixel polygon. Both the linestring and the off-boundary pixel polygon should be in geographic coordinates, not pixel coordinates. The pixels that intersect should be added to the main pixel set. You can find this implementation in the `generate_grid` method under [FastSquareGridGenerator](https://geowrangler.thinkingmachin.es/grids.html#fastsquaregridgenerator) and [FastBingTileGridGenerator](https://geowrangler.thinkingmachin.es/grids.html#fastbingtilegridgenerator)\n", + "We determine which pixels to add to the filled-in pixel set by intersecting the polygon boundary linestring with the off-boundary pixel polygon. Both the linestring and the off-boundary pixel polygon should be in geographic coordinates, not pixel coordinates. The pixels that intersect should be added to the filled-in pixel set. You can find this implementation in the `generate_grid` method under [FastSquareGridGenerator](https://geowrangler.thinkingmachin.es/grids.html#fastsquaregridgenerator) and [FastBingTileGridGenerator](https://geowrangler.thinkingmachin.es/grids.html#fastbingtilegridgenerator)\n", "\n", "- *Why can't we just add all of the off-boundary pixels?* We can't because not all of the off-boundary pixels actually intersect the polygon when in geographic coordinates. \n", "\n", - "- *Won't there be a performance slowdown from using a geometric intersection operation?* Despite error correction relying on geometry intersection, the performance slowdown should be minimal since we're doing a linestring to polygon intersection (not a polygon to polygon intersection), and the off-boundary pixels should be a small fraction of the total pixels.\n", + "- *Won't there be an increased computational cost from using a geometry intersection operation?* Yes, this additional step will add compute time but the increase in computational cost should be minimal since we're doing a linestring to polygon intersection (not a polygon to polygon intersection), and the off-boundary pixels should be a small fraction of the total pixels.\n", "\n", - "- *Why is error correction not implemented in this notebook?* In this particular notebook we're only working with pixel coordinates, so the loss of precision problem isn't a concern and we don't need error correction. It's a concern when you're starting off with geographic coordinates, as shown in [FastSquareGridGenerator](https://geowrangler.thinkingmachin.es/grids.html#fastsquaregridgenerator) and [FastBingTileGridGenerator](https://geowrangler.thinkingmachin.es/grids.html#fastbingtilegridgenerator). \n" + "- *Why is error correction not implemented in this notebook?* In this particular notebook we're only working with pixel coordinates, so the translation problem isn't a concern and we don't need error correction. It's a concern when you're starting off with geographic coordinates, as shown in [FastSquareGridGenerator](https://geowrangler.thinkingmachin.es/grids.html#fastsquaregridgenerator) and [FastBingTileGridGenerator](https://geowrangler.thinkingmachin.es/grids.html#fastbingtilegridgenerator). \n" ] }, { From 4a35c3a75e4447afe4b1e6a0dc732c8b53cfcce0 Mon Sep 17 00:00:00 2001 From: Joshua Cortez Date: Wed, 11 Sep 2024 10:36:50 +0800 Subject: [PATCH 4/5] revert markdown heading --- notebooks/15_polygon_fill.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/notebooks/15_polygon_fill.ipynb b/notebooks/15_polygon_fill.ipynb index 937dad8..1de002e 100644 --- a/notebooks/15_polygon_fill.ipynb +++ b/notebooks/15_polygon_fill.ipynb @@ -1069,7 +1069,7 @@ "\n", "Thus, there will sometimes be pixels that when in geographic coordinates actually intersect the AOI, but when in pixel coordinates are only tangential to the AOI polygon. When we use the fast polygon fill algorithm, it doesn't consider these tangential pixels, also called off-boundary pixels, as part of the filled-in pixel set. So to correct this error, we need to first identify the off-boundary pixels and then select which ones to add to the filled-in pixel set.\n", "\n", - "### How do we determine which off-boundary pixels to add?\n", + "### How do we implement error correction?\n", "\n", "We determine which pixels to add to the filled-in pixel set by intersecting the polygon boundary linestring with the off-boundary pixel polygon. Both the linestring and the off-boundary pixel polygon should be in geographic coordinates, not pixel coordinates. The pixels that intersect should be added to the filled-in pixel set. You can find this implementation in the `generate_grid` method under [FastSquareGridGenerator](https://geowrangler.thinkingmachin.es/grids.html#fastsquaregridgenerator) and [FastBingTileGridGenerator](https://geowrangler.thinkingmachin.es/grids.html#fastbingtilegridgenerator)\n", "\n", From 438034cacd6e45455a1735a0daf9b1f4d246dc60 Mon Sep 17 00:00:00 2001 From: Joshua Cortez Date: Wed, 11 Sep 2024 12:34:29 +0800 Subject: [PATCH 5/5] correct wording --- notebooks/15_polygon_fill.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/notebooks/15_polygon_fill.ipynb b/notebooks/15_polygon_fill.ipynb index 1de002e..bedde55 100644 --- a/notebooks/15_polygon_fill.ipynb +++ b/notebooks/15_polygon_fill.ipynb @@ -1065,7 +1065,7 @@ "\n", "Off-boundary pixels are pixels that have at least one corner tangential to an AOI polygon's edge. They are useful for gridding error correction in [FastSquareGridGenerator](https://geowrangler.thinkingmachin.es/grids.html#fastsquaregridgenerator) and [FastBingTileGridGenerator](https://geowrangler.thinkingmachin.es/grids.html#fastbingtilegridgenerator). \n", "\n", - "When we translate a polygon from geographic coordinates to pixel coordinates, we inevitably have to round the polygon vertex coordinates to the nearest higher or lower integer. For some pixels, this rounding results in the translated polygon boundary to be tangent to one of the pixel's corners. But if it were in the original geographic coordinates, the boundary would have had intersected a portion of the pixel's interior.\n", + "When we translate a polygon from geographic coordinates to pixel coordinates, we inevitably have to round the polygon vertex coordinates to the nearest higher or lower integer. For some pixels, this rounding results in one of the pixel corners to be just tangent to the translated polygon boundary. But if it were in the original geographic coordinates, the boundary would have had intersected a portion of the pixel's interior, not just exactly at a corner.\n", "\n", "Thus, there will sometimes be pixels that when in geographic coordinates actually intersect the AOI, but when in pixel coordinates are only tangential to the AOI polygon. When we use the fast polygon fill algorithm, it doesn't consider these tangential pixels, also called off-boundary pixels, as part of the filled-in pixel set. So to correct this error, we need to first identify the off-boundary pixels and then select which ones to add to the filled-in pixel set.\n", "\n",