2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

QGISで緯度経度の距離をメートルで取得する

Posted at

はじめに

レイヤの座標系が緯度経度でのメートルで値が取得方法を書きます。参考値とはなると思う値です。
他にいい方法があったら教えてください。

環境

QGIS 3.4.4

DistansAreaを使う


layer = iface.activeLayer()
crs = layer.crs()
feature = layer.selectedFeatures()[0]
geom = feature.geometry()
print(geom.length())

area = QgsDistanceArea()
area.setEllipsoid(crs.ellipsoidAcronym())
print(area.measureLength(geom))

2.18でのコードの供養


layer = iface.activeLayer()
crs = layer.crs()
feature = layer.selectedFeatures()[0]
geom = feature.geometry()

area = QgsDistanceArea()
area.setEllipsoid(crs.ellipsoidAcronym())
area.setEllipsoidalMode(True)
print area.measureLength(geom)

参考

QGIS Documentation: QgsDistanceArea
stackexchange: QGIS Python Distance between points
QgsDistanceArea.convertMeasurement not enough arguments error

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?