Skip to content

Instantly share code, notes, and snippets.

View amarinelli's full-sized avatar
😅

Adam Marinelli amarinelli

😅
View GitHub Profile
@amarinelli
amarinelli / City_temp.py
Last active August 29, 2015 14:03
Get city temperature in °C using openweathermap API
# -*- coding: cp1252 -*-
# Using http://openweathermap.org/
import urllib2
import json
def Convert(k):
return k - 273.15
location = raw_input("Select a city: ")
@amarinelli
amarinelli / DateCalc.py
Last active August 29, 2015 14:04
Take 8 character string ("20140717") and turn into type Date
def CalcDate(string):
if (len(string) <> 8):
return
else:
return "{0}-{1}-{2}".format(string[:4], string[4:6], string[6:])
@amarinelli
amarinelli / sample.geojson
Created July 18, 2014 16:47
Sample GeoJSON file
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@amarinelli
amarinelli / Commute-Tracking.py
Created August 28, 2014 02:53
Attempt to calculate commuting time trends to work and back during rush hour
# Recording Daily Commute History
# West Queen West <----> North York
# Approx Route: Gardiner eastbound - D.V.P. northboutd - Eglinton Ave. E.
# Google Distance Matrix API
# https://developers.google.com/maps/documentation/distancematrix/
'''The departure time may be specified by Google Maps API for Business customers
for to specify the departure_time to receive trip duration considering current
traffic conditions. The departure_time must be set to within a few minutes of the current time.'''
@amarinelli
amarinelli / select_by_location.py
Created September 17, 2014 20:47
Sample 'Select by Location' using point geometry and query layer
import arcpy
point = arcpy.Point(592326.779, 6241287.454)
ref = arcpy.SpatialReference(26708) #SRID
ptGeometry = arcpy.PointGeometry(point, ref)
conn = r'Database Connections\CUTSP62__sde@GISDB.sde'
layer = "polygon"
@amarinelli
amarinelli / AddressRanges.py
Created September 25, 2014 18:32
Assign address ranges from point layer to road reference data
import arcpy
streets = []
#
#Search cursor code here to get list of streets
#
arcpy.MakeFeatureLayer_management("<file path>","roads_lyr")
arcpy.MakeFeatureLayer_management("<file path>","points_lyr")
@amarinelli
amarinelli / export_bands.py
Created September 29, 2014 15:35
Export all bands of raster imagery to a folder workspace
import arcpy
import os
in_raster = r"C:\gisworkspace\CASES\_DEVELOPMENT\156950\47_072.tif'"
out_folder = r"C:\gisworkspace\CASES\_DEVELOPMENT\156950"
desc = arcpy.Describe(in_raster)
for band in desc.children:
indiv_band = os.path.join(in_raster, band.name)
@amarinelli
amarinelli / get_json_file.js
Created September 29, 2014 18:53
Load .json file based on feature name from map click
require(["dojo/request/xhr"], function(xhr){
var category
feat = //code to get selected feature element
fcName = feat.attributes.Name;
fcType = feat.attributes.Type
//The following if statement does not cover all feature cases
//such as Ruins and Towns...
if (fcType == "City") {
category = "GoTCities"
} else if (fcType == "Castle") {
@amarinelli
amarinelli / export_attachments.py
Created October 6, 2014 15:25
Export BLOB feature class attachments to folder
from arcpy import da
import os
inTable = r'Database Connections\CUTSP62__sde@GISDB.sde\GISDB.SDE.Canada__ATTACH'
fileLocation = r"C:\Users\AMarinelli\Downloads\blob"
with da.SearchCursor(inTable,['DATA','ATT_NAME']) as cursor:
for row in cursor:
binaryRep = row[0]
@amarinelli
amarinelli / edit_service.py
Created October 20, 2014 20:38
Manage AGS Service scale levels and edit the service using REST API to include new max/min scales
'''
==Inputs== (starting at line 95)
server --> AGS machine name - (string)
port --> AGS port - (string)
adminUser --> administrator or publisher user - (string)
adminPass --> administrator or publisher password - (string)
service --> name of service starting with folder (if applicable) <name>.<type> notation - (string)
full_service_path --> path to the .ags connection file and the service folder and <name>.<type> notation - (string)
scales --> semicolon delimited list of scale values - (string)