Last active
December 22, 2015 11:49
-
-
Save creg-ny-baa/6468534 to your computer and use it in GitHub Desktop.
View CartoDB data (from a public table) in QGIS 1.8. Substitute your user name and SQL, and paste it in the python console.
This file contains hidden or 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
# Run in QGIS python console for read-only view of CartoDB table | |
# Substitute your user name and query on first two lines | |
cartoName = "" # PUT YOUR USER NAME IN THE QUOTES | |
cartoQuery = "" # PUT YOUR QUERY IN THE QUOTES | |
import urllib | |
cartoUrl = 'http://{}.cartodb.com/api/v2/sql?format=GeoJSON&q={}'.format(cartoName, cartoQuery) | |
response = urllib.urlopen(cartoUrl) | |
content = response.read() | |
layer = QgsVectorLayer(content, cartoName, 'ogr') | |
QgsMapLayerRegistry.instance().addMapLayer(layer) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment