私の「長期的な目標」は、スイスの無料の地形データセット ( http://www.toposhop.admin.ch/de/shop/products/height/dhm25200_1 ) をプロットし、スイスの国境を含むシェープファイルでオーバーレイを作成し、 R の気象観測所を表すデータ ポイント。
シェープファイルを境界線でプロットし、ステーションをポイントとして追加することはうまくいきますが、多くの試行で失敗したのは、WGS84 の境界線とステーションと一緒にプロットできるようにするために、スイス座標の地形データセットを WGS84 に投影することです。
私が過去数日間試したものの最良の解決策と思われるものは何ですか:
# read xyz data:
topo=read.table("DHM200.xyz", sep=" ")
CH.topo.x= as.vector(topo$V1)
CH.topo.y= as.vector(topo$V2)
library(rgdal)
coord.topo <- data.frame(lon=CH.topo.x, lat=CH.topo.y)
coordinates(coord.topo) <- c("lon", "lat")
proj4string(coord.topo) <- CRS("+proj=somerc +lat_0=46.95240555555556+
lon_0=7.439583333333333 +k_0=1 +x_0=600000 +y_0=200000 +ellps=bessel+
towgs84=674.374,15.056,405.346,0,0,0,0 +units=m +no_defs") # CH1903 / LV03 (EPSG:21781)
CRS.new <- CRS("+init=epsg:4326") # WGS84
coord.topo.wgs84 <- spTransform(coord.topo, CRS.new)
# this should have transformed the coordinates properly into a SpatialPoints object
# I now try to replace the old swiss coordinates by the degrees lat/lon:
topo[,1:2]=coordinates(coord.topo.wgs84)
topo=topo[order(topo$V1, topo$V2),]
# but creating a raster (that can be plotted!?)
topo.raster= rasterFromXYZ(topo, res=c(0.002516,0.00184), crs="+init=epsg:4326",
digits=5)
# returns the following error (either with or without "res" input):
# " x cell sizes are not regular"
順序にもかかわらず、このエラーは座標変換の丸め誤差の結果ですか? Rは、terrain.colors()
形状と点をプロットに追加できる方法でデータを投影およびプロットするためのより良いソリューションを提供しますか?
直接尋ねる理由: データセットは ESRI ASCII Grid としても利用できますが、スイス座標でプロットしようとしたため (最初の概要のために)、デフォルトの色は赤から黄色でした。image()
関数 forでプロットしようとしましたterrain.colors()
が、点も形状も追加できませんでした。
誰でも助けることができますか?
前もって感謝します!!!