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

This is an example of exporting an environment so it can be used to create a new environment. It will also show how to specify a channel that should be included in the build process

First, you'll need to activate the environment you want to use.

activate old-environment

Then export then environment to environment.yml

View agol_map.html
<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8">
<title>Map of single-part geometry data pulled directly from AGOL</title>
<!-- Load require.js. Delete this if your page already loads require.js -->
View bad_geojson_pts.geojson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
maptastik /
Last active Dec 21, 2018
JavaScript functions for fading layers using various map APIs
""" Generate a list of unique values for a field in a feature class
fc (str): Input feature class
field (str): Field to find unique values for
list: unique values in a field
import arcpy
import numpy as np
def randomFCSample(fc, fd='sample_fd', sample_field='OBJECTID', sample_pct=10):
"""Return a randomish sample of a feature class as a feature layer
fc (str): Input feature class to sample
fd (str): Name of output feature layer
sample_field (int): Numeric field to sample values from

Add features from several GPX files in a directory to a GeoPackage

This is motivated by the fact that Runkeeper exports all your GPS data to individual GPX files. These GPX files contain 5 different tables:

  1. route_points
  2. routes
  3. track_points
  4. tracks
  5. waypoints
maptastik /
Created Dec 6, 2018
Function that takes a list of shapefiles and adds them to a File Geodatabase
import arcpy
def shp_to_fgdb(shps, out_fgdb):
if isinstance(shps, str):
shps = [shps]
for shp in shps:
out_fc_name = shp.split('\\')[-1].split('.')[0]
print('Working on {}...'.format(out_fc_name))
arcpy.FeatureClassToFeatureClass_conversion(shp, out_fgdb, out_fc_name)
maptastik /
Last active Dec 6, 2018
Function that takes a directory as a parameter and returns a list of shapefiles. Although this doesn't explicitly involve arcpy, this function could be used for automating an action on all shapefiles in a directory using arcpy. That said, it could be
import os
def shps_in_dir(search_directory, full_path = True):
shp_list = []
for file in os.listdir(search_directory):
if file.endswith('.shp'):
if len(shp_list) > 0 and full_path:
shp_list = list(map(lambda x: os.path.join(search_directory,x), shp_list))
return shp_list
maptastik / allFieldsPopup.js
Last active Jan 22, 2019
List all of a features fields and values in a popup in Leaflet
View allFieldsPopup.js
function allFieldsPopup(feature, layer) {
let featureProperties =;
let popupHtml = '';
for(let property in featureProperties) {
popupHtml+=`<b>${property}:</b> ${featureProperties[property]}<br>`
You can’t perform that action at this time.