Skip to content

geoiq/geoiq-ruby

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

README.rdoc

Ruby API Wrapper around the GeoIQ and GeoCommons API

This is a ruby gem library that wraps around the Geocommons and GeoIQ REST API.

Features

You can search for datasets, and maps.

Upload new datasets from a CSV file and edit existing ones.

Get the features of a dataset and filter them according to a number of parameters, for example, by bounding box, or by attribute.

Create, edit and update maps with layers

Note: That some simple requests will work without a valid username and password.

Some examples

@geoiq = Geoiq.client("http://geocommons.com", "user", "password")

# get dataset and features
dataset = geoiq.dataset.find(1348)
features = dataset.features

# get the geometries in non hexwkb
features = dataset.features({:hex_geometry => 0})

# get features with a custom filter
filtered_features = @dataset.features({"filter[PERIMETER][][max]" => 0.3})
bbox_filtered_features = @dataset.features({:bbox => '-87.2,33.4,-75.9,38.4'})

# Search
@geoiq.search("points", {:bbox => '-87.2,33.4,-75.9,38.4', :limit=> 10})
@geoiq.search("tag:economics")

# Edit dataset
@dataset.update(:title => "Garden Scultures", :description => "lovely jubbly")

# Upload CSV
csv_file = 'data/sculptures.csv'
@dataset = @geoiq.dataset.csv_upload(csv_file, {:title =>"garden sculptures"})

# Upload SHP
@dataset = @geoiq.dataset.shp_upload("data/simple.shp", "data/simple.dbf", "data/simple.shx")

# Upload by URL (type = csv,kml,rss,wms,tile)
@dataset = @geoiq.dataset.url_upload("http://geothings.net/geoiq/simple_testing.csv", {:type => "csv"})

# Add WMS server by URL
@geoiq.dataset.url_upload("http://tilecache.osgeo.org/wms-c/tilecache.py?request=GetCapabilities&service=WMS", {:type=>"wms", :title=>"VMAP FOR THE WMS WIN"})

# Create a new map
map = @geoiq.map(:title => "my empty map")
@geoiq_map = map.create

#get a map and it's layers
@map = @geoiq.map.find(239)
layer_titles =  @map.layers.map{ |l| l['title']}

#add a dataset to a map as a new layer
@map.add_layer(1466)

#deleting map or dataset
@map.delete
@dataset.delete

# Run a simple analysis
@geoiq.analysis.create({:calculation => "intersect", :ds1 => 2288, :ds2 => 2284 })

@geoiq.analysis.create({:calculation => "buffer", :ds1 => 2288, :distance => 50, :units => 'km'})

See the tests, and the API doc for some more, and remember to change the URL to point to your GeoIQ instance, usually Geocommons.com :)

Getting Started

To package the gem:

rake gem              # Build the gem file into pkg/geoiq-0.0.1.gem

To install the gem

sudo rake gem:install      # Installs the gem

Dependencies

The gem needs httparty and json gems. If you want to run the tests, you would need shoulda, fakeweb and geo_ruby

Further examples can be found in the tests

TODO

Coming soon:

Addition of error and response handling, more analysis

Help

Add an issue on the github page github.com/fortiusone/geoiq-ruby/

About

Ruby Library for interfacing with GeoCommons/GeoIQ.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages