Reprojecting a layer
Layers may be in a CRS other than the one that is best for a given task. Although QGIS supports on-the-fly reprojection when rendering, other tasks, such as performing spatial analysis, may require using a given CRS or having all input layers in the same one. This recipe shows you how to reproject a vector layer.
Getting ready
Open the layer named Davis_DBO_centerline.shp
from the sample dataset.
How to do it…
The Davis_DBO_centerline.shp
layer uses a CRS with feet as the unit, which makes this unsuitable for certain operations. We plan to use this layer in future recipes to calculate routes and work in metric units, so including this in a CRS that uses them is then a much better option:
- Right-click on the layer name in the table of contents and select Save as....
- Select Selected CRS in the drop-down list to specify a different output CRS. Click on the Browse button to select a CRS. You will see the CRS selector dialog.
- You will be converting the point to the
EPSG:26911
CRS. Use the filter box to find it among the list of available CRSs and select it. Then click on OK. - Click on OK in the Save as dialog to create the layer. A new shapefile will be created with the projected lines.
How it works…
Reprojecting is done by the OGR library when it saves the file because this is one of the options that it supports.
There's more…
Raster layers can be reprojected in a similar way:
- In the Save as dialog, for raster layers, you can find a CRS field with a Browse button.
- Click on it to open the CRS selector, and select the destination CRS.
- When you click on OK, the raster layer will be exported using the selected CRS instead of its original one.