Skip to content

Instantly share code, notes, and snippets.

Cindy Jayakumar cindygis

Block or report user

Report or block cindygis

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View transferDomainsToFields.py
#
# @author Cindy Jayakumar
# @date 21/07/2018
#
# Extract domains from a field in one feature class, and apply
# it to matching fields in another feature class.
#
import arcpy
@cindygis
cindygis / attachGoogleMapsURL.py
Created May 2, 2018
Adds a field to a point feature class containing a link to launch Google Maps with directions from the current location of the device to the destination point.
View attachGoogleMapsURL.py
#
# @author Cindy Jayakumar
#
# @date 12/05/2018
#
# Adds a field to a point feature class containing a link
# to launch Google Maps with directions from the current
# location of the device to the destination point.
#
# Can be used for navigating to sites while in the field,
@cindygis
cindygis / getUniqueFieldValues.py
Created Nov 15, 2017
Methods to get a unique list of values from a field in a feature class
View getUniqueFieldValues.py
import arcpy as ap
import numpy as np
import timeit
lyr = ap.mapping.Layer(r"C:\Some\Arb\Folder\test.gdb\test")
field_name = "NAME"
# Method 1: Python
unique_values = list(set(row[0] for row in ap.da.SearchCursor(lyr, field_name)))
@cindygis
cindygis / alterCamelCaseAlias.py
Last active Oct 5, 2017
How to insert a space between camel case, lest I ever forget again
View alterCamelCaseAlias.py
#
# @date 05/10/2017
# @author Cindy Jayakumar
#
# Change the alias of feature classes to the
# title case version of the CamelCase name
#
# e.g. WaterPumpStation => Water Pump Station
import arcpy
View makequerytablebug.md

http://desktop.arcgis.com/en/arcmap/10.3/tools/data-management-toolbox/make-query-table.htm

When inputting the optional SQL clause, ArcGIS automatically adds quotation marks "" to the field names in the dialog box. This will pass the tool's error checking successfully but will cause the tool to fail with an error.

If you verify the SQL clause in the dialog box, it will give a SQL error with no specifics. When adding the clause, remember to remove the quotation marks.

e.g. If you want to join Layer1 to Layer 2 on common field ID and where Layer 1 contains "Cape Town", ArcGIS will format your expression in the following way:

@cindygis
cindygis / duplicatePoint.py
Created Feb 9, 2017
Uses the geometry of a selected point in one layer to insert new points with selected attributes from a different layer.
View duplicatePoint.py
'''
@author Cindy Jayakumar
@date 31/01/2017
- Inserts a new point with the selected geometry in to_lyr
- Adds attributes to that point from from_lyr
- Updates the record in from_lyr
Uses selected features
@cindygis
cindygis / changeDelimiterInCSV.py
Created Jul 19, 2016
Replaces the delimiter in a csv file
View changeDelimiterInCSV.py
'''
@date 19/07/2016
@author Cindy Williams-Jayakumar
Replaces the delimiter in a csv file
using the pathlib library in Python 3
'''
import csv
@cindygis
cindygis / createTableFieldsFromXLS.py
Created May 5, 2016
Converts a spreadsheet containing field names and aliases into a file geodatabase table.
View createTableFieldsFromXLS.py
'''
@date 09/07/2013
@author Cindy Williams
Converts a spreadsheet containing field names and aliases
into a file geodatabase table.
'''
import arcpy
xls = r"C:\Some\Arb\Folder\test.xlsx\Fields$"
@cindygis
cindygis / reverseGeocodeXLScoords.py
Created Apr 21, 2016
Quickly reverse geocode coordinates in a spreadsheet
View reverseGeocodeXLScoords.py
import geocoder
import pandas as pd
xls = r'C:\Some\Arb\Folder\coords.xls'
out_xls = r'C:\Some\Arb\Folder\geocoded.xls'
df = pd.read_excel(xls)
for index, row in df.iterrows():
g = geocoder.google([row[3], row[2]], method='reverse')
df.set_value(index, 'Street Address', g.address)
@cindygis
cindygis / filterDataFrameUsingMask.py
Created Dec 17, 2015
Filters a pandas data frame using a mask
View filterDataFrameUsingMask.py
import pandas as pd
in_xls = r"C:\Some\Arb\Folder\test.xlsx"
columns = [0, 2, 3, 4, 6, 8]
# Use a function to define the mask
# to create a subset of the data frame
def mask(df, key, value):
return df[df[key] == value]
You can’t perform that action at this time.