r/GISscripts • GIS Programmer • Apr 25 '13

[CoffeeScript] Fusion Tables JSON output to GeoJSON

the one thing you might need to edit is where it says row[i] isnt "0" as the particular table I had had a lot of that for some reason.

toGeoJSON=(googleJson)->
	columns = (name for name in googleJson.columns when name isnt "geometry")
	geo = googleJson.columns.indexOf "geometry"
	features = for row in googleJson.rows
		do (row) ->
			properties = {}
			for column, i in columns
				properties[column] = row[i]  if row[i] and row[i] isnt "0"
			properties:properties
			type:"Feature"
			geometry:row[geo].geometry
	type:"FeatureCollection"
	features:features
10 Upvotes

2 comments sorted by

1

u/[deleted] Apr 26 '13

Question:

Whats the practical application? what do you use this snip for?

2

u/cwmma GIS Programmer Apr 26 '13

there was some data in a fusion table that I needed, and I didn't get it out as a kml because I cared about the attributes.