Skip to content

Instantly share code, notes, and snippets.

View amarinelli's full-sized avatar
😅

Adam Marinelli amarinelli

😅
View GitHub Profile
with open("import.txt") as file:
data = file.read()
lines = data.split("\n")
with open("export.csv", "w") as output:
output.write("date, amount, desc\n")
year = "19"
balance = 8698.05

The Spatial Community - Code of Conduct

The Spatial Community Date Posted: 7/26/2016, Last Updated: 7/27/2016

Version 1.04

Creating a Culture of Innovation

We aspire to create a culture where people work joyfully, communicate openly about things that matter, and collaborate on projects. We would like our community to reflect the diversity of the wider community of geospatial and IT professionals. We want to foster diversity of all kinds—not just the classes protected in law. Diversity fosters innovation. Diverse teams are creative teams. We need a diversity of perspective to create solutions for the real and urgent challenges we face.

@amarinelli
amarinelli / arcpy_duplicates.py
Created January 25, 2016 16:40
Simply list duplicates values for a field using arcpy
table_rows = []
duplicates = []
layer = "Springs"
fields = ["OBJECTID", "FCode"]
with arcpy.da.SearchCursor(layer, fields) as cursor:
for row in cursor:
if row[1] in table_rows:
duplicates.append(row[0])
@amarinelli
amarinelli / SearchCursor.py
Created October 23, 2015 17:18
Search Cursor (arcpy)
# from: http://desktop.arcgis.com/en/desktop/latest/analyze/arcpy-data-access/searchcursor-class.htm
import arcpy
fc = 'c:/data/base.gdb/well'
fields = ['WELL_ID', 'WELL_TYPE', 'SHAPE@XY']
# For each row print the WELL_ID and WELL_TYPE fields, and the
# the feature's x,y coordinates
with arcpy.da.SearchCursor(fc, fields) as cursor:
@amarinelli
amarinelli / agol_backup_utility.py
Created March 31, 2015 22:11
Python utility to backup (batch or single) hosted feature services in ArcGIS Online. Requires ArcGIS Desktop 10.2+
from __future__ import print_function
import time
import json
import os
import tortilla
from requests.packages import urllib3
import arcpy
@amarinelli
amarinelli / item_details.py
Created March 25, 2015 16:31
Get a formatted JSON representation of an item's data hosted in ArcGIS Online
import json
import tortilla
class AGOL:
""" A class for administering an ArcGIS Online account"""
def __init__(self, in_username, in_password, expiration=60):
self.agol = tortilla.wrap('https://www.arcgis.com')
self.username = in_username
self.password = in_password
@amarinelli
amarinelli / leaflet-geojson-esri.html
Last active August 29, 2015 14:17
Leaflet GeoJSON (esri): Leaflet AJAX // source http://jsbin.com/debolatopa
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=1024, user-scalable=no">
<style>
html { height: 100% }
body { height: 100%; margin: 0; padding: 0;}
#map{ height: 100% }
@amarinelli
amarinelli / IIFE.js
Created January 13, 2015 20:41
Sample JS template for writing an IIFE
// Code goes here
(function() {
var createWorker = function() {
var workCount = 0;
var task1 = function() {
workCount += 1;
@amarinelli
amarinelli / consolidate_layers.py
Created January 9, 2015 22:30
This script using arcpy to consolidate all the feature layers in a map document into a single File GDB
import arcpy
import time
import os
mxd = arcpy.mapping.MapDocument(r'C:\<path>\<to>\<map>.mxd')
dfs = arcpy.mapping.ListDataFrames(mxd)
file_gdb = r'C:\<path>\<to>\<file>.gdb'
@amarinelli
amarinelli / list_layer_mapservice.py
Created November 16, 2014 16:51
List the layers in an AGS map service using the REST endpoint
import urllib2
import json
content = urllib2.urlopen("http://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer/layers?f=pjson").read()
service = json.loads(content)
for layer in service['layers']:
print layer['name'], ":", layer['type']