Skip to content

Commit

Permalink
Use full projection string for gdalbuildvrt.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
akirmse committed Nov 12, 2024
1 parent d8cb174 commit 960c289
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions scripts/run_prominence.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ def round_up(coord, interval):
"""Return coord rounded up to the nearest interval"""
return math.ceil(coord / interval) * interval

def sign(a):
return bool(a > 0) - bool(a < 0)

def filename_for_coordinates(x, y, degrees_per_tile):
"""Return output filename for the given coordinates"""
y += degrees_per_tile # Name uses upper left corner
Expand Down Expand Up @@ -122,7 +119,11 @@ def create_vrts(tile_dir, input_files, skip_boundary):
ds = gdal.Open(input_file)
prj = ds.GetProjection()
srs = osr.SpatialReference(wkt=prj)
projection_name = srs.GetAttrValue('projcs')
# gdalbuildvrt needs the projections to match pretty much exactly within a VRT file.
# It's not enough to use the projection name; sometimes two projections have the
# same name but slightly different datums, and gdalbuildvrt will fail.
# So instead we use the whole WKT string.
projection_name = srs.ExportToWkt()
projection_map.setdefault(projection_name, []).append(input_file)

# For each projection, build raw and warped VRTs
Expand Down

0 comments on commit 960c289

Please sign in to comment.