Home 00 Dataplay 01 Download And Load 02 Merge Data 03 Map Basics Intake... 04 Nb 2 Html 05 Map Correlation N... 06 Timelapse Data Gi...

Don't Look! I'm changing!

URL Copied

Musical loops

Hi! We are BNIA-JFI.

This package was made to help with data handling


About this Tutorial:

You use can use these docs to learn from or as documentation when using the attached library.



By the end of this tutorial users should have an understanding of:

Usage Instructions

Install the Package

The code is on PyPI so you can install the scripts as a python library using the command:

!pip install dataplay geopandas

Important: Contributers should follow the maintanance instructions and will not need to run this step.

Their modules will be retrieved from the VitalSigns-GDrive repo they have mounted into their Colabs Enviornment.


Import Modules

  1. Import the installed module into your code:
from VitalSigns.acsDownload import retrieve_acs_data 
  1. use it
retrieve_acs_data(state, county, tract, tableId, year, saveAcs)

Now you could do something like merge it to another dataset!

from dataplay.merge import mergeDatasets
mergeDatasets(left_ds=False, right_ds=False, crosswalk_ds=False,  use_crosswalk = True, left_col=False, right_col=False, crosswalk_left_col = False, crosswalk_right_col = False, merge_how=False, interactive=True)

Getting Help

You can get information on the package, modules, and methods by using the help command.

Here we look at the package's modules:

Help on package dataplay: NAME dataplay PACKAGE CONTENTS _nbdev corr geoms gifmap html intaker merge VERSION 0.0.37 FILE c:\python311\lib\site-packages\dataplay\__init__.py

Lets take a look at what functions the geoms module provides:

Help on module dataplay.geoms in dataplay: NAME dataplay.geoms - # AUTOGENERATED! DO NOT EDIT! File to edit: notebooks/03_Map_Basics_Intake_and_Operations.ipynb (unless otherwise specified). FUNCTIONS map_points(data, lat_col='POINT_Y', lon_col='POINT_X', zoom_start=11, plot_points=True, cluster_points=False, pt_radius=15, draw_heatmap=False, heat_map_weights_col=None, heat_map_weights_normalize=True, heat_map_radius=15, popup=False) Creates a map given a dataframe of points. Can also produce a heatmap overlay Arg: df: dataframe containing points to maps lat_col: Column containing latitude (string) lon_col: Column containing longitude (string) zoom_start: Integer representing the initial zoom of the map plot_points: Add points to map (boolean) pt_radius: Size of each point draw_heatmap: Add heatmap to map (boolean) heat_map_weights_col: Column containing heatmap weights heat_map_weights_normalize: Normalize heatmap weights (boolean) heat_map_radius: Size of heatmap point Returns: folium map object readInGeometryData(url=False, porg=False, geom=False, lat=False, lng=False, revgeocode=False, save=False, in_crs=4326, out_crs=False) # reverseGeoCode, readFile, getGeoParams, main workWithGeometryData(method=False, df=False, polys=False, ptsCoordCol=False, polygonsCoordCol=False, polyColorCol=False, polygonsLabel='polyOnPoint', pntsClr='red', polysClr='white', interactive=False) # Cell # # Work With Geometry Data # Description: geomSummary, getPointsInPolygons, getPolygonOnPoints, mapPointsInPolygons, getCentroids DATA __all__ = ['workWithGeometryData', 'readInGeometryData', 'map_points'] FILE c:\python311\lib\site-packages\dataplay\geoms.py

And here we can look at an individual function and what it expects:



So heres an example:

Import your modules

Read in some data

Define our download parameters.

More information on these parameters can be found in the tutorials!

county = '510'
 state = '24'
 tableId = 'B19001'
 year = '17'
 saveAcs = False

And download the Baltimore City ACS data using the imported VitalSigns library.

Here we can import and display a geospatial dataset with special intake requirements.

Here we pull a list of Baltimore Cities CSA's

Now in this example we will load in a bunch of coorinates

geoloom_gdf = dataplay.geoms.readInGeometryData(url=geoloom_gdf_url, porg=False, geom='geometry', lat=False, lng=False, revgeocode=False,  save=False, in_crs=4326, out_crs=False)
 geoloom_gdf = geoloom_gdf.dropna(subset=['geometry'])
 # geoloom_gdf = geoloom_gdf.drop(columns=['POINT_X','POINT_Y'])

And here we get the number of points in each of our corresponding CSAs (polygons)

And we plot it with a legend

What were to happen if I wanted to create a interactive click map with the label of each csa (polygon) on each point?

Well we just run the reverse operation!

And then we can visualize it like:

               pt_radius=1, draw_heatmap=True, heat_map_weights_col=None, heat_map_weights_normalize=True,
                heat_map_radius=15, popup='CSA2010')

These interactive visualizations can be exported to html using a tool found later in this document.

Its how I made this page!

If you like what you see, there is more in the package you will just have to explore.