Skip to content

Instantly share code, notes, and snippets.

View AlexArcPy's full-sized avatar

Alexey Tereshenkov AlexArcPy

View GitHub Profile
@AlexArcPy
AlexArcPy / get_not_null_fields.py
Last active January 31, 2016 08:10
Sample arcpy helper function - get not null fields
import arcpy
def get_fields(input_fc,only_field_type="String",not_null=True):
'''returns list of field names of specified data type and contain at
least one not NULL value'''
if not not_null:
all_fields = [field.name for field in arcpy.ListFields(in_fc,field_type=only_field_type)]
return all_fields
@AlexArcPy
AlexArcPy / arcpy_select_distinct.py
Last active January 31, 2016 08:11
Sample arcpy helper function
def select_distinct(input_fc,input_field):
'''returns a list of unique values in a field sorted'''
sql = (None, 'GROUP BY {0}'.format(input_field))
cur = arcpy.da.SearchCursor(in_table=input_fc,field_names=["{0}".format(input_field)],
sql_clause=sql)
unique_values = [f[0] for f in cur]
return sorted(unique_values)
@AlexArcPy
AlexArcPy / geodatabase_describe.py
Created March 1, 2016 16:27
Accessing properties of a geodatabase
import arcpy
path = r"C:\ArcTutor\Editing\Zion.gdb"
#obtaining individual properties
release = arcpy.Describe(path).release
workspaceType = arcpy.Describe(path).workspaceType
workspaceFactoryProgID = arcpy.Describe(path).workspaceFactoryProgID
#obtaining a dictionary of properties
@AlexArcPy
AlexArcPy / read_features.py
Created April 20, 2016 19:50
Calling fmeobjects with Python: FMEUniversalReader and FMEUniversalWriter
import sys
sys.path.append(r"C:\Program Files (x86)\FME\fmeobjects\python27")
from fmeobjects import *
import os
root_folder = r"C:\GIS\fme"
#----------------------------------------------------------------------
def read_features():
"""Reads all features within input shapefile, projects it and writes
@AlexArcPy
AlexArcPy / project_multiple_shapefiles.py
Created April 20, 2016 20:01
Call FME workbench from Python: FMEWorkspaceRunner and dynamic workspace
import sys
import os
sys.path.append(r"C:\Program Files (x86)\FME\fmeobjects\python27")
import fmeobjects
#----------------------------------------------------------------------
def project_multiple_shapefiles():
"""Finds all shapefiles in the input folder, projects and outputs
a projected feature type into output folder."""
try:
@AlexArcPy
AlexArcPy / buffer_single_shapefile_diff_param_values.py
Last active April 20, 2016 20:08
Call FME workbench from Python: FMEWorkspaceRunner
import sys
sys.path.append(r"C:\Program Files (x86)\FME\fmeobjects\python27")
import fmeobjects
#----------------------------------------------------------------------
def buffer_single_shapefile_diff_param_values():
"""
Processes the same shapefile specified in the FME workbench project
creating multiple output shapefiles with the distance appended to the
output file.
@AlexArcPy
AlexArcPy / booli.py
Created June 4, 2016 16:26 — forked from emilkaiser/booli.py
Booli API Python
import httplib
import time
from hashlib import sha1
import random
import string
import json
callerId = "YOUR_CALLER_ID"
timestamp = str(int(time.time()))
unique = ''.join(random.choice(string.ascii_uppercase + string.digits) for x in range(16))
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@AlexArcPy
AlexArcPy / citibike.ipynb
Created July 31, 2016 14:39 — forked from kjordahl/citibike.ipynb
Citibike data
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.