[GIS] How to generate smooth contours from cropped raster

contourqgisraster

I’m trying to create contours from a raster layer in QGIS. On my first attempt, I cropped my raster layer in Photoshop and reimported it, but it lost coordinate data I think. I made the contours successfully and they were beautiful, but mirrored upwards from the raster layer.

The scale is way out. I discovered this when I imported some vector data. A distance that should be 0.04 degrees is now 30 degrees. This probably is why I’m having my next problem:

I eventually figured out a method for cropping the raster layer in QGIS so it’s at the right scale and location. However, when I make contours from this raster they appear square and pixellated, like they follow the pixel boundaries of the raster layer.

The pixel data for the two raters I used looks the same, so why is this one at the smaller scale now looking so different? Any idea how I can get the nice smooth contours that I got on my first attempt (albeit at the wrong scale)?

I’m very new to this, so I may be missing obvious things! I’d appreciate any help.

Best Answer

This answer summarizes the comments above, where the solution was discovered.

The problem turned out to be that during the cropping process on the raster, the cell size was increased dramatically. When the contour operation was run, it created very angular and pixellated lines.

I suggested:

It would also be a good idea to check and make sure that the cell size and other factors did not change during the cropping process. If the cell size increased significantly from the original, that could make the resulting contours very angular instead of having smooth curves.

Here is how @GrahamvdR found the problem:

Ah, @GetSpatial, if I look at the metadata for the two raster layers I see the Pixel Size has increased hugely (though visually I see no difference). Any ideas on how to avoid this?

Here is the solution as described by @GrahamvdR:

OK, problem solved! I used Raster > Extraction > Clipper to make the crop and the contours I generated subsequently are perfect. Obviously the method I had tried for cropping was not ideal.

Related Question