This example illustrates how to load data from a CARTO table using a SQL Query.
Use this when you need to see or modify the data locally. If you only need to visualize the data, just use the query directly in the Layer:
Layer('SELECT * FROM dataset_name')
Note: You'll need CARTO Account credentials to reproduce this example.
from cartoframes.auth import set_default_credentials
set_default_credentials('cartoframes')
from cartoframes import read_carto
gdf = read_carto("SELECT * FROM global_power_plants WHERE country IN ('Brazil')")
gdf.head()
cartodb_id | the_geom | fuel4 | country_abbrev | country | name | gppd_idnr | capacity_mw | latitude | longitude | ... | owner | source | url | geolocation_source | year_of_capacity_data | generation_gwh_2013 | generation_gwh_2014 | generation_gwh_2015 | generation_gwh_2016 | estimated_generation_gwh | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 2161 | POINT (-40.57080 -20.39530) | BRA | Brazil | Jucu | BRA0001272 | 4.840 | -20.3953 | -40.5708 | ... | Agência Nacional de Energia Elétrica (Brazil) | http://www2.aneel.gov.br/aplicacoes/capacidade... | Agência Nacional de Energia Elétrica (Brazil) | 2017 | None | None | None | 18.435905 | |||
1 | 2502 | POINT (-53.00000 -19.00000) | BRA | Brazil | Paraíso I | BRA0027587 | 21.600 | -19.0000 | -53.0000 | ... | Agência Nacional de Energia Elétrica (Brazil) | http://www2.aneel.gov.br/aplicacoes/capacidade... | Agência Nacional de Energia Elétrica (Brazil) | 2017 | None | None | None | 82.275939 | |||
2 | 2989 | POINT (-46.50000 -22.60000) | BRA | Brazil | Socorro | BRA0002762 | 1.000 | -22.6000 | -46.5000 | ... | Agência Nacional de Energia Elétrica (Brazil) | http://www2.aneel.gov.br/aplicacoes/capacidade... | Agência Nacional de Energia Elétrica (Brazil) | 2017 | None | None | None | 3.809071 | |||
3 | 1116 | POINT (-48.72300 -1.53740) | BRA | Brazil | Alunorte | BRA0028916 | 103.854 | -1.5374 | -48.7230 | ... | Agência Nacional de Energia Elétrica (Brazil) | http://www2.aneel.gov.br/aplicacoes/capacidade... | Agência Nacional de Energia Elétrica (Brazil) | 2017 | None | None | None | 994.854387 | |||
4 | 1386 | POINT (-44.06640 -19.54880) | BRA | Brazil | COSIMAT | BRA0032959 | 2.000 | -19.5488 | -44.0664 | ... | Agência Nacional de Energia Elétrica (Brazil) | http://www2.aneel.gov.br/aplicacoes/capacidade... | Agência Nacional de Energia Elétrica (Brazil) | 2017 | None | None | None | 8.554761 |
5 rows × 24 columns
from cartoframes.viz import Layer
Layer(gdf)