Skip to content

Instantly share code, notes, and snippets.

View stdavis's full-sized avatar

Scott Davis stdavis

View GitHub Profile
@stdavis
stdavis / remove_duplicates.py
Last active September 14, 2017 22:04
remove_duplicates.py
'''
remove_duplicates.py
A module that removes duplicate features from a feature class.
Usage:
from remove_duplicates import remove
remove(r'path/to/data')
@stdavis
stdavis / fix_wkt_geometries.py
Last active September 14, 2017 15:52
Fix WKT Bug in Geometries
'''
fix_wkt_geometries.py
A module that contains code for fixing geometries that stubbornly refused to give you their WKT
This code assumes that the OBJECTIDs are sequential.
Example usage:
from fix_wkt_geometries import fix
@stdavis
stdavis / parseXML.py
Created September 1, 2017 23:00
parseXML.py
import arcpy
import xml.etree.ElementTree as etree
from os.path import join
from dateutil.parser import parse
xml = r'Y:\Mineralsoutput.xml'
output_folder = r'C:\Temp'
gdb_name = 'XMLOutput.gdb'
gdb = join(output_folder, gdb_name)
@stdavis
stdavis / repro.py
Created August 14, 2017 18:34
repair_geometry
import arcpy
from os import path
sde = r'C:\Users\agrc-arcgis\AppData\Roaming\ESRI\Desktop10.5\ArcCatalog\SGID10_Local as CADASTRE.sde\SGID10.CADASTRE.Parcels_Wasatch'
with arcpy.da.UpdateCursor(sde, ['OID@', 'SHAPE@']) as cursor:
for oid, geo in cursor:
print('isMultipart: {}'.format(geo.isMultipart))
print('partCount: {}'.format(geo.partCount))
@stdavis
stdavis / example.js
Created August 9, 2017 20:43
WebAPI.js Geocode Example
require(['agrc/modules/WebAPI'], function (WebAPI) {
var webAPI = new WebAPI({apiKey: 'yourapikey'});
webAPI.geocode('123 S Main St', 84117).then(function (result) {
console.log(result);
}, function (errMsg) {
console.error(errMsg);
});
});
@stdavis
stdavis / TanksInsertBug.py
Created August 1, 2017 19:22
Template with no OID bug in Pro
import arcpy
from os import path
#: SQL Server (non-SDE) database table
source = r'X:\deq-enviro\scripts\nightly\databases\ustdata.sde\USTDATA.dbo.FMSFacilityUstNew'
destination_workspace = r'c:\temp\destination.gdb'
destination_name = 'FMSFacilityUstNew'
@stdavis
stdavis / web.config
Created July 28, 2017 15:34
PrintProxy for Discover Quad Words via IIS URL Rewrite
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="PrintProxy" stopProcessing="true">
<match url=".*Export Web Map Task\/execute" />
<action type="Redirect" url="{R:0}?{C:1}your-open-quad-word{C:2}" appendQueryString="false" redirectType="Found" />
<conditions trackAllCaptures="true">
<add input="{QUERY_STRING}" pattern="(.*discover\.agrc\.utah\.gov%2Flogin%2Fpath%2F)(?!your-open-quad-word).*?(%2Ftiles.*)" />
@stdavis
stdavis / processData.py
Created July 11, 2017 23:28
Broadband Single Providers
import arcpy
from os.path import join
base_folder = r'\\Mac\Documents\Projects\working\SingleProviderBroadbandAreas'
fiber = join(base_folder, 'fiber.gdb')
broadband = join(base_folder, 'broadband.gdb')
output = join(base_folder, 'output.gdb')
fiber_providers = join(fiber, 'Providers')
@stdavis
stdavis / NamePallet.py
Last active June 26, 2017 21:21
Pallet Ship Shell
'''
NamePallet.py
A module that ...
'''
from forklift.models import Pallet
from time import strftime
class NamePallet(Pallet):
@stdavis
stdavis / babel.md
Last active May 18, 2018 22:59
Implement Babel in a AGRC JS Project
  • npm i grunt-babel babel-preset-latest babel-plugin-transform-remove-strict-mode —-save-dev
  • move src/app to _src/app and other base files like index.html.
  • update .gitignore to ignore the entire src directory (yeah!)
  • add babel grunt task config to go from _src/app to src/app
babel: {
    options: {
        sourceMap: true,
 presets: ['latest'],