[SOLVED] Good day! I'm looking at either gdal_contour or gdal_polygonize.py to create a vector layer file from a raster file. I can create the vector file using either method, but it's upside down when I plot it using QGIS. Another list indicated this has to do with the world file.

I use gdal_translate and gdalwarp when transforming the orginal raster in lambert conformal to spherical mercator (for use in OpenLayers) and understand that the world file could be created using one of those utilities (probably when using gdalwarp). However, I'm really unsure after that about the next step using either of the raster to vector utilities where the world file comes into play. Do I have to also use ogr2ogr as well? I'd appreciate a detailed list of steps as the GDAL documentation is a bit fuzzy here.

Just to note my current steps are:

  1. Use gdal_translate to first geo reference the original raster in lambert conformal
  2. Use gdalwarp to reproject the resulting raster image to spherical mercator
  3. Use gdal_translate to create a PNG at a reduced size. Becomes an Image Layer in OpenLayers.
  4. Use either raster to vector utility on the raster produced in step 3.

I see where -co for the world file can be included in gdal_translate or gdalwarp. And like I said, I can create the vector file once the original raster has been warped to spherical mercator. Really just unclear here how the world file comes into play for the resulting vector file in step 4 so the image will be rightside up. Thanks for any help!

[SOLVED] As Matthew asked and then I commented on, I apparently was confused about the world file creation and in which step to do that in.

But, addding -co WORLDFILE=YES in step 3 above created a .wld file for the resulting PNG image. Then used gdal_contour creating a shapefile and also gml, brought both into QGIS to view, and they're now rightside up! Thanks all who viewed and Matthew who commented!

  • is a pgw file created at step 3? – Matthew Snape Jul 26 '11 at 11:28
  • Matthew - I think I had just started to check adding the option for the world file in step 3 after I asked the question and had not had time to check the results. But, I'm pleased to say that adding the option WORLDFILE=YES to step 3 seems to have solved my issue and I will note that after I enter this comment. I think where I ran into problems originally was that gdalwarp doesn't allow -of PNG and therefore, the world file is actually a tfw rather than pgw (or wld as in the doc). Ran the gdal_contour, brought into QGIS, and it worked! Thanks for commenting! – teknocreator Jul 26 '11 at 14:34
  • @MatthewSnape could you write an answer to this question so it can be closed? – underdark Nov 6 '12 at 18:39
  • @teknocreator please post an answer and accept it. This thread is answered and should be marked as such in the system. – underdark Nov 6 '12 at 18:40

Sorry for the delay in posting an answer. As I indicated above, adding -co WORLDFILE=YES in step 3 above created a .wld file for the resulting PNG image. I then used gdal_contour, brought into QGIS, and it worked!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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