Moshav Idan then and now

Here’s an interesting animation of two aerial photos. The first black and white is from 1966, the second, in color, was taken in 2007.

Merging of the images was done totally with open source GIS software.
Moshav Idan from 1966 to the present

Moshav Idan from 1966 to the present

How it was done:

We obtained several old aerial photos (not rectified) as scanned tiff images. I imported them into GRASS GIS [1] and using the GRASS imagery tools [2] I was able to register the rasters to the Israel Transverse Mercator projection, such that the old photos displayed in their correct geographic location.

Next I wanted to create an animation showing the older image morphing into the new one. But, since one raster is a single band B/W image, and the newer ortho-photo is three band color, I could not just merge the two, since the color range would go awry. Instead, I conjured up this scheme: I made 30 [3] interim rasters from the color raster, each with larger and larger strips, and null values between the strips [4]. Then I opened a PNG driver monitor, and ran the GRASS display commands to overlay each new raster on top of the previous, creating a png file. [5]

Finally, after converting the png files to gif, I ran the ‘gifsicle’ [6] command to merge them all into an animated gif.

My script

I accomplished this process using a GRASS script available here: draw_strips. The script takes up to four command line options:

-f  <first raster>   Start with this raster.  Required

-l  <last raster>   Finish with this raster.  Required

-r  <saved region>     Optional. A saved region. All work is done in this region.  Default is the region of the first raster.

-s <number of strips>   Optional.  Number of strips (iterations). Default is 30.

If you find this helpful, or have any additional ideas or corrections, let me know.

Comments

[1] The module r.in.gdal imports tiff (and many other) formated files as GRASS rasters.

The color images are imported into GRASS in their three separate bands, so I ran r.composite after importing to combine them into a color raster.

[2] I started importing the raw B/W images into an XY (unprojected) location. Using i.group I created an imagery group with just one B/W image in the group. I ran i.target pointing the group to the ITM (Israel Transverse Mercator) location. Then I ran i.points and loaded the color ortho-photo to locate rectification points. I zoomed and panned searching carefully for features such as trees, road intersections etc. that appeared in both images. After finding about 10-15 such locations, I ran i.rectify.

[3] Why 30? I wanted the animation to run for about 10 secs. Running at 4 fps (gifsicle has the ‘–delay’ option for this),  I’d need 40 frames for 10 secs. I copied the opening and closing frames several times (so that the first and last image would appear for a second for two).  So with 30 interim frames, 5 more for each of the first and last images,  it worked out to a 10 second cycle.

[4] By running r.mapcalc in a loop, 30 times, I created 30 rasters. In each cycle ‘n’ of the loop I used the modulus function on the row number, and checked:

if ( row() % 30) < $n

If the modulus was less than ‘n’ the new raster value was set to the color raster. Otherwise ( row_num mod 30 >=  n ) the new raster was set to null. This way I got 30 rasters with wider and wider strips.  And the strips with null value in each iteration  got narrower.

[5] I began by setting the environment variable GRASS_PNG_READ=TRUE. (GRASS 6.3 and later).  This causes the PNG driver to start the PNG monitor with the previous “run”.

Then I simply did d.mon start=PNG;  and d.rast -o map=….; then d.mon stop=PNG for each of the above loops, thus creating a png file with the old B/W raster being overlayed with the strips of the newer one.

[6] The procedure I used for creating animated gifs is from the GRASS wiki .