FAQ/ I want to import a shapefile of the left bank line / right bank line¶
How do I import the left and right bank lines of a river into a shapefile?
In DioVista, shapefile files are used for display only and do not provide the ability to import them as project data.
Is there a way to get shapefile data into my project? The target data is . It consists of four files: dbf, .prj, .shp, and .shx.
response¶
Requirements for the Kawashin Line and the Kawagan Line
In DioVISTA, the left and right shore lines and river core lines must be as follows.
- Going from downstream to upstream
- Must be a single polyline
In the example shown below, the polylines of the target river name are connected in the order in which they appear in the shapefile to form a single polyline. If the above requirements are not met in the shapefile of the original data, it may not be possible to create the river as intended.
Incorporate it in the next step.
-
Convert ShapeFile to GeoJSON. Let's take QGIS as an example.
- Drag and drop the desired shapefile into QGIS.
- Right-click the desired shapefile and[export] select > [Saving features] .
- [Save vector layer as] In the dialog, export in geoJSON format. [CRS] Please[EPSG: 4326 - WGS 84] be.
- Here is an example of a geojson of the Kawashin line.
1 2
{ "type": "Feature", "properties": { "W05_004": "OO川", }, "geometry": { "type": "MultiLineString", "coordinates": [ [ [ 133.000, 34.000 ], [ 133.001, 34.001 ], [ 133.002, 34.002 ] ] ] } } ...
- Here is an example of a left and right coast line geojson.
1 2
{ "type": "Feature", "properties": { "河川名": "OO川", "左右岸": "左岸" }, "geometry": { "type": "MultiLineString", "coordinates": [ [ [ 133.000, 34.000 ], [ 133.001, 34.001 ], [ 133.002, 34.002 ] ] } } ...
-
Create a PowerShell script. Save as ImportFrom-GeojsonToFsxprojDRiver.ps1.
Encoding script files
If you are using PowerShell 5, save in UTF16 encoding.
If you are using PowerShell 7, save in UTF8 encoding.1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
# 設定 ここから # 河川データを取り込む先のプロジェクトファイルを指定します。 $projPath = ".\sample.fsxproj" # プロジェクトファイルの保存先を指定します。(フルパスで指定します)。 $projOutPath = "C:\Temp\sample1.fsxproj" # 左右岸線の geojson を指定します。 $lines_lr = ".\lines_lr.json" # 河心線の geojson を指定します。 $lines_center = ".\lines_center.json" # 設定 ここまで [xml]$xml = cat -Encoding utf8 $projPath $lrLines = cat -Encoding utf8 $lines_lr | ConvertFrom-Json $centerLines = cat -Encoding utf8 $lines_center | ConvertFrom-Json $rivers = $lrLines.properties."河川名" | select -Unique $riverId = $xml.floodSim.conditions.diffusionalRivers.diffusionalRiver.Length foreach ($river in $rivers) { $xDiffusionalRiver = $xml.CreateElement("diffusionalRiver") [void]$xml.floodSim.conditions.diffusionalRivers.AppendChild($xDiffusionalRiver) # 河川の属性 $attrs = @{ "name" = $river "riverId" = $riverId "viewItems" = "8191" "inflow" = "1 0 0" "downstreamToeWaterLevel" = "0" "closeDownstreamToe" = "False" "enableConnectionToDrain" = "True" "maxTransverseInterval" = "100" "depthValidMin" = "0.01" "areaValidMin" = "0.003" "onewayRtoP" = "False" "prConnExpressionOfRiverLine" = "0" "riverWallAllowReverseOverFlow" = "False" "valid" = "True" "centerLineStyle" = "0 2 0 0 255 255" "leftLineStyle" = "0 2 51 102 255 255" "rightLineStyle" = "0 2 255 153 204 255" "transverseLineStyle" = "0 1 255 153 0 255" "riverWallLineStyle" = "0 4 204 255 204 192" "flowGraphMin" = "" "flowGraphMax" = "" "upperRiverId" = "-1" "upperRiverDistance" = "0" "confluenceIsLeft" = "False" "upperRiverIsLeft" = "False" "mainstreamRiverId" = "-1" "mainstreamRiverDistance" = "0" "distributaryIsLeft" = "False" "mainstreamRiverIsLeft" = "False" "distributaryRatio" = "0" "distributaryLimit" = "" "steadyFlowAlpha" = "1" "steadyFlowBeta" = "1" "initialPrecip" = "" "precipCorrectionFactor" = "" "watershedDelineationOnly" = "False" "conditionalInflow" = "False" } $attrs.GetEnumerator() | % { $xAttr = $xml.CreateAttribute($_.Name) $xAttr.Value = $_.Value [void]$xDiffusionalRiver.Attributes.Append($xAttr) } # 左右岸線 $sides = @{ "elementName" = "leftLine" "shapefileProperty" = "左岸" }, @{ "elementName" = "rightLine" "shapefileProperty" = "右岸" } foreach ($side in $sides) { $xLine = $xml.CreateElement($side.elementName) [void]$xDiffusionalRiver.AppendChild($xLine) $lrLine = $lrLines | ? { $_.properties."河川名" -eq $river -and $_.properties."左右岸" -eq $side.shapefileProperty } foreach ($coords in $lrLine.geometry.coordinates) { foreach ($coord in $coords) { $lon = ($coord[0] * [Math]::PI / 180.0) $lat = ($coord[1] * [Math]::PI / 180.0) $xCoordNode = $xml.CreateTextNode(("{0:0.000000000000000} {1:0.000000000000000}" -f $lat, $lon)) $xCoord = $xml.CreateElement("coord") [void]$xCoord.AppendChild($xCoordNode) [void]$xLine.AppendChild($xCoord) } } } # 河心線 $xCenterLine = $xml.CreateElement("centerLine") [void]$xDiffusionalRiver.AppendChild($xCenterLine) foreach ($centerLine in ($centerLines | ? { $_.properties."W05_004" -eq $river } )) { foreach ($coords in $centerLine.geometry.coordinates) { foreach ($coord in $coords) { $lon = ($coord[0] * [Math]::PI / 180.0) $lat = ($coord[1] * [Math]::PI / 180.0) $xCoordNode = $xml.CreateTextNode(("{0:0.000000000000000} {1:0.000000000000000}" -f $lat, $lon)) $xCoord = $xml.CreateElement("coord") [void]$xCoord.AppendChild($xCoordNode) [void]$xCenterLine.AppendChild($xCoord) } } } $riverId++ } $xml.Save($projOutPath)
-
Run the PowerShell script. The created project was saved as "C:\Temp\sample1.fsxproj".