Skip to content

Instantly share code, notes, and snippets.

View maptastik's full-sized avatar

Ryan Cooper maptastik

View GitHub Profile
curl https://url-to-data.com/data.geojson | ogr2ogr -f "ESRI Shapefile" data.shp /vsistdin/

Problem

When trying to use cURL from the OSGEO4W shell, it throws the following error:

curl: (60) SSL certificate problem: unable to get local issuer certificate More details here: https://curl.haxx.se/docs/sslcerts.html

curl failed to verify the legitimacy of the server and therefore could not establish a secure connection to it. To learn more about this situation and how to fix it, please visit the web page mentioned above.

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

<!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 -->
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 December 21, 2018 17:15
JavaScript functions for fading layers using various map APIs
""" 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
"""
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

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 December 6, 2018 19:36
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)