Commit 7e4f542
Buffer road lines in the raster's own CRS
combine_vector_targets reprojected everything to EPSG:3857, buffered the
line features there, then reprojected back to the raster CRS. The detour
existed to get a CRS whose units are metres - but the raster's own CRS
normally already is one, since Sentinel-2 is UTM.
Reprojecting straight to it does in one pass what took two. Measured on a
60 km Perth box carrying 918,399 Overture features (256,906 roads and
661,493 buildings), the function's peak drops from +2.67 GB to +1.26 GB;
the two reprojections were 2.1 GB of the 2.7 GB it spent. A full tile
covers ~3.4x the area.
It also buffers by the distance actually asked for. EPSG:3857's scale
factor is 1/cos(latitude), so buffer(distance=5) there laid down about
4.24 m on the ground at Perth's latitude, and a different amount at every
other one - the same code gave a Kununurra scene and a Hobart scene
different real-world road widths. Roads are now buffered a true 5 m,
which widens them by ~18% and sets 1.7% more negative-target pixels
(7,470,943 -> 7,598,563 on the box measured).
A geographic raster CRS cannot buffer in metres, so it keeps the detour
through EPSG:3857 and is reprojected back as before.
make_valid is unchanged.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent 220e14d commit 7e4f542
2 files changed
Lines changed: 83 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
156 | 156 | | |
157 | 157 | | |
158 | 158 | | |
159 | | - | |
160 | | - | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
161 | 173 | | |
162 | 174 | | |
163 | 175 | | |
| |||
174 | 186 | | |
175 | 187 | | |
176 | 188 | | |
177 | | - | |
| 189 | + | |
| 190 | + | |
178 | 191 | | |
179 | 192 | | |
180 | 193 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
1 | 4 | | |
2 | 5 | | |
3 | 6 | | |
| |||
582 | 585 | | |
583 | 586 | | |
584 | 587 | | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
0 commit comments