7.1. Lesson: データを再投影および変換する

座標参照系 (CRSs) について再度話しましょう。前にも簡潔に触れましたが、それは実質的に何を意味するのか議論していませんでした。

このレッスンの目標: ベクターデータセットの再投影および変換をします。

7.1.1. basic Follow Along: 投影法

地図自体だけでなくすべてのデータが今あるCRSはWGS84と呼ばれるものです。これはデータを表現するのに一般的な空間参照系(GCS)です。しかし問題があり、それを見ていきます。

  • Save your current map.
  • Then open the map of the world which you’ll find under exercise_data/world/world.qgs.
  • Zoom in to South Africa by using the Zoom In tool.
  • Try setting a scale in the Scale field, which is in the Status Bar along the bottom of the screen. While over South Africa, set this value to 1:5000000 (one to five million).
  • Pan around the map while keeping an eye on the Scale field.

Notice the scale changing? That’s because you’re moving away from the one point that you zoomed into at 1:5000000, which was at the center of your screen. All around that point, the scale is different.

理由を理解するために、地球の世界を考えます。それは北から南に沿って引かれる線があります。これらの経線は赤道で遠く離れますが、極で出会います。

GCSでは、この球に取り組んでいるが、画面は平坦です。平らな面に球を表現しようとすると、歪みが発生し、テニスボールを開いてカットし、それを平らにしようとした場合に何が起こるかに似ています。これは地図上の意味は、経線も(それらは会うことになっている)の極で、互いに均等に離れて滞在するということです。これは、地図上の離れた赤道から旅行として、見る対象の規模が大きくなると大きくなる、ということを意味します。これが私たちのために何を意味するのか、事実上、私たちの地図には一定の縮尺はないことです!

この問題を解決するため、かわりに投影座標系(PCS)を使用してみましょう。PCSでは縮尺変更のための余裕を作り、それを修正する方法でデータを「投影」または変換します。そのため、一定の縮尺を維持するために、PCSを使用するために私たちのデータを投影変換する必要があります。

7.1.2. basic Follow Along: 「その場で」再投影

QGIS allows you to reproject data “on the fly”. What this means is that even if the data itself is in another CRS, QGIS can project it as if it were in a CRS of your choice.

  • To enable “on the fly” projection, click on the CRS Status button in the Status Bar along the bottom of the QGIS window:
../../../_images/crs_status_button.png
  • In the dialog that appears, check the box next to Enable ‘on the fly’ CRS transformation.
  • Type the word global into the Filter field. One CRS (NSIDC EASE-Grid Global) should appear in the list below.
  • Click on the NSIDC EASE-Grid Global to select it, then click OK.
  • 南アフリカの形状が変化するのに注意してください。すべて投影法の変更によって地球の見た目としての形状が変わります。

  • Zoom in to a scale of 1:5000000 again, as before.
  • 地図をパンニングします。

  • 縮尺は同じであることに注意します!

「その場で」再投影は異なるCRSのデータセットを組み合わせて使う際にも用いられます。

  • Deactivate “on the fly” re-projection again:
    • Click on the CRS Status button again.
    • Un-check the Enable ‘on the fly’ CRS transformation box.
    • Clicking OK.
  • In QGIS 2.0, the ‘on the fly’ reprojection is automatically activated when layers with different CRSs are loaded in the map. To understand what ‘on the fly’ reprojection does, deactivate this automatic setting:
    • Go to Settings ‣ Options...
    • On the left panel of the dialog, select CRS.
    • Un-check Automatically enable ‘on the fly’ reprojection if layers have different CRS.
    • Click OK.
  • Add another vector layer to your map which has the data for South Africa only. You’ll find it as exercise_data/world/RSA.shp.

何に気づきますか?

The layer isn’t visible! But that’s easy to fix, right?

  • Right-click on the RSA layer in the Layers list.
  • Select Zoom to Layer Extent.

OK, so now we see South Africa... but where is the rest of the world?

It turns out that we can zoom between these two layers, but we can’t ever see them at the same time. That’s because their Coordinate Reference Systems are so different. The continents dataset is in degrees, but the RSA dataset is in meters. So, let’s say that a given point in Cape Town in the RSA dataset is about 4 100 000 meters away from the equator. But in the continents dataset, that same point is about 33.9 degrees away from the equator.

This is the same distance - but QGIS doesn’t know that. You haven’t told it to reproject the data. So as far as it’s concerned, the version of South Africa that we see in the RSA dataset has Cape Town at the correct distance of 4 100 000 meters from the equator. But in the continents dataset, Cape Town is only 33.9 meters away from the equator! You can see why this is a problem.

QGIS doesn’t know where Cape Town is supposed to be - that’s what the data should be telling it. If the data tells QGIS that Cape Town is 34 meters away from the equator and that South Africa is only about 12 meters from north to south, then that is what QGIS will draw.

To correct this:

  • Click on the CRS Status button again and switch Enable ‘on the fly’ CRS transformation on again as before.
  • Zoom to the extents of the RSA dataset.

Now, because they’re made to project in the same CRS, the two datasets fit perfectly:

../../../_images/with_reprojection.png

When combining data from different sources, it’s important to remember that they might not be in the same CRS. “On the fly” reprojection helps you to display them together.

Before you go on, you probably want to have the ‘on the fly’ reprojection to be automatically activated whenever you open datasets having different CRS:

  • Open again Settings ‣ Options... and select CRS.
  • Activate Automatically enable ‘on the fly’ reprojection if layers have different CRS.

7.1.3. moderate Follow Along: 他のCRSに設定したデータセットの保存

Remember when you calculated areas for the buildings in the Classification lesson? You did it so that you could classify the buildings according to area.

  • Open your usual map again (containing the Swellendam data).
  • Open the attribute table for the buildings layer.
  • Scroll to the right until you see the AREA field.

Notice how the areas are all very small; probably zero. This is because these areas are given in degrees - the data isn’t in a Projected Coordinate System. In order to calculate the area for the farms in square meters, the data has to be in square meters as well. So, we’ll need to reproject it.

But it won’t help to just use ‘on the fly’ reprojection. ‘On the fly’ does what it says - it doesn’t change the data, it just reprojects the layers as they appear on the map. To truly reproject the data itself, you need to export it to a new file using a new projection.

  • Right-click on the buildings layer in the Layers list.
  • Select Save As... in the menu that appears. You will be shown the Save vector layer as... dialog.
  • Click on the Browse button next to the Save as field.
  • Navigate to exercise_data/ and specify the name of the new layer as buildings_reprojected.shp.
  • Leave the Encoding unchanged.
  • Change the value of the Layer CRS dropdown to Selected CRS.
  • Click the Browse button beneath the dropdown.
  • The CRS Selector dialog will now appear.
  • In its Filter field, search for 34S.
  • Choose WGS 84 / UTM zone 34S from the list.
  • Leave the Symbology export unchanged.

The Save vector layer as... dialog now looks like this:

../../../_images/save_vector_dialog.png
  • Click OK.
  • Start a new map and load the reprojected layer you just created.

Refer back to the lesson on Classification to remember how you calculated areas.

  • Update (or add) the AREA field by running the same expression as before:
../../../_images/new_area_field.png

This will add an AREA field with the size of each building in square meters

  • To calculate the area in another unit of measurement, for example hectares, use the AREA field to create a second column:
../../../_images/new_hectare_field.png

Look at the new values in your attribute table. This is much more useful, as people actually quote building size in meters, not in degrees. This is why it’s a good idea to reproject your data, if necessary, before calculating areas, distances, and other values that are dependent on the spatial properties of the layer.

7.1.4. hard Follow Along: 独自の投影法の作成

投影はデフォルトでQGISに含まれるものだけよりも多くあります。自身の投影も作成できます。

  • Start a new map.
  • Load the world/oceans.shp dataset.
  • Go to Settings ‣ Custom CRS... and you’ll see this dialog:
../../../_images/custom_crs.png
  • Click on the Add new CRS button to create a new projection.

An interesting projection to use is called Van der Grinten I.

  • Enter its name in the Name field.

他のほとんどの投影がそうであるように、この投影は、長方形のものの代わりに円形フィールドに地球を表します。

  • For its parameters, use the following string:

+proj=vandg +lon_0=0 +x_0=0 +y_0=0 +R_A +a=6371000 +b=6371000 +units=m +no_defs

../../../_images/new_crs_parameters.png
  • Click OK.
  • Enable “on the fly” reprojection.
  • Choose your newly defined projection (search for its name in the Filter field).
  • この投影法を適用するため地図は再投影され、したがって:

../../../_images/van_grinten_projection.png

7.1.5. In Conclusion

異なる投影は、異なる目的のために有用です。正しい投影を選択することにより、地図上の地物が正確に表現されていることを確認できます。

7.1.6. Further Reading

Materials for the Advanced section of this lesson were taken from this article.

Further information on Coordinate Reference Systems is available here.

7.1.7. What’s Next?

次のレッスンでは、QGISの様々なベクター分析ツールを使ってベクターデータの分析をする方法について学習します。