(nb:This project is part of the #Wikipedia #wikimaps project)

1. Question:

  • How to create vector topographic maps from raster image ?
  • How to convert raster topographic image into closed vector polygons for the relevant levels as seen in the illustration below ?

Using commands (likely gdal) and a GIS topographic raster image, I want to produce topographic .shp maps with an elegant relief. This .shp should be made of closed polygons for each of the n requested level.

enter image description here

2. Possible direction would be:

  1. Create vector isolines (gdal_contour -a elev -fl -500 0 500 1000 2000 4000 crop.tif contours.shp)

  2. Create a copy of the whole map area into vector polygon,

  3. Cut this polygon with all isolines of level n (i.e. isolines of level 0).
  4. Keep those of these polygons with a value (altitude) superior to the isoline value.
  5. (merge this polygons into one shp layer of level_n.)
  6. Repeat for each level.

I haven't clues how to do that, but it sound promising! (should work) If you can provide the solution to one of the points 2, 3, 4, It will be really appreciated ! and I will be happy to then open a specific question where I will validate your helpful answer.

3. Current workflow: gdal_contours alone is not suitable. I currently crop my source raster ETOPO using gdal_translate then get levels with gdal_contour. Using the libs curl, unzip, gdal, my current worflow is as follow.

# download it:
curl -o ETOPO1.zip 'http://www.ngdc.noaa.gov/mgg/global/relief/ETOPO1/data/ice_surface/grid_registered/georeferenced_tiff/ETOPO1_Ice_g_geotiff.zip'
# unzip it:
unzip ETOPO1.zip
# crop it:
gdal_translate -projwin -005.48 051.30 10.00 041.00 ETOPO1_Ice_g_geotiff.tif crop.tif
# lines for levels:
gdal_contour -a elev -fl -500 -200 0 100 200 500 1000 2000 4000 crop.tif contours.shp

Unfortunally, gdal_contour generates vertor iso lines, which are not suitable. The main trouble is with cropped areas: in the case of a close up on France, the isolines are not closing into a circle as for Islands or continents but open lines, so there are partial parts of the polygons (as the quarter of a circle) whose' relevant fill --a 1/4 pie-- appear as a filled arc (see bug below).

End result in D3js fails due to unclosed isolines generated by <code>gdal_contour</code>

  • An other heuristic could be to: 1. create a copy of the raster area ; 2. delete pixels where elevation < n ; 3. use polygonize.py to generate a .shp layer to later import. See : gis.stackexchange.com/questions/69062
    – Hugolpz
    Aug 19, 2013 at 13:24
  • This question was answer on SO main website.
    – Hugolpz
    Aug 23, 2014 at 17:17

1 Answer 1


In my case it worked best to:

  1. Reclass the raster

reclass the elevation grid using GRASS r.reclass, see how this works here: How to reclass a raster with reclassify grid values in QGIS? This gave me the opportunity to manually define the class breaks.

  1. Raster to Polygon

from the menu choose raster>conversion>polygonize (raster to vector)... make sure to select the reclassified raster as the source raster. This gave me the polgygon shapefile with the predefined class-breaks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.