-
-
Save dmfenton/7d9203e47d9bac7e9e95 to your computer and use it in GitHub Desktop.
Socrata to AGOL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. Make sure you have ruby on your machine | |
2. git clone https://github.com/ajturner/arcgis-ruby.git | |
3. from the directory that repository was cloned into -> gem build arcgis.gemspec | |
4. gem install arcgis | |
5. edit the above file | |
- replace username and pass | |
- replace group with one you control | |
- replace koop link | |
- create a new key and register as a provider with koop | |
- replace the URL variable with the socrata instance url | |
6. ruby registerSocrata.rb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%w{arcgis uri open-uri json}.each {|g| require g} | |
@username = 'user' | |
@password = 'pass' | |
@ago = "http://www.arcgis.com/sharing/rest/" | |
group = "b4bc0f9a091043b0b215c0db2c2f900f" | |
koop = "http://koop.dc.esri.com" | |
url = "http://finances.worldbank.org" | |
key = "worldbank_finances" | |
catalog = "#{url}/data.json" | |
response = open(catalog) | |
datasets = JSON.parse(response.read)['dataset'] | |
# Register in ArcGIS Online | |
@online = Arcgis::Online.new(:host => @ago) | |
@online.login(:username => @username, :password => @password) | |
datasets.each do |dataset| | |
unless dataset['identifier'].nil? || dataset['identifier'].length == 0 | |
puts "Adding #{dataset['identifier']}" | |
# Create an item | |
begin | |
response = @online.item_add( | |
:title => dataset['title'], | |
:description => dataset['description'], | |
:licenseInfo => dataset['license'], | |
:type => "Feature Service", | |
:folder => "MD_Socrata", | |
:url => "#{koop}/socrata/#{key}/#{dataset['identifier'].split('/').last}/FeatureServer/0", | |
:tags => (dataset['keyword'].join(',') rescue nil) | |
) | |
rescue | |
puts $! | |
redo | |
end | |
puts response | |
begin | |
response = @online.item_share( | |
:id => response["id"], | |
:everyone => true, | |
:groups => group) | |
puts response | |
rescue | |
puts $! | |
redo | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I don't think it causes any problems downstream in the Open Data app or AGOL. Still, I agree that it's something that should be fixed.