Skip to content

Instantly share code, notes, and snippets.

@jccartwright
jccartwright / gist:d9b69821bc45e648e969c490f56a0c98
Last active November 5, 2018 17:16
Logstash http_poller example
input {
http_poller {
id => "production ArcGIS Servers"
urls => {
ngdc => "https://gis.ngdc.noaa.gov/arcgis/rest/info/healthCheck?f=json"
ncdc => {
# Supports all options supported by ruby's Manticore HTTP client
method => get
url => "https://gis.ncdc.noaa.gov/arcgis/rest/info/healthCheck?f=json"
headers => {
@jccartwright
jccartwright / gist:4136e253c6abc7696e3f339a50dc6849
Last active September 29, 2018 17:50
combine multipartline
@Grab(group='com.vividsolutions', module='jts', version='1.13')
import com.vividsolutions.jts.io.WKTReader
import com.vividsolutions.jts.geom.*
import com.vividsolutions.jts.precision.*
def wktReader = new WKTReader()
def wktString = new File('/Users/jcc/Downloads/wkt.txt').text
GeometryFactory geometryFactory = new GeometryFactory(new PrecisionModel(), 4326)
@jccartwright
jccartwright / gist:7e358625eb5e06427daf4da0870449e7
Created August 15, 2018 16:44
round decimal degrees to the nearest cell resolution
def cellResolution = 0.004166666666666667
println roundTo(35.8912, cellResolution)
def roundTo(dd, cellResolution) {
//convert to arcseconds
def interval = Math.round(cellResolution * 3600)
def coord = Math.round(dd * 3600)
def adjustedCoord = interval * Math.round(coord / interval)
@jccartwright
jccartwright / unique_raster_values.py
Created August 10, 2018 21:23
subset a raster and return the counts for all unique values
import arcpy
from arcpy import env
from arcpy.sa import *
import numpy as np
arcpy.CheckOutExtension("Spatial")
#env.workspace = "C:/Users/jcc/Desktop/bathy"
#inRaster = "NH18_SID_ReclassedBathy.tif"
clipEnvelope = arcpy.GetParameter(0)
@jccartwright
jccartwright / ziptest.groovy
Last active May 5, 2018 19:03
create a zip file
import java.util.zip.*
import java.nio.channels.*
ZipOutputStream zipFile = new ZipOutputStream(new FileOutputStream('testme.zip'))
zipFile.putNextEntry(new ZipEntry('testme.txt'))
zipFile.write('Hello World!'.bytes)
zipFile.write('one\n'.bytes)
zipFile.write('two\n'.bytes)
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"/>
<title>Simple Map</title>
<link rel="stylesheet" href="https://js.arcgis.com/3.23/esri/css/esri.css">
<!--<link rel="stylesheet" type="text/css" href="https://js.arcgis.com/3.23/esri/dijit/analysis/ExtractData.css"/>-->
<link rel="stylesheet" type="text/css" href="https://js.arcgis.com/3.23/esri/css/widgets-1.css"/>
@Grapes([
@Grab(group='com.vividsolutions', module='jts-core', version='1.14.0'),
@Grab(group='com.vividsolutions', module='jts-io', version='1.14.0'),
@Grab(group='org.locationtech.spatial4j', module='spatial4j', version='0.6')
])
import com.vividsolutions.jts.io.WKTReader
import com.vividsolutions.jts.geom.*
import org.locationtech.spatial4j.shape.jts.*
import org.locationtech.spatial4j.context.jts.*
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
<title>Identify with Popup</title>
<link rel="stylesheet" href="https://js.arcgis.com/3.21/esri/css/esri.css">
<style>
<?xml version="1.0" encoding="UTF-8"?>
<StyledLayerDescriptor
xmlns="http://www.opengis.net/sld"
xmlns:ogc="http://www.opengis.net/ogc"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
version="1.0.0"
xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd">
<NamedLayer>
<Name>lines</Name>
@jccartwright
jccartwright / gist:33db9bdad4939c9414f2
Created March 26, 2016 20:23
gradle script to execute JAR from remote repo
apply plugin: 'java'
repositories {
maven {
url 'http://artifacts.unidata.ucar.edu/content/repositories/unidata-releases'
}
}
configurations {
toolsUIRuntime