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 json | |
import ogr | |
driver = ogr.GetDriverByName('ESRI Shapefile') | |
shp_path = r'C:\GIS\Temp\Counties.shp' | |
data_source = driver.Open(shp_path, 0) | |
fc = { | |
'type': 'FeatureCollection', | |
'features': [] |
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
UPDATE DBO.CITIES SET TYPE = 0 WHERE TYPE IS NULL | |
ALTER TABLE DBO.CITIES | |
ALTER COLUMN TYPE NVARCHAR(25) NOT NULL | |
--create FK for feature class Cities and store legal values for the attribute Type in the table CityType | |
ALTER TABLE DBO.CITIES DROP CONSTRAINT FK_CITYTYPES | |
DROP TABLE CityType | |
GO |
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
'''Python add-in that will find multiple k-alternate paths between a given number of stops. | |
This code is supposed to be run in ArcMap map document with a Route Network Analysis layer | |
named Route with at least two stops loaded. The impedance attribute name is read from a | |
Route solver properties object.''' | |
import os | |
import arcpy | |
import arcpy.mapping as mp | |
import pythonaddins |
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
using System; | |
using ArcGIS.Core.Hosting; | |
using ArcGIS.Core.Data; | |
namespace SimplePro | |
{ | |
public class DataManagement | |
{ | |
public static string GetObjectIDField(string path, string shapefile) | |
{ |
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
'''Find difference in gp tools between Pro and Desktop''' | |
import json | |
pro_tools = dict(json.load(open(r"C:\GIS\Temp\Pro_tools.json"))) | |
desktop_tools = dict(json.load(open(r"C:\GIS\Temp\Desktop_tools.json"))) | |
#to get tools present in Pro but not in Desktop | |
for tbx, tools in pro_tools.iteritems(): | |
print(tbx) | |
for i in [str(tool) for tool in tools if tool not in desktop_tools.get(tbx,[])]: | |
print(i) |
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
'''This is an ArcGIS Python add-in class for calculating the distance and the time | |
between the two selected by user Route network analysis layer stops. This code is | |
supposed to be wrapped into a Python add-in, but can also be executed as a standalone | |
script tool with minor modifications. This code assumes that the route has been | |
already solved and there are accumulators associated with the route solver''' | |
import arcpy | |
import arcpy.mapping as mp | |
import pythonaddins | |
arcpy.env.overwriteOutput = True |
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
'''This code will export the attachments associated with a feature class features into | |
a folder naming output files using the feature's attribute provided''' | |
import arcpy | |
import os | |
##define input parameters for the tool | |
#input attachments table | |
in_table = arcpy.GetParameterAsText(0) | |
#output folder to save files in | |
file_location = arcpy.GetParameterAsText(1) |
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 | |
arcpy.env.overwriteOutput = True | |
#---------------------------------------------------------------------- | |
def create_convex_hull(in_fc, grouping_field=None): | |
""" | |
generate convex hull features optionally grouping input features; | |
if no grouping_field specified, a single Convex Hull will be generated | |
for all input features | |
""" |
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
''' | |
This code provides access to a map document layout MapsurroundElement such as scale bar. | |
In order to use this code, you would need to have a map document with a pre-created | |
scale bar. | |
''' | |
import sys | |
from comtypes.client import GetModule, CreateObject | |
from snippets102 import GetStandaloneModules, InitStandalone |
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
''' | |
This code shows how to hide/show map grids in a map document before exporting the map. | |
This can be handy when you have multiple grids with different grid cell size and you | |
want to be able to control at what map scales each of the map grids should be visible. | |
As this is not exposed via arcpy, you have to use ArcObjects. | |
This code assumes there are two grids for the data frame with the name `small` and `large` | |
''' | |
import sys | |
from comtypes.client import GetModule, CreateObject |