GeoJSON (.geojson)
予備知識
-
- MIMEタイプ:application/geo+json.
- GeoJSON GIS形式.
- JSON(JavaScript Object Notation)に基づく地理空間データ交換形式.
- 単純な地理的特徴を表すためのオープン標準.
- GeoJSONはWolfram言語においてGeoJSONオブジェクトを規則のリストであると見なす.
- GeoJSONはRFC 7946で指定される.
Import
- Import["file.geojson"]はGeoJSONファイルをインポートし,GeoGraphicsオブジェクトとして描画する.
- Import["file.geojson","elem"]はGeoJSONファイルから指定の要素をインポートする.
- Import["file.geojson",{{"elem1","elem2",…}}]は複数の要素をインポートする.
- Export["file.geojson",expr]はGeoGraphics式またはDynamicGeoGraphics式をGeoJSONファイルにエキスポートする.
- 科学表記が使用された座標数はJSONではE表記で与えられる.
- シンボルTrueとFalseはJSONでは真偽の値として表される.
- GeoJSON形式は地理投影情報を保存しない.
- 一般的な情報は,以下の関数ページを参照のこと.
-
Import, Export ファイルからインポートする,あるいはファイルへエキスポートする CloudImport, CloudExport クラウドオブジェクトからインポートする,あるいはクラウドオブジェクトへエキスポートする ImportString, ExportString 文字列からインポートする,あるいは文字列へエキスポートする ImportByteArray, ExportByteArray バイト配列からインポートする,あるいはバイト配列へエキスポートする
要素
- 一般的なImport要素:
-
"Elements" ファイル中の有効な要素とオプションのリスト "Summary" ファイルの概要 "Rules" 使用可能なすべての要素の規則のリスト - データ表現要素:
-
"Data" GeoJSONアーカイブの各特徴のルールベース表現 "Graphics" 単一のGeoGraphicsオブジェクトに組み合されたすべての幾何学的特徴 "GraphicsList" GeoJSONアーカイブの幾何学的特徴を現すグラフィックスのリスト - ImportはGeoJSON形式にデフォルトで"Graphics"要素を使う.
- 特殊情報要素:
-
"CoordinateSystem" 座標基準系の名前 "SpatialRange" 通常十進角で与えられる地理座標範囲 - ファイルからの低レベルメタ情報:
-
"CoordinateSystemInformation" 座標基準系の生のパラメータ
例題
すべて開く すべて閉じる例 (3)
Import["ExampleData/newyork.geojson"]GeoGraphicsオブジェクトをGeoJSONファイルとしてエキスポートする:
file = FileNameJoin[{$TemporaryDirectory, "marker.geojson"}]Export[file, GeoGraphics[GeoMarker[Entity["City", {"Boston", "Massachusetts", "UnitedStates"}]]]]Import[file]FilePrint[file]Import["ExampleData/lineNYCtoBoston.geojson", "String"]文字列をインポートし,それをGeoGraphicsオブジェクトとして解釈する:
ImportString[%, "GeoJSON"]スコープ (6)
GeoGraphics地図をGeoJSONファイルとしてエキスポートする:
file = FileNameJoin[{$TemporaryDirectory, "polygonBoston.geojson"}]Export[file, GeoGraphics[Polygon[Entity["City", {"Boston", "Massachusetts", "UnitedStates"}]]]]Import[file]GeoGraphicsオブジェクトをGeoJSONを使って文字列としてエキスポートする:
ExportString[GeoGraphics[GeoMarker[Entity["City", {"Boston", "Massachusetts", "UnitedStates"}]]], "GeoJSON"]明示的にGeoJSON形式を指定して,GeoGraphicsオブジェクトをJSONファイルにエキスポートする:
file = FileNameJoin[{$TemporaryDirectory, "marker.json"}]Export[file, GeoGraphics[GeoMarker[Entity["City", {"Boston", "Massachusetts", "UnitedStates"}]]], "GeoJSON"]Import[file]Import[file, "GeoJSON"]グラフィックス指示子を持ち,GeoJSON特性として符号化されたGeoGraphics式をエキスポートする:
file = FileNameJoin[{$TemporaryDirectory, "polygonWithDirectives.geojson"}]Export[file, GeoGraphics[{FaceForm[Blue], EdgeForm[Red], Polygon[Entity["City", {"Boston", "Massachusetts", "UnitedStates"}]]}]]GeoGraphicsデータをインポートし戻す:
Import[file]Import[file, "Data"]様々なタイプのGeoGraphicsプリミティブと指示子をエキスポートする:
file = FileNameJoin[{$TemporaryDirectory, "geopath.json"}]Export[file, GeoGraphics[{Red, Opacity[0.5], Thickness[Large], GeoPath[{Entity["City", {"NewYork", "NewYork", "UnitedStates"}], Entity["City", {"Boston", "Massachusetts", "UnitedStates"}]}], Blue, Point[Entity["City", {"NewYork", "NewYork", "UnitedStates"}]], FaceForm[{Blue, Opacity[0.7]}], EdgeForm[{Red, Dashed, Thickness[Medium]}], Polygon[Entity["City", {"NewYork", "NewYork", "UnitedStates"}]], Red, Point[Entity["City", {"Boston", "Massachusetts", "UnitedStates"}]], FaceForm[{Red, Opacity[0.7]}], EdgeForm[{Blue, Dashed, Thickness[Medium]}], Polygon[Entity["City", {"Boston", "Massachusetts", "UnitedStates"}]]}], "GeoJSON"]Import[file, "GeoJSON"]GeoJSONファイルからインポートする可能な要素のリストを与える:
Import["ExampleData/map.geojson", "Elements"]Import["ExampleData/map.geojson", "SpatialRange"]Import["ExampleData/map.geojson", {{"Graphics", "SpatialRange"}}]Import要素 (4)
"Data" (1)
"Graphics" (1)
GeoJSONファイルのGeoGraphicsバージョンをインポートする:
Import["ExampleData/newyork.geojson", "Graphics"]"GraphicsList" (1)
GeoJSONファイルを完全なGeoGraphicsオブジェクトとしてインポートする:
Import["ExampleData/disks.geojson"]各地理的プリミティブに対するGeoGraphicsオブジェクトのリストをインポートする:
Import["ExampleData/disks.geojson", "GraphicsList"]"SpatialRange" (1)
GeoJSONファイルで使用されている空間的範囲を取得する:
Import["ExampleData/boston.geojson", "SpatialRange"]FilePrint["ExampleData/boston.geojson"]そのGeoJSONファイルは境界ボックス情報のみを含み,それはGeoGraphicsにインポートする際に使用される:
Import["ExampleData/boston.geojson"]Exportオプション (1)
アプリケーション (1)
earthquakes = EarthquakeData[GeoDisk[Entity["City", {"Sacramento", "California", "UnitedStates"}], Quantity[600, "Kilometers"]], 4, {{1972, 1, 1}, {2012, 12, 31}}, "Position"]["Values"];データのGeoGraphics地図を,他の用途に使えるようにGeoJSONファイルとしてエキスポートする:
file = FileNameJoin[{$TemporaryDirectory, "earthquakes.geojson"}]Export[file, GeoGraphics[{Red, PointSize[.015], Point[earthquakes]}]]GeoJSONファイルの"Data"要素をインポートして結果を確認する:
Import[file, "Data"]地形図の背景を使ってGeoJSONファイルをインポートし,地形との相関関係を示す:
Import[file, GeoBackground -> "ReliefMap"]関連するガイド
履歴
2017 で導入 (11.2)