Skip to content

Instantly share code, notes, and snippets.

Ryan Cooper maptastik

Block or report user

Report or block maptastik

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@maptastik
maptastik / ebpa_routes_sample.geojson
Created Oct 28, 2019
EBPA sample routes for a single census block
View ebpa_routes_sample.geojson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@maptastik
maptastik / citrix_bike_routes_sample10.geojson
Last active Oct 28, 2019
Sample Citrix Cycle route data
View citrix_bike_routes_sample10.geojson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View gif2mp4_h264.bat
ffmpeg -i animated.gif -movflags faststart -pix_fmt yuv420p -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" video.mp4
View calculate_pd_column_from_other_columns.py
import pandas as pd
df = pd.DataFrame({'a': [1,2,3], 'b': [2,3,4], 'c':['dd','ee','ff'], 'd':[5,9,1]})
df['e'] = df[['a', 'b', 'd']].sum(axis = 1)
#########################
## RESULT ##
#########################
# a b c d e # COLUMNS
# 0 1 2 dd 5 8 # ROW
View quantile_bins.py
def quantile_bins(quantiles, min = 0, max = 100):
"""Return a list of quantiles including floor and ceiling values
Args:
quantile (list): Quantile values in order
min (numeric): Floor value of data range
max (numeric): Ceiling value of data range
Returns:
list: An inclusive list of quantile bin values
View quantile_percentiles.py
def quantile_percentiles(quantile_count: int = 5) -> list:
"""Return quantile percentile values for a given number of quantiles.
Args:
quantile_count (int): Number of quantiles to generate percentile values for (default 5)
Returns:
list: Equally spaced quantile percentile values based on quantile_count
Examples:
View update_table.sql
-- ABOUT -----------------------------------------------------------------------
-- This script is meant to outline a procedure for updating a PostgreSQL table
-- with the latest features even if there are views that depend on the table.
-- In other words, this method allows you to update the table without deleting
-- it and recreating it with the latest data. There are definitely some
-- opportunities for improvement - there may be a bit too much redundancy - but
-- this should get the job done, especially on datasets where size is trivial.
--------------------------------------------------------------------------------
-- NOTES -----------------------------------------------------------------------
View activate_run.bat
rem If you want to open CMD and see your script run
@echo
rem Call activate.bat located for your conda installation
call C:\Users\some_user\AppData\Local\Continuum\Miniconda3\Scripts\activate.bat
rem Activate your environment, change directory to location of your script, run script.
activate some_environment && cd C:\Users\some_user\python_script_directory && python python_script.py
rem I can't remember why I added this...You might not need it.
@maptastik
maptastik / ogrIntoPostGIS.md
Last active Aug 2, 2019
Import data into PostGIS with ogr2ogr
View ogrIntoPostGIS.md

Generally I can use QGIS and its DBManager to import data into a PostGIS database. Sometimes that doesn't work perfectly. ogr2ogr can help though. Here are a few approaches to getting data into PostGIS with ogr2ogr.

This is probably the most basic approach:

 ogr2ogr -f "PostgreSQL" PG:"dbname=<db name> user=<username> password=<password> host=<host> port=<port #>" input.geojson -nln schema.table

Running this little command seems to work if you have need to specify the geometry type (Source):

View tnm_edit.arcade
var y = (2 * Atan(Exp(Geometry($feature).y / 6378137)) - PI / 2) / (PI / 180)
var x = Geometry($feature).x / (PI / 180) / 6378137
return "https://edits.nationalmap.gov/tnmcorps/?loc=" + y +"," + x + ",16"
You can’t perform that action at this time.