Sept 6, 2016
Data sent from Erin at Anti-eviction Mapping Project:
We're going to use CARTO's builder. Signup for free accounts here: https://carto.com/signup
We're going to explore the space (through PostGIS) and time (native PostgreSQL) in today's workshops using two datasets that have lat/long and timestamps.
<!DOCTYPE html> | |
<html> | |
<meta charset="utf-8"> | |
<style> | |
body { | |
font: 10px sans-serif; | |
} | |
.axis path, |
-- Convert your states (or other geometries id'd by state) to | |
-- display as with Alaska, Hawaii, and Puerto Rico transcaled | |
-- | |
-- @param g: input geometry | |
-- @param state: column identifying the state (name, postal abbreviation, state FP) | |
-- | |
-- output: geometries of states in albers projections of the states | |
-- | |
-- Projections: |
Making good maps in data science is hard. Maps are another form of data visualization with its own set of design principles to bring out the story in the data. Data scientists need for maps varies, but a very common use case is to quickly generate a data visualization iteratively to better understand model outputs, spatial variations in the data, and more.
In this mini-tutorial, I will cover best practices for data scientists needing maps -- ideas pulled from cartography and honed over the years working in the intersection of open source GIS and data science. Using open source tools, I will show how to make patterns more apparent, how to build interactive maps so that it is easier to explore data on larger and smaller scales, and some list some cartographic tips and tricks. The goal is that data viz with maps will be made easier so that you can think about your data science problems instead of worrying about visualizing data on a map.
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>CARTO VL + CARTOframes</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta charset="UTF-8"> | |
<!-- Include CARTO VL JS --> | |
<script src="https://cartodb.github.io/carto-vl/dist/carto-vl.js"></script> | |
<!-- Include Mapbox GL JS --> | |
<script src="https://cartodb-libs.global.ssl.fastly.net/mapbox-gl/v0.48.0-carto1/mapbox-gl.js"></script> |
with envelope as ( | |
SELECT | |
ST_SetSRID(ST_Extent(the_geom), 4326) as env, | |
count(*)::int as cnt | |
FROM | |
eschbacher.mexican_states | |
), | |
numers as ( | |
SELECT | |
unnest(Array['mx.inegi.entidad', 'mx.inegi.localidad_urbana_y_rural_amanzanada']::text[]) as geom_id, |
Andy Eschbacher, Map Scientist, CartoDB
"""Class for updating a cartoframe postgres table""" | |
class SQL(object): | |
"""class for building queries for syncing""" | |
def __init__(self, cartoframe): | |
"""""" | |
self.cframe = cartoframe | |
def add_cols(self): | |
"""prototype methods for add columns to table/dataframe""" |