{"id":243,"date":"2024-04-17T17:05:05","date_gmt":"2024-04-17T08:05:05","guid":{"rendered":"https:\/\/www.flumen-jp.com\/wordpress\/?p=243"},"modified":"2024-04-18T13:42:04","modified_gmt":"2024-04-18T04:42:04","slug":"ogr2ogr_3","status":"publish","type":"post","link":"https:\/\/www.flumen-jp.com\/wordpress\/index.php\/2024\/04\/17\/ogr2ogr_3\/","title":{"rendered":"CUI \u3067 GIS\uff083\uff09"},"content":{"rendered":"\n<p>\u3000<a href=\"https:\/\/www.flumen-jp.com\/wordpress\/index.php\/2024\/04\/13\/ogr2ogr_2\/\">\u524d\u56de<\/a>\u3001\u4eca\u6642\u306e GIS \u30c7\u30fc\u30bf\u306f DBMS \u7528\u306e\u30d5\u30a1\u30a4\u30eb\u306b\u306a\u3063\u3066\u3044\u308b\u3001\u3068\u3044\u3046\u304a\u8a71\u3092\u3057\u307e\u3057\u305f\u304c\u3001\u4eca\u56de\u306f\u305d\u308c\u306e\u7d9a\u304d\u3067\u3059\u3002<br>\u3000\u795e\u5948\u5ddd\u770c\u5185\u306e\u7279\u5b9a\u306e\u6d41\u57df\u5185\u306e\u4eba\u53e3\u3092\u96c6\u8a08\u3057\u307e\u3059\u3002<br><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u624b \u9806<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u539f\u30c7\u30fc\u30bf\u306e\u53d6\u5f97<\/li>\n\n\n\n<li>\u5bfe\u8c61\u6d41\u57df\u306e\u30c7\u30fc\u30bf\u306e\u62bd\u51fa<\/li>\n\n\n\n<li>\u5bfe\u8c61\u6d41\u57df\u5185\u306e 5 \u6b21\u30e1\u30c3\u30b7\u30e5\u306e\u62bd\u51fa<\/li>\n\n\n\n<li>\u6d41\u57df\u5185\u306e\u4eba\u53e3\u306e\u96c6\u8a08<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">\u539f\u30c7\u30fc\u30bf\u306e\u53d6\u5f97<\/h3>\n\n\n\n<p>\u3000\u4f7f\u7528\u3059\u308b\u539f\u30c7\u30fc\u30bf\u306f\u4ee5\u4e0b\u306e 3 \u70b9\u3067\u3059\u3002\u5f8c 2 \u8005\u306b\u3064\u3044\u3066\u306f 1 \u6b21\u30e1\u30c3\u30b7\u30e5\u6bce\u306e\u30a2\u30fc\u30ab\u30a4\u30d6\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002\u4eca\u56de\u306f 5239 \u3068 5339 \u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3057\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/nlftp.mlit.go.jp\/ksj\/gmlold\/datalist\/gmlold_KsjTmplt-W12.html#prefecture14\">\u795e\u5948\u5ddd\u770c\u306e\u6d41\u57df\u754c\u30fb\u975e\u96c6\u6c34\u57df\u30c7\u30fc\u30bf\uff08\u4e16\u754c\u6e2c\u5730\u7cfb\uff09<\/a><br> W12-52A-14-01.0a_GML.zip<\/li>\n\n\n\n<li>e-Stat \u7d71\u8a08\u5730\u7406\u60c5\u5831\u30b7\u30b9\u30c6\u30e0 <a href=\"https:\/\/www.e-stat.go.jp\/gis\/statmap-search?page=1&amp;type=1&amp;toukeiCode=00200521&amp;toukeiYear=2020&amp;aggregateUnit=Q&amp;serveyId=Q002005112020&amp;statsId=T001102&amp;datum=2000&amp;prefCode=14\">\u4ee4\u548c 2 \u5e74\u5ea6\u56fd\u52e2\u8abf\u67fb\uff08\u795e\u5948\u5ddd\u770c\uff09<\/a> <br>tblT001102Q5239.zip tblT001102Q5339.zip<\/li>\n\n\n\n<li>e-Stat \u7d71\u8a08\u5730\u7406\u60c5\u5831\u30b7\u30b9\u30c6\u30e0 <a href=\"https:\/\/www.e-stat.go.jp\/gis\/statmap-search?page=1&amp;type=2&amp;aggregateUnitForBoundary=Q&amp;coordsys=1&amp;format=shape&amp;prefCode=14\">5 \u6b21\u30e1\u30c3\u30b7\u30e5\u5883\u754c\u30c7\u30fc\u30bf\uff08\u795e\u5948\u5ddd\u770c\uff09<\/a> <br>QDDSWQ5239.zip QDDSWQ5339.zip<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">\u5bfe\u8c61\u6d41\u57df\u306e\u30c7\u30fc\u30bf\u306e\u62bd\u51fa<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">\u5bfe\u8c61\u6d41\u57df\u3092\u69cb\u6210\u3059\u308b\u5c0f\u6d41\u57df\u306e\u9078\u629e<\/h4>\n\n\n\n<p>\u3000\u6d41\u57df\u754c\u30fb\u975e\u96c6\u6c34\u57df\u30c7\u30fc\u30bf\u306e\u5c5e\u6027\u306b\u306f\u30a4\u30f3\u30c6\u30ea\u30b8\u30a7\u30f3\u30b9\u304c\u306a\u3044\u306e\u3067\u3001QGIS \u3092\u7528\u3044\u3066\u76ee\u8996\u3067\u5c0f\u6d41\u57df\u3092\u9078\u629e\u3057\u307e\u3059\u3002\u4f5c\u696d\u306e\u30dd\u30a4\u30f3\u30c8\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3059\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u539f\u30c7\u30fc\u30bf\u306b\u306f .prj \u304c\u542b\u307e\u308c\u3066\u3044\u306a\u3044\u306e\u3067 JGD2000\uff08EPSG:4612\uff09\u3092\u6307\u5b9a<\/li>\n\n\n\n<li>\u300c\u30a8\u30af\u30b9\u30dd\u30fc\u30c8\u300d\u2192\u300c\u65b0\u898f\u30d5\u30a1\u30a4\u30eb\u306b\u9078\u629e\u5730\u7269\u3092\u4fdd\u5b58\u300d\u3067\u4ee5\u4e0b\u3092\u6307\u5b9a\n<ul class=\"wp-block-list\">\n<li>\u30d5\u30a1\u30a4\u30eb\u578b\u3000GeoPackage<\/li>\n\n\n\n<li>\u30d5\u30a1\u30a4\u30eb\u540d\u3000someBasin.gpkg<\/li>\n\n\n\n<li>\u30ec\u30a4\u30e4\u30fc\u540d\u3000subBasins<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"695\" height=\"371\" src=\"https:\/\/www.flumen-jp.com\/wordpress\/wp-content\/uploads\/2024\/04\/subBasins.png\" alt=\"\" class=\"wp-image-244\" srcset=\"https:\/\/www.flumen-jp.com\/wordpress\/wp-content\/uploads\/2024\/04\/subBasins.png 695w, https:\/\/www.flumen-jp.com\/wordpress\/wp-content\/uploads\/2024\/04\/subBasins-300x160.png 300w\" sizes=\"auto, (max-width: 695px) 100vw, 695px\" \/><\/figure>\n\n\n\n<div style=\"height:43px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h4 class=\"wp-block-heading\">\u5bfe\u8c61\u6d41\u57df\u306e\u30c7\u30fc\u30bf\u306e\u62bd\u51fa<\/h4>\n\n\n\n<p>\u3000\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u3067 clipsrc.sqlite \u3092\u4f5c\u6210\u3057\u307e\u3059\u3002GeoPackage \u306e\u5e7e\u4f55\u60c5\u5831\u306f geom \u306b\u3001\u5730\u7269\u756a\u53f7\u306f fid \u306b\u53ce\u9332\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>set SQL=SELECT\nset SQL=%SQL% ST_Union(ST_buffer(geom, 0.0001)) as geometry\nset SQL=%SQL% FROM subBasins\nset SQL=%SQL% WHERE fid ^&gt; 0\n\nogr2ogr ^\n    -nln     clipsrc ^\n    -dialect sqlite ^\n    -sql     &quot;%SQL%&quot; ^\n    clipsrc.sqlite someBasin.gpkg<\/code><\/pre><\/div>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"695\" height=\"371\" src=\"https:\/\/www.flumen-jp.com\/wordpress\/wp-content\/uploads\/2024\/04\/clipsrc.png\" alt=\"\" class=\"wp-image-245\" srcset=\"https:\/\/www.flumen-jp.com\/wordpress\/wp-content\/uploads\/2024\/04\/clipsrc.png 695w, https:\/\/www.flumen-jp.com\/wordpress\/wp-content\/uploads\/2024\/04\/clipsrc-300x160.png 300w\" sizes=\"auto, (max-width: 695px) 100vw, 695px\" \/><\/figure>\n\n\n\n<div style=\"height:37px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">\u5bfe\u8c61\u6d41\u57df\u5185\u306e 5 \u6b21\u30e1\u30c3\u30b7\u30e5\u306e\u62bd\u51fa<\/h3>\n\n\n\n<p>\u30002 \u3064\u306e5 \u6b21\u30e1\u30c3\u30b7\u30e5\u5883\u754c\u30c7\u30fc\u30bf\u304b\u3089 code.sqlite \u3092\u4f5c\u6210\u3057\u307e\u3059\u3002code.sqlite \u306e code \u30c6\u30fc\u30d6\u30eb\u306b\u306f clipsrc \u306e\u9818\u57df\u5185\u306e 5 \u6b21\u30e1\u30c3\u30b7\u30e5\u306e\u30b3\u30fc\u30c9 KEY_CODE \u304c\u51fa\u529b\u3055\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>ogr2ogr ^\n    -nln     code ^\n    -sql     &quot;SELECT KEY_CODE FROM MESH05239&quot; ^\n    -clipsrc clipsrc.sqlite ^\n    code.sqlite \/vsizip\/QDDSWQ5239.zip\n\nogr2ogr ^\n    -nln     code ^\n    -sql     &quot;SELECT KEY_CODE FROM MESH05339&quot; ^\n    -clipsrc clipsrc.sqlite ^\n    -append -update ^\n    code.sqlite \/vsizip\/QDDSWQ5339.zip<\/code><\/pre><\/div>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"695\" height=\"371\" src=\"https:\/\/www.flumen-jp.com\/wordpress\/wp-content\/uploads\/2024\/04\/code.png\" alt=\"\" class=\"wp-image-246\" style=\"width:620px;height:auto\" srcset=\"https:\/\/www.flumen-jp.com\/wordpress\/wp-content\/uploads\/2024\/04\/code.png 695w, https:\/\/www.flumen-jp.com\/wordpress\/wp-content\/uploads\/2024\/04\/code-300x160.png 300w\" sizes=\"auto, (max-width: 695px) 100vw, 695px\" \/><\/figure>\n\n\n\n<p class=\"has-text-align-right has-small-font-size\">\u5b9f\u969b\u306e code.sqlite \u306b\u306f\u5730\u7406\u60c5\u5831\u304c\u542b\u307e\u308c\u306a\u3044<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u6d41\u57df\u5185\u306e\u4eba\u53e3\u306e\u96c6\u8a08<\/h3>\n\n\n\n<p>\u3000<a href=\"https:\/\/7-zip.opensource.jp\/\">7z<\/a> \u3067\u56fd\u52e2\u8abf\u67fb\u306e zip \u30d5\u30a1\u30a4\u30eb\u3092\u89e3\u51cd\u3057\u3066\u3001QGIS \u306b\u540c\u68b1\u306e <a href=\"https:\/\/www.javadrive.jp\/sqlite\/ini\/index1.html\">sqlite3<\/a> \u3067\u4eba\u53e3\u3092\u96c6\u8a08\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>7z x -so tblT001102Q5239.zip  &gt; population.csv\n7z x -so tblT001102Q5339.zip &gt;&gt; population.csv\n\nsqlite3 code.sqlite &lt; code.sql<\/code><\/pre><\/div>\n\n\n\n<p>\u3000code.sql \u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3059\u3002\u89e3\u51cd\u3057\u305f population.csv \u306e\u30c6\u30fc\u30d6\u30eb\u540d\u3092 population \u3068\u3057\u3001\u3053\u308c\u306e KEY_CODE \u3068 code.sqlite \u306e code \u30c6\u30fc\u30d6\u30eb\u306e KEY_CODE \u3092\u7d10\u3065\u3051\u3057\u305f\u3046\u3048\u3067\u3001 5 \u6b21\u30e1\u30c3\u30b7\u30e5\u6bce\u306e\u4eba\u53e3\uff08T001102002\uff09\u3092\u96c6\u8a08\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-sql\" data-lang=\"SQL\"><code>.mode csv\n.import .\/population.csv population\n.header on\n\nSELECT SUM(p.T001102002) AS population\nFROM population AS p\nINNER JOIN code AS c ON p.KEY_CODE = c.KEY_CODE;<\/code><\/pre><\/div>\n\n\n\n<p>\u3000\u3053\u308c\u306b\u3088\u3063\u3066\u6b21\u306e\u7d50\u679c\u304c\u753b\u9762\u306b\u51fa\u529b\u3055\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>population\n45294<\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">\u30d0\u30c3\u30c1\u30d5\u30a1\u30a4\u30eb<\/h3>\n\n\n\n<p>\u3000\u4ee5\u4e0a\u306e\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u3092\u307e\u3068\u3081\u305f\u30d0\u30c3\u30c1\u30d5\u30a1\u30a4\u30eb\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3059\u3002\u5b9f\u969b\u306f 33 \u884c\u76ee\u306e\u30b3\u30e1\u30f3\u30c8\u884c\uff08goto :eof\uff09\u306e\u3088\u3046\u306b\u9014\u4e2d\u6bb5\u968e\u3067\u306e\u7d50\u679c\u3092\u78ba\u8a8d\u3057\u306a\u304c\u3089\u30d0\u30c3\u30c1\u30d5\u30a1\u30a4\u30eb\u3092\u5b8c\u6210\u3055\u305b\u307e\u3059\u3002\u6700\u7d42\u7684\u306b\u306f\u4e2d\u9593\u30d5\u30a1\u30a4\u30eb\u3092\u524a\u9664\u3057\u307e\u3059\u304c\u3001\u518d\u5ea6\u3001\u30d0\u30c3\u30c1\u30d5\u30a1\u30a4\u30eb\u3092\u5b9f\u884c\u3059\u308c\u3070\u6e08\u3080\u306e\u3067\u3001\u3053\u308c\u3089\u3092\u4fdd\u5b58\u3057\u3066\u304a\u304f\u5fc5\u8981\u306f\u3042\u308a\u307e\u305b\u3093\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>@echo off\nsetlocal\nset OSGEO4W_ROOT=C:\\OSGEO4W\nset PATH=%OSGEO4W_ROOT%\\bin;%PATH%\ncall %OSGEO4W_ROOT%\\etc\\ini\\gdal.bat\n\nif exist *.sqlite del *.sqlite\n\nset SQL=SELECT\nset SQL=%SQL% ST_Union(ST_buffer(geom, 0.0001)) as geometry\nset SQL=%SQL% FROM subBasins\nset SQL=%SQL% WHERE fid ^&gt; 0\n\nogr2ogr ^\n    -nln     clipsrc ^\n    -dialect sqlite ^\n    -sql     &quot;%SQL%&quot; ^\n    clipsrc.sqlite someBasin.gpkg\n\nogr2ogr ^\n    -nln     code ^\n    -sql     &quot;SELECT KEY_CODE FROM MESH05239&quot; ^\n    -clipsrc clipsrc.sqlite ^\n    code.sqlite \/vsizip\/QDDSWQ5239.zip\n\nogr2ogr ^\n    -nln     code ^\n    -sql     &quot;SELECT KEY_CODE FROM MESH05339&quot; ^\n    -clipsrc clipsrc.sqlite ^\n    -append -update ^\n    code.sqlite \/vsizip\/QDDSWQ5339.zip\n\n@REM goto :eof\n7z x -so tblT001102Q5239.zip  &gt; population.csv\n7z x -so tblT001102Q5339.zip &gt;&gt; population.csv\n\nsqlite3 code.sqlite &lt; code.sql\n\ndel *.sqlite *.csv<\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">\u307e\u3068\u3081<\/h3>\n\n\n\n<p>\u3000\u4eca\u56de\u306f\u5730\u7406\u60c5\u5831\u3092\u542b\u3080\u666e\u901a\u306e\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u304b\u3089\u901a\u5e38\u306e\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u51e6\u7406\u3092\u884c\u3046\u4e8b\u4f8b\u3092\u7d39\u4ecb\u3057\u307e\u3057\u305f\u3002GIS \u306e\u5fdc\u7528\u7bc4\u56f2\u304c\u62e1\u304c\u308b\u306e\u3067\u306f\u306a\u3044\u3067\u3057\u3087\u3046\u304b\u3002<br>\u3000\u6700\u5f8c\u306b\u3001QGIS \u306e\u7528\u9014\u3068\u3057\u3066\u306f\u4e3b\u984c\u56f3\u306e\u4f5c\u6210\u304c\u65e5\u5e38\u7684\u3067\u3042\u308b\u3068\u601d\u308f\u308c\u307e\u3059\u304c\u3001\u53ef\u8996\u5316\u3057\u305f\u60c5\u5831\u304b\u3089\u4f55\u304c\u8a00\u3048\u308b\u304b\u3001\u3092\u8aac\u660e\u3059\u308b\u3053\u3068\u304c\u91cd\u8981\u3067\u3059\u3002\u305d\u3046\u3067\u306a\u3044\u306a\u3089\u3070\u898b\u305f\u4eba\u306b\u300c\u7dba\u9e97\u306a\u7d75\u3067\u3057\u3087\u3002\u3054\u81ea\u7531\u306b\u89e3\u91c8\u304f\u3060\u3055\u3044\u300d\u306b\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3000\u524d\u56de\u3001\u4eca\u6642\u306e GIS \u30c7\u30fc\u30bf\u306f DBMS \u7528\u306e\u30d5\u30a1\u30a4\u30eb\u306b\u306a\u3063\u3066\u3044\u308b\u3001\u3068\u3044\u3046\u304a\u8a71\u3092\u3057\u307e\u3057\u305f\u304c\u3001\u4eca\u56de\u306f\u305d\u308c\u306e\u7d9a\u304d\u3067\u3059\u3002\u3000\u795e\u5948\u5ddd\u770c\u5185\u306e\u7279\u5b9a\u306e\u6d41\u57df\u5185\u306e\u4eba\u53e3\u3092\u96c6\u8a08\u3057\u307e\u3059\u3002 \u624b \u9806 \u539f\u30c7\u30fc\u30bf\u306e\u53d6\u5f97 \u3000\u4f7f\u7528\u3059\u308b\u539f\u30c7\u30fc\u30bf\u306f\u4ee5\u4e0b\u306e 3  [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[18,22,17,24,25],"class_list":["post-243","post","type-post","status-publish","format-standard","hentry","category-it","tag-cui","tag-gis","tag-ogr2ogr","tag-sql","tag-sqlite3"],"_links":{"self":[{"href":"https:\/\/www.flumen-jp.com\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/243","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.flumen-jp.com\/wordpress\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.flumen-jp.com\/wordpress\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.flumen-jp.com\/wordpress\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.flumen-jp.com\/wordpress\/index.php\/wp-json\/wp\/v2\/comments?post=243"}],"version-history":[{"count":16,"href":"https:\/\/www.flumen-jp.com\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/243\/revisions"}],"predecessor-version":[{"id":272,"href":"https:\/\/www.flumen-jp.com\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/243\/revisions\/272"}],"wp:attachment":[{"href":"https:\/\/www.flumen-jp.com\/wordpress\/index.php\/wp-json\/wp\/v2\/media?parent=243"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.flumen-jp.com\/wordpress\/index.php\/wp-json\/wp\/v2\/categories?post=243"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.flumen-jp.com\/wordpress\/index.php\/wp-json\/wp\/v2\/tags?post=243"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}