Giter Site home page Giter Site logo

nicar-2020-geopandas's Introduction

POLITICO

nicar-2020-geopandas

This repo contains the files for the #NICAR20 session "Mapping in Python".

From the session description:

Learn how to use GeoPandas, a handy Python library that lets you do powerful geospatial analysis from the comfort of a Jupyter Notebook. We'll cover mapping, filtering and merging datasets, changing between projections and formatting publication-ready maps.

Intro

GeoPandas is a powerful Python library that extends pandas with geospatial analysis tools.

It's a great alternative to QGIS or standalone PostGIS queries because โ€” like pandas or R โ€” it enables scripted, repeatable and shareable analysis.

We'll be using GeoPandas within a Jupyter Notebook, an excellent tool for writing, annotating and storing Python code used in analyses.

A smart note from Scott Pham, who led a similar session at NICAR 2019:

It's important to realize that GeoPandas is really just a nice wrapper around a bunch of other useful Python libraries including Pandas, Matplotlib, Fiona, Shapely and others. If you want to do something complicated that's not covered by the GeoPandas documentation, there's a good chance you can still do it by looking at the documentation for one of those other libraries.

What's in here

  • ./notebooks/: The four notebooks we'll be using throughout this session.
  • ./source_data/: The data files these notebooks load for analysis and mapping.
  • ./output-images/: An empty folder where the notebooks will export images of finished maps.
  • ./Pipfile: A list of dependencies needed to run this tutorial.

Related reading

Requirements

Installation

  1. Clone this repo and cd into it:

    $ git clone [email protected]:The-Politico/nicar-2020-geopandas.git
    $ cd nicar-2020-geopandas
  2. Set up a Python 3.6 virtual environment, step into it and install dependencies:

     $ pipenv shell
     $ pipenv install --dev

Usage

To launch the Jupyter Notebook service, run the following command in this folder:

$ pipenv run jupyter notebook

A Jupyter Notebook process should launch and open a tab in your web browser. From there you should be able to navigate to the notebooks/ folder and begin navigating through the four notebook files (each of which is described below).

Notebooks used in this tutorial

All notebooks can be found in the ./notebooks/ directory.

  • 01__simple-mapping.ipynb

    What it covers: Importing polygon shapefiles, map styling, generating simple choropleth maps.

  • 02__meaningful-choropleth.ipynb

    What it covers: Filtering polygon shapefile to a subset of features, creating derived fields, merging data files on a unique identifier.

  • 03__points-atop-polygons.ipynb

    What it covers: Importing and filtering point shapefiles, mapping points and polygons simultaneously.

  • 04__geospatial-merge.ipynb

    What it covers: Changing coordinate systems of data, merging point data with that of containing polygons, grouping and counting how many points are in a given polygon.

nicar-2020-geopandas's People

Contributors

allanjamesvestal avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.