TransWikia.com

GDAL warp & GDAL contour inconsistent results

Geographic Information Systems Asked on January 30, 2021

I am creating 2 output contours based on the same input DEM, one is clipped to a smaller grid feature (green line) while the other is clipped to a larger irregular polygon (blue line).

The problem is there is a .05m gap between the 2 results and the ends of the smaller feature have a bend to them, where the larger feature is straight.

I am using this code to generate the results where the cutline_layer is either the grid feature or large irregular polygon:

    # clip the DEM from cutline layer
    dem = gdal.Warp(raster_out,
                    dem_file,
                    format='GTiff',
                    xRes=2,
                    yRes=2,
                    cutlineDSName=cutline_layer,
                    dstSRS='EPSG:3424',
                    cropToCutline=True)
    dem = None  # remove from memory

    # create the contour
    temp_shapefile_dir = os.path.join('temp', 'contour')
    out_shapefile = os.path.join(temp_shapefile_dir, f"{id_property}.shp")
    os.system(f'gdal_contour -a elevation -i 2 "{raster_out}" "{out_shapefile}"')

Output

  • Blue line – Contour from large Irregular cutline
  • Green line – Contour from smaller Grid cutline
  • Gray dash – Cutline being used for smaller DEM (green line)

enter image description here

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP