Sunday 29 April 2018

gdal - Topography: How to convert raster into vector layers?


(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>





No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...