CRSプロジェクションを使用してRで新しいGRASSデータベースを作成します



Create New Grass Database R With Crs Projection



解決:

R-sig-Geoから採用した以下のアプローチを思いつきました。まず、を介して新しい場所を作成しますデフォルトのPERMANENTマップセットを使用するinitGRASS。次に、目的の座標参照系(CRS)を設定します。そして最後に、PERMANENTからCRSを自動的に継承する新しいマップセットを作成します。

library(rgrass7)##必要なepsgコードgisBaseを使用して新しい場所とベースラインマップセットを初期化します<- system('grass72 --config path', intern = TRUE) initGRASS(gisBase = gisBase, home = raster::tmpDir(), gisDbase = '~/grassdata', location = 'tmp', mapset = 'PERMANENT', override = TRUE) execGRASS('g.proj', flags = 'c', epsg = 4326) ## initialize new mapset inheriting projection info execGRASS('g.mapset', flags = 'c', mapset = 'new_mapset')  

理想的には、あなたは電話する必要がありますg.mapsetおよびg.regionを後で印刷オプションを有効にして、すべてがスムーズに実行されているかどうかを確認します。

execGRASS( 'g.mapset'、flags = 'p')#new_mapset execGRASS( 'g.region'、flags = 'p')#投影:3(緯度-経度)#ゾーン:0#データム:wgs84#楕円体: wgs​​84#北:1N#南:0#西:0#東:1E#nsres:1#ewres:1#行:1#列:1#セル:1 

rgrass7では可能ですがspgrass6では不可能であることがわかりました:https://grasswiki.osgeo.org/wiki/GRASS_Location_Wizard

require(rgrass7)#epsgコードシステムを使用( '' C:/ Program Files / GRASS GIS 7.0.3 / grass70'-c epsg:32651 D:/ temp / use_epsg ')#地理参照ラスターシステムを使用(' 'C: / Program Files / GRASS GIS 7.0.3 / grass70'-c D:/folder/srtm30.tif D:/ temp / use_raster ')#grassデータベースに接続しますinitGRASS(gisBase =' C:/ Program Files / GRASS GIS7.0。 3 '、gisDbase =' D:/ temp '、location =' use_raster '、mapset =' PERMANENT '、override = TRUE)#gisdbase D:/ temp#location rtss#mapset PERMANENT#行748#列944#北1253702#南1230844#西732001.4#東760855.3#nsres 30.55878#ewres 30.56557#射影+ proj = utm + no_defs + zone = 51 + a = 6378137 + rf = 298.257223563 + towgs84 = 0.000,0.000,0.000 + to_meter = 1