#!/usr/koeki/bin/ruby # -*- coding: utf-8 -*- require 'csv' require 'json' umap = CSV.read("uMap.csv", {:headers => true}) #umap.each{|row| # printf("obj=%s\n",row["type"]) #} open("umaptest.geojson",'w') do |umapjson| hash = {"type"=>"FeatureCollection","features" =>[{"type" =>"Feature","properties"=>{"name"=>umap["名前"][0],"description"=>umap["コメント"][0]},"geometry" =>{"type" => umap["type"][0],"coordinates"=>[umap["緯度"][0].to_f,umap["経度"][0].to_f]}},{"type" =>"Feature","properties"=>{"name"=>umap["名前"][1], "description" => umap["コメント"][1]},"geometry" =>{"type" => umap["type"][1],"coordinates" => [umap["緯度"][1].to_f,umap["経度"][1].to_f]}}]} geojson = JSON.pretty_generate(hash) umapjson.print geojson print("geojsonできたよ\n") end