GFZ / arosics

AROSICS - Automated and Robust Open-Source Image Co-Registration Software
https://git.gfz-potsdam.de/danschef/arosics
Apache License 2.0
150 stars 28 forks source link

A geotransform must be passed if mapPoly is given. #54

Closed wangleping2000 closed 2 weeks ago

wangleping2000 commented 1 month ago

Description

Describe what you were trying to get done.

I have two images that are not totally overlapped. However, their size, resolution, and projection are samely. The first images have been matched. I want to use the first image as reference to match the second image.

Tell us what happened, what went wrong, and what you expected to happen.

But I get a error report called 'A geotransform must be passed if mapPoly is given'

This is my images in GIS. 微信图片_20241015102646(1)

What I Did

here is my code and error

CRL = arosics.COREG_LOCAL(reference,correct_image,
                          grid_res=16,max_points=500,path_out=out_path,
                          fmt_out='GTIFF')
CRL.correct_shifts()
Calculating footprint polygon and actual data corner coordinates for reference image...
Bounding box of calculated footprint for reference image:
    (-0.5, -13399.5, 11999.5, 0.5)
Calculating footprint polygon and actual data corner coordinates for image to be shifted...
Bounding box of calculated footprint for image to be shifted:
    (0.0, -13400.0, 12000.0, 0.0)
Matching window position (X,Y): 5999.75/-6699.75
Initializing tie points grid...
Equalizing pixel grids and projections of reference and target image...

ValueError: ((0.0, 1.0, 0.0, 0.0, 0.0, -1.0), 'A geotransform must be passed if mapPoly is given.')
danschef commented 1 month ago

Partly overlapping images can be easily handled, that is not the problem. However, your input images should have proper geocoding information. Please run gdalinfo </path/to/image> on both of your input images and post the output here. Please also post the entire error traceback.

wangleping2000 commented 1 month ago

I think it is because abnormality of projection. Actually, this error disappeared when I reduced the number of max_points and the code ran successfully. But the corrected image does not have the spatial reference. So I checked the spatial referenen of the original image and found the loss of that.

dataset = gdal.Open(r'xxxxx.tiff')
geotranform = dataset.GetGeoTransform()
projection = dataset.GetProjection()
print('dataset',dataset)
print('projection',projection)
dataset <osgeo.gdal.Dataset; proxy of <Swig Object of type 'GDALDatasetShadow *' at 0x000002293AA854B0> >
projection 

When I checked my original image at Arcmap, the spatial reference was still here. D_WGS_1984: 'EPSG:4326' 微信图片_20241015172931(1) I think it is not the problem of arosics, but my satellite images.

danschef commented 4 weeks ago

Yes, looks like something is wrong with the projection of your input dataset. However, you can also pass an instance of GeoArray to AROSICS to enforce that AROSICS is using the correct projection:

from geoarray import GeoArray
from arosics import COREG_LOCAL

# geotransform expects something like dataset.GetGeoTransform(), projection expects a WKT string
reference = GeoArray('/path/to/image.tiff', geotransform=..., projection=...)  

CRL = arosics.COREG_LOCAL(reference,correct_image,
                          grid_res=16,max_points=500,path_out=out_path,
                          fmt_out='GTIFF')

Let me know, if you got it working, so that the issue can be closed.

wangleping2000 commented 3 weeks ago

OK. Thank you very much.

---- Replied Message ---- | From | Daniel @.> | | Date | 10/17/2024 16:23 | | To | @.> | | Cc | @.>@.> | | Subject | Re: [GFZ/arosics] A geotransform must be passed if mapPoly is given. (Issue #54) |

Yes, looks like something is wrong with the projection of your input dataset. However, you can also pass an instance of GeoArray to AROSICS to enforce that AROSICS is using the correct projection:

fromgeoarrayimportGeoArrayfromarosicsimportCOREG_LOCAL# geotransform expects something like dataset.GetGeoTransform(), projection expects a WKT stringreference=GeoArray('/path/to/image.tiff', geotransform=..., projection=...)

CRL=arosics.COREG_LOCAL(reference,correct_image, grid_res=16,max_points=500,path_out=out_path, fmt_out='GTIFF')

Let me know, if you got it working, so that the issue can be closed.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>