Skip to content

Instantly share code, notes, and snippets.

View cbachich's full-sized avatar

Christopher Bachicha cbachich

  • Sanborn
  • United States
View GitHub Profile
@cbachich
cbachich / gist:d50708834a63014a7b76
Created December 31, 2014 22:15
Convert the Geometry hash from a Geojson Feature to WKT
View gist:d50708834a63014a7b76
def convert_to_wkt_string geometry
if geometry['type'] == "Polygon"
wkt_string [geometry["coordinates"]]
else
wkt_string geometry["coordinates"]
end
end
def wkt_string coordinates
"MULTIPOLYGON #{format_outer_polygons coordinates}"
@cbachich
cbachich / array_to_rgeo_multipolygon.rb
Last active August 29, 2015 14:12
Converting an array to a Multipolygon String for RGeo
View array_to_rgeo_multipolygon.rb
test = [[[-70, 30],[-71, 31]],[[0,0],[-180,90],[-179,75]]]=> [[[-70, 30], [-71, 31]], [[0, 0], [-180, 90], [-179, 75]]]
converted = "MULTIPOLYGON ((#{test.map { |coord| "(#{coord.map { |pair| pair.join(" ") }.join ", "})" }.join ", "}))"
@cbachich
cbachich / geotiff2tiles.rb
Created June 6, 2014 14:40
A script that converts geotifs into mbtiles
View geotiff2tiles.rb
#!/usr/bin/env ruby
require 'optparse'
def run_cmd(text,command)
start_time = Time.now
puts "-- Starting #{text} at #{start_time.strftime '%I:%M:%S %b %d, %Y'}"
result = system command
end_time = Time.now