Skip to content

Instantly share code, notes, and snippets.

@tuttinator
Created April 18, 2016 10:55
Show Gist options
  • Select an option

  • Save tuttinator/a64a928276afb99ac761de8a8716e9d6 to your computer and use it in GitHub Desktop.

Select an option

Save tuttinator/a64a928276afb99ac761de8a8716e9d6 to your computer and use it in GitHub Desktop.
Turn a bbox string into an EWKT polygon
def polygon_from_bbox(str)
south_west_lat, south_west_lng, north_east_lat, north_east_lng = str.split(',')
"SRID=4326;POLYGON((" +
south_west_lat + " " + south_west_lng + "," +
north_east_lat + " " + south_west_lng + "," +
north_east_lat + " " + north_east_lng + "," +
south_west_lat + " " + north_east_lng + "," +
south_west_lat + " " + south_west_lng + "))"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment