This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import xlsxwriter | |
import arcpy | |
workbook = xlsxwriter.Workbook('ResearchAreas.xlsx') | |
worksheet = workbook.add_worksheet() | |
fc = r"C:\ArcTutor\GP Service Examples\ClipAndShip\ToolData\Zion.gdb\Research_areas" | |
fields = [f.name for f in arcpy.ListFields(fc) if f.name.upper() not in ("OBJECTID","SHAPE")] | |
rows = [r for r in arcpy.da.SearchCursor(fc,fields)] | |
rows_structured = [list(elem) for elem in rows] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import arcpy | |
import os | |
######################################################################## | |
class FeatureClass(object): | |
"""FeatureClass object""" | |
#---------------------------------------------------------------------- | |
def __init__(self,path): | |
"""Constructor for FeatureClass""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gdb = Geodatabase(path=r"C:\ArcTutor\Editing\Zion.gdb",initialize=True) | |
print gdb.featureClassesFullPaths | |
#[u'C:\\ArcTutor\\Editing\\Zion.gdb\\Springs', | |
#u'C:\\ArcTutor\\Editing\\Zion.gdb\\Tracts', | |
#u'C:\\ArcTutor\\Editing\\Zion.gdb\\Trails', | |
#u'C:\\ArcTutor\\Editing\\Zion.gdb\\Roads'] | |
fcs = gdb.feature_classes_objects | |
print fcs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import unicodecsv | |
csv_file = r"C:\GIS\temp\graffiti.csv" | |
#read as is | |
with open(csv_file,"rb") as f: | |
reader = unicodecsv.DictReader(f) | |
reader_rows = list(reader) | |
print reader_rows[:3] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import multiprocessing | |
from arcrest import AGSTokenSecurityHandler | |
from arcrest.ags.server import Server | |
from arcrest.common.geometry import Envelope | |
ags_admin_url = r"http://localhost:6080/arcgis/admin" | |
ags_security_handler = AGSTokenSecurityHandler(username="username", | |
password="password", | |
org_url=ags_admin_url) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
OlderNewer