View randomFCSample.py
import arcpy
import numpy as np
def randomFCSample(fc, fd='sample_fd', sample_field='OBJECTID', sample_pct=10):
count_class = arcpy.GetCount_management(fc)
count = int(count_class[0])
random_vals = np.random.choice(count, int(count*(sample_pct/100)))
arcpy.MakeFeatureLayer_management(fc,
fd + "_" + str(sample_pct) + 'pct',
sample_field + ' IN ' + str(tuple(random_vals)))
View test_track.geojson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View TEMPLATE.mapx
{
"type" : "CIMMapDocument",
"version" : "2.0.0",
"build" : 8933,
"mapDefinition" : {
"type" : "CIMMap",
"name" : "TEMPLATE",
"uRI" : "CIMPATH=map6/map6.xml",
"sourceModifiedTime" : {
"type" : "TimeInstant"
View qgis-osx-error-solved.md

I installed QGIS (KyngChaos) after installing Miniconda. When I would open QGIS, I'd get an error about MetaSearch not started because requests couldn't be found. How I got things working again

Alias system Python 2.7 (This may be optional)

sudo alias python2=/usr/bin/python2.7

Get a copy of get-pip.py and use it to install pip

sudo /usr/bin/python2.7 /Users/maptastik/get-pip.py

View GDBtoPostGIS.md

Generally I can use QGIS and its DBManager to import data into a PostGIS database. Sometimes that doesn't work perfectly. ogr2ogr can help though. Running this little command seems to work (Source)

ogr2ogr -overwrite -f "PostgreSQL" PG:"host=<host> user=<username> dbname=<db name> password=<password> port=<port #>" "C:\some.gdb" "<feature class>" -nln <new table name> -nlt <geometry type>
View UsefulSQL.md

Get a list of duplicate records and how many duplicates there of that record

SELECT DISTINCT SOME_FIELD, count(*)
FROM SOME_TABLE
GROUP BY SOME_FIELD
HAVING count(*) > 1

Spatial join based that adds polygon values (b) to intersecting point features (a). Be aware that this does not return a value for those points that are outside a polygon feature

View agolToDF.py
import pandas as pd
from arcgis.gis import GIS
# Login to AGOL
gis = GIS()
# For other login methods see: https://developers.arcgis.com/python/guide/working-with-different-authentication-schemes/
# use for logging in within active ArcGIS Pro session
# gis = GIS('pro')
View IntroToSQLForDataScience_Notes.md

Get a list of distinct values for a column in a table

SELECT DISTINCT column FROM table;

Get the count of rows in a table

SELECT COUNT(*) FROM table;
View nullVsZeroShp.py
def calc(main_code, field_list):
if sum(field_list) == 0:
return -1
else:
return main_code
View geocode.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.