[gdal-dev] best way to compare in a numpy table the values of two
images with different projection
Matthieu Rigal
rigal at rapideye.de
Wed May 12 09:49:46 EDT 2010
Hi folks,
I am currently implementing a tool to allow band-to-band computations on
array values out of 2 images with different projection and different
resolution in python.
The operation is quite complex, so I will summarize it here and below give
the solution I am currently testing to see if it is the best one and ask
for some enhancements and performance hints. Unfortunately, the high-level
warping class is, at my knowledge, only available in C++.
Workflow (could also be improved by all-in-one functions like for C++)
- Open image A, 5000*5000 pixels, 5m resolution, UTM
- Open image B, approx 100m resolution, LatLon, much larger than the
previous one
- Cut out the buffered extents of image A from image B
- Reproject this cutted image to the projection and resolution of image A
- Read full image A as array
- Read extents of image A from image B as array
It sounds easy, but when I started implementing it, I figured out that it
was quite complicated and that it would be quite time consuming, so if you
have any suggestions, this is my pseudo-code (I thought about writing a
real code, but it may be too long for the list, if I want to also include
the generation of image A and B at the beginning):
- gdal.Open(imgA, imgB)
- GetGeoTransform(imgA, imgB)
- CreateGeometry(boundaries of imgA).Buffer
- Transform(projection imgB)
- GetEnvelope(transformed geometry)
- transform to in-image of imgB x, y, x_off, y_off
- Create new image in memory
- Calculate its geotransform
- Read the bands into memory (GetRasterBand().Read and .Write() or
ReadIO() ?)
- Reproject the image
- Get GeoTransform
- Calculate in-image coordinates to finally read exactly the same window as
array
Best Regards,
Matthieu
RapidEye AG
Molkenmarkt 30
14776 Brandenburg an der Havel
Germany
Follow us on Twitter! www.twitter.com/rapideye_ag
Head Office/Sitz der Gesellschaft: Brandenburg an der Havel
Management Board/Vorstand: Wolfgang G. Biedermann
Chairman of Supervisory Board/Vorsitzender des Aufsichtsrates:
Juergen Breitkopf
Commercial Register/Handelsregister Potsdam HRB 17 796
Tax Number/Steuernummer: 048/100/00053
VAT-Ident-Number/Ust.-ID: DE 199331235
DIN EN ISO 9001 certified
*************************************************************************
Diese E-Mail enthaelt vertrauliche und/oder rechtlich geschuetzte
Informationen. Wenn Sie nicht der richtige Adressat sind oder diese
E-Mail irrtuemlich erhalten haben, informieren Sie bitte sofort den
Absender und vernichten Sie diese E-Mail. Das unerlaubte Kopieren sowie
die unbefugte Weitergabe dieser E-Mail ist nicht gestattet.
The information in this e-mail is intended for the named recipients
only. It may contain privileged and confidential information. If you
have received this communication in error, any use, copying or
dissemination of its contents is strictly prohibited. Please erase all
copies of the message along with any included attachments and notify
RapidEye AG or the sender immediately by telephone at the number
indicated on this page.
More information about the gdal-dev
mailing list