Giter Club home page Giter Club logo

Comments (2)

DFEvans avatar DFEvans commented on May 25, 2024

Perhaps useful for context, this is the effect on a real-world raster, where the roads become significantly misaligned:
image

from rasterio.

DFEvans avatar DFEvans commented on May 25, 2024

This bug seems to be caused by rasterio choosing to use an Approximate Transformer - the bUseApproxTransformer flag is always True here unless using RPCs:

rasterio/rasterio/_warp.pyx

Lines 503 to 512 in 8427430

hTransformArg = exc_wrap_pointer(
GDALCreateGenImgProjTransformer2(
src_dataset, dst_dataset, imgProjOptions))
if bUseApproxTransformer:
hTransformArg = exc_wrap_pointer(
GDALCreateApproxTransformer(
GDALGenImgProjTransform, hTransformArg, tolerance))
pfnTransformer = GDALApproxTransform
GDALApproxTransformerOwnsSubtransformer(hTransformArg, 1)
log.debug("Created approximate transformer")

With the current main branch, with cdef bint bUseApproxTransformer = True:
output_main_approx_transformer

And changing it to False
output_main_full_transformer

My naive suggestion for a fix would be adding bUseApproxTransformer = False inside the elif src_geoloc_array is not None branch in the _reproject function, although I'm not fully sure of what other side effects using a non-approximate transformer might give (slightly worse performance?):

rasterio/rasterio/_warp.pyx

Lines 470 to 481 in 8427430

if rpcs:
imgProjOptions = CSLSetNameValue(imgProjOptions, "SRC_METHOD", "RPC")
elif src_geoloc_array is not None:
arr = np.stack((src_geoloc_array[0], src_geoloc_array[1]))
geoloc_dataset = MemoryDataset(arr, crs=src_crs)
log.debug("Geoloc dataset created: geoloc_dataset=%r", geoloc_dataset)
imgProjOptions = CSLSetNameValue(
imgProjOptions, "SRC_GEOLOC_ARRAY", geoloc_dataset.name.encode("utf-8")
)
imgProjOptions = CSLSetNameValue(
imgProjOptions, "SRC_SRS", src_crs.to_string().encode("utf-8")
)

from rasterio.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.