I have some contour lines in raster format, I want to convert them vector. I tried with QGIS (version 3.4.6) I got the vector form. But when I tried to select the contour lines to put the actual values those lines represent, I noticed that these lines are formed by rectangles as shown below. Now the problem is I can't select the entire contour and put the required values. How can I get a line instead of these?
Use the Identify tool to click on one of the large polygons between contour lines. Find out what value this polygon has for its elevation value. It's probably
NULL, but it might be 0 or 9999 or some other value that represents
Next, use the Select by Value tool to select all the polygons with that elevation value. This should select all the large polygons.
Delete holestool to fill the hole in the center of each polygon.
Polygons to linestool to convert the selected polygons into lines. Be sure to check the box for "selected features only."
Now you should have a line that represents each contour, with a slight offset towards the inner edge of the ring. The amount of offset is the width of 1-2 "pixels" or grid cells of the original raster.
Note: if that slight offset is unacceptable, skip step 3 (delete holes). Step 4 will give you a pair of lines for each contour. Now you need a way to fill in "centerlines" between the pair of lines. See this question: "Average" of two lines. There are a few tools that supposedly do this, including the HCMGIS plugin and the GRASS tool v.centerline. (I couldn't get the centerline tool in HCMGIS to work, and my version of QGIS seems to be missing v.centerline. But perhaps you will have better luck.)