Skip to content

Instantly share code, notes, and snippets.

@sabman
Created August 11, 2010 14:02
Show Gist options
  • Save sabman/519022 to your computer and use it in GitHub Desktop.
Save sabman/519022 to your computer and use it in GitHub Desktop.
user = "admin"
pass = "geoserver"
gs_url = "localhost:8080/geoserver"
workspace = "floods"
system( "curl -u #{user}:#{pass} -v -XPOST -H 'Content-type: text/xml' -d '<workspace><name>#{workspace}</name></workspace>' #{gs_url}/rest/workspaces")
system("mkdir -p tmp_expanded")
system("mkdir -p geotiffs")
Dir.glob('*.zip').each{ |z| system( "unzip -n #{z} -d ./tmp_expanded")}
Dir.glob('./tmp_expanded/*.jpg').each{ |j|
system("gdal_translate -of GTiff \
-co 'PROFILE=GeoTIFF' -co 'INTERLEAVE=PIXEL' \
-co 'COMPRESS=LZW' -co 'TILED=YES' \
-a_srs EPSG:4326 #{j} ./geotiffs/#{File.basename(j,'.jpg')}.tif")
}
system("rm -rf tmp_expanded")
Dir.glob("./geotiffs/*.tif").each{ |g|
system("curl -u #{user}:#{pass} -XPUT -H \"image/tif\" \
--data-binary @#{g} \
#{gs_url}/rest/workspaces/#{workspace}/coveragestores/#{File.basename(g,'.tif')}/file.geotiff")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment