Skip to content

Commit 960c289

Browse files
committed
Use full projection string for gdalbuildvrt.
Sometimes two projections have the same name, but different internal parameters, which would cause gdalbuiltvrt to fail because it can handle only one projection in a VRT file. So now we use the full WKT string to describe the projection.
1 parent d8cb174 commit 960c289

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

scripts/run_prominence.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,6 @@ def round_up(coord, interval):
4444
"""Return coord rounded up to the nearest interval"""
4545
return math.ceil(coord / interval) * interval
4646

47-
def sign(a):
48-
return bool(a > 0) - bool(a < 0)
49-
5047
def filename_for_coordinates(x, y, degrees_per_tile):
5148
"""Return output filename for the given coordinates"""
5249
y += degrees_per_tile # Name uses upper left corner
@@ -122,7 +119,11 @@ def create_vrts(tile_dir, input_files, skip_boundary):
122119
ds = gdal.Open(input_file)
123120
prj = ds.GetProjection()
124121
srs = osr.SpatialReference(wkt=prj)
125-
projection_name = srs.GetAttrValue('projcs')
122+
# gdalbuildvrt needs the projections to match pretty much exactly within a VRT file.
123+
# It's not enough to use the projection name; sometimes two projections have the
124+
# same name but slightly different datums, and gdalbuildvrt will fail.
125+
# So instead we use the whole WKT string.
126+
projection_name = srs.ExportToWkt()
126127
projection_map.setdefault(projection_name, []).append(input_file)
127128

128129
# For each projection, build raw and warped VRTs

0 commit comments

Comments
 (0)