Changeset 5577 for spike/wktraster/scripts/gdal2wktraster.py
- Timestamp:
- 04/27/10 16:06:05 (2 years ago)
- Files:
-
- 1 modified
-
spike/wktraster/scripts/gdal2wktraster.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
spike/wktraster/scripts/gdal2wktraster.py
r5542 r5577 191 191 """If verbose mode requested, sends extra progress information to stderr""" 192 192 if VERBOSE is True: 193 sys.stderr.write(msg) 193 sys.stderr.write(msg) 194 194 195 195 … … 569 569 return (xpad, ypad) 570 570 571 def is_georeferenced(gt):572 if gt[0] == 0.0 and gt[1] == 1.0 and gt[3] == 0.0 and gt[5] == -1.0:573 return False574 else:575 return True576 577 571 def get_gdal_geotransform(ds): 578 572 assert ds is not None 579 573 gt = list(ds.GetGeoTransform()) 580 # GDAL returns a positive Y pixelsize making ungeoreferenced images581 # to be badly georeferenced. Here we fix this by negating the Y582 # pixelsize when the image is not georeferenced.583 if gt[0] == 0.0 and gt[1] == 1.0 and gt[3] == 0.0 and gt[5] == 1.0:584 gt[5] = -1.0585 574 return tuple(gt) 586 575 … … 591 580 assert len(xy) == 2 592 581 593 if is_georeferenced(gt): 594 xgeo = gt[0] + gt[1] * xy[0] + gt[2] * xy[1]; 595 ygeo = gt[3] + gt[4] * xy[0] + gt[5] * xy[1]; 596 else: 597 xgeo = xy[0] 598 ygeo = xy[1] 599 582 xgeo = gt[0] + gt[1] * xy[0] + gt[2] * xy[1]; 583 ygeo = gt[3] + gt[4] * xy[0] + gt[5] * xy[1]; 584 600 585 return (xgeo, ygeo) 601 586
