6

皆様、

私が持っている約 700 ポイントの標高データを取得しようとしています。同じ質問 ( R で緯度/経度から高度への変換) に提供されたコードを使用する可能性があると思いましたが、残念ながら geonames パッケージを使用するとエラーが発生し、最良の回答が提供する Web サイトにはオーストラリアの標高データがありません (エラー参考までに以下に示します)。

オーストラリアの非常に正確な標高データを提供する別の Web サイトを見つけましたが、Web ページから情報を抽出する方法がわかりません。Google標高APIを使用していると思いますが、それにアクセスする方法がわかりません。

「場所の検索」ボックスに「緯度、経度」座標を入力すると、地図の下に標高データが表示されます。ただし、ソースページでこれを見つけることができないようです。Web サイトはhttp://www.daftlogic.com/sandbox-google-maps-find-altitude.htmです。

機能する緯度経度値の例:

-36.0736、146.9442

-36.0491、146.4622

R からこのサイトにクエリを実行し、標高データを抽出するのを手伝ってくれる人がいるかどうか疑問に思っています。それとも、面倒なように思えますか?Web サイトにバッチ機能 (最大 100 の場所) があることは認識していますが、R からこれを実行できると便利です。

皆さんありがとうございます。これが非常に明白な場合は申し訳ありません。

乾杯、アダム

エラー

ジオネームを使用する場合:

elevation <- GNgtopo30(adult$lat, adult$lon)
Error in getJson("gtopo30JSON", list(lat = lat, lng = lng)) : 
  error code 10 from server: Please add a username to each call in order for geonames to    be able to identify the calling application and count the credits usage.
In addition: Warning message:
In readLines(u) :
  incomplete final line found on 'http://ws.geonames.org/gtopo30JSON?  lat=-36.0736&lng=146.9442'

クエリ コードを使用する場合:

library(RCurl)
library(XML)
url <- paste("http://earthtools.org/height", adult$lat, adult$lon, sep = '/')
page <- getURL(url)
ans <- xmlTreeParse(page, useInternalNodes = TRUE)
Space required after the Public Identifier
SystemLiteral " or ' expected
SYSTEM or PUBLIC, the URI is missing
Extra content at the end of the document
Error: 1: Space required after the Public Identifier
2: SystemLiteral " or ' expected
3: SYSTEM or PUBLIC, the URI is missing
4: Extra content at the end of the document
4

3 に答える 3

7

パッケージ?getDataにはSRTM昇格用があります。raster

例えば:

library(raster)
m <- data.frame(lon = c(146.9442, 146.4622), lat = c(-36.0736, -36.0491))

x <- getData('alt', country = "AUS")

cbind(m, alt = extract(x, m))
       lon      lat alt
1 146.9442 -36.0736 164
2 146.4622 -36.0491 172

最近隣ではなく、セルへの補間を使用します。

cbind(m, alt = extract(x, m, method = "bilinear"))
       lon      lat      alt
1 146.9442 -36.0736 164.9519
2 146.4622 -36.0491 172.1293

ダウンロード手順では、以前に作業ディレクトリに保存されたファイルを見つけるだけなので、これは一度だけ行う必要があります。

データ オブジェクトは、などRasterLayerで視覚化できる です。plot

plot(x)
points(m)
x
class       : RasterLayer 
dimensions  : 5496, 5568, 30601728  (nrow, ncol, ncell)
resolution  : 0.008333333, 0.008333333  (x, y)
extent      : 112.8, 159.2, -54.9, -9.1  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 
data source : C:\temp\AUS_msk_alt.grd 
names       : AUS_msk_alt 
values      : -43, 2143  (min, max)

ここに画像の説明を入力

于 2014-02-06T07:20:46.703 に答える