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
View README.md

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">
<head>
<meta charset="UTF-8">
<title>Map of single-part geometry data pulled directly from AGOL</title>
</head>
<body>
<!-- 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
maptastik / README.md
Last active Dec 21, 2018
JavaScript functions for fading layers using various map APIs
View README.md
View fcUniqueVals.py
""" Generate a list of unique values for a field in a feature class
Parameters:
fc (str): Input feature class
field (str): Field to find unique values for
Returns:
list: unique values in a field
"""
View randomFCSample.py
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
Parameters:
fc (str): Input feature class to sample
fd (str): Name of output feature layer
sample_field (int): Numeric field to sample values from
View README.md

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
maptastik / shps_to_fgdb.py
Created Dec 6, 2018
Function that takes a list of shapefiles and adds them to a File Geodatabase
View shps_to_fgdb.py
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
maptastik / shps_in_dir.py
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
View shps_in_dir.py
import os
def shps_in_dir(search_directory, full_path = True):
shp_list = []
for file in os.listdir(search_directory):
if file.endswith('.shp'):
shp_list.append(file)
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
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 = feature.properties;
let popupHtml = '';
for(let property in featureProperties) {
popupHtml+=`<b>${property}:</b> ${featureProperties[property]}<br>`
}
layer.bindPopup(popupHtml)
}
You can’t perform that action at this time.