A Python utility to query a CARTO database and return a geopandas GeoDataFrame.
Via conda:
conda install -c controllerphl carto2gpd
Via PyPi:
pip install carto2gpd
import carto2gpd
url = "https://phl.carto.com/api/v2/sql"
where = "date_ > current_date - 30"
gdf = carto2gpd.get(url, "shootings", fields=['age', 'fatal'], where=where, limit=5)
gdf.head()
There is also a utility function to get the size of a CARTO database:
url = "https://phl.carto.com/api/v2/sql"
size = carto2gpd.get_size(url, "shootings")
size