Created
March 31, 2015 07:10
-
-
Save kohakurei/fa067a3dc6efdec94660 to your computer and use it in GitHub Desktop.
標高メッシュデータからDEMを作成するバッチファイル
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:Make csv2shp | |
:引数としてCSVファイルを指定する。 | |
:例)make.bat target EPSG:4326 | |
:第一引数:ファイル名 | |
:第二引数:EPSGコード | |
@echo off | |
SET SHP_DELETE_FLAG=1 | |
SET OSGEO4W_BIN=C:\OSGeo4W64\bin | |
:中間ファイルとなるVRTファイルを作成 | |
echo ^<OGRVRTDataSource^>>temp.vrt | |
echo ^<OGRVRTLayer name="%1"^>>> temp.vrt | |
echo ^<SrcDataSource^>%1.csv^</SrcDataSource^>>> temp.vrt | |
echo ^<GeometryType^>wkbPoint^</GeometryType^>>> temp.vrt | |
echo ^<LayerSRS^>%2^</LayerSRS^>>> temp.vrt | |
echo ^<GeometryField encoding="PointFromColumns" x="y" y="x" /^>>> temp.vrt | |
echo ^</OGRVRTLayer^> >> temp.vrt | |
echo ^</OGRVRTDataSource^> >> temp.vrt | |
:@echo on | |
:OGR2OGRを使ってShapefileに変換 | |
rem ogr2ogr -f "ESRI Shapefile" -s_srs EPSG:4326 -t_srs EPSG:4326 -lco GEOMETRY=AS_XY %1.shp temp.vrt | |
%OSGEO4W_BIN%\ogr2ogr.exe -f "ESRI Shapefile" -s_srs %2 -t_srs %2 -lco GEOMETRY=AS_XY %1.shp temp.vrt | |
IF NOT EXIST %1.shp ( | |
REM "Shapeへの変換に失敗" | |
GOTO EOFunction | |
) | |
:作成したSHPファイルからDEMを作成 | |
%OSGEO4W_BIN%\gdal_rasterize.exe -a z -tr 2.5 2.5 -l %1 %1.shp %1.tif | |
:EOFunction | |
:不用な中間ファイルを削除 | |
DEL temp.vrt | |
:中間ファイルのShapeを削除する。 | |
IF %SHP_DELETE_FLAG%==0 ( | |
DEL %1.shp | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment