This file contains hidden or 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 xml.etree.ElementTree as ET | |
from lxml import etree | |
import pandas as pd | |
xml_data = "%s/rasters/wtshds_%s.aux.xml" % (out,rpu) | |
def xml2df(xml_data): | |
tree = ET.parse(xml_data) | |
root = list(list(tree.getroot())[0])[1] | |
all_records = [] |
This file contains hidden or 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
from IPython.display import HTML | |
################################ | |
HTML('''<script> | |
code_show=true; | |
function code_toggle() { | |
if (code_show){ | |
$('div.input').hide(); | |
} else { | |
$('div.input').show(); | |
} |
This file contains hidden or 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 re | |
def dms2dec(dms_str): | |
"""Convert coordinates in DMS notation to decimal | |
Author: https://github.com/jeteon """ | |
dms_str = re.sub(r'\s', '', dms_str) | |
sign = -1 if re.search('[swSW]', dms_str) else 1 | |
numbers = filter(len, re.split('\D+', dms_str, maxsplit=4)) | |
degree = numbers[0] | |
minute = numbers[1] if len(numbers) >= 2 else '0' | |
second = numbers[2] if len(numbers) >= 3 else '0' |
This file contains hidden or 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 getWKTio(epsg) : | |
import urllib | |
from bs4 import BeautifulSoup | |
html = 'http://epsg.io/{}'.format(epsg) | |
r = urllib.urlopen(html) | |
data = r.read() | |
soup = BeautifulSoup(data, "html") | |
for tag in soup.find_all('pre'): | |
if tag.get('id') == 's_esriwkt_text': | |
return tag.contents |
This file contains hidden or 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 pandas as pd | |
import geopandas as gpd | |
def main(ptDF, lnDF): | |
# handle null geometries in point DF | |
ptDF = ptDF[~ptDF.geometry.isnull()] | |
# handle crs issues if geographic | |
ptDF.to_crs({'init': u'epsg:5070'}, inplace=True) | |
lnDF.to_crs({'init': u'epsg:5070'}, inplace=True) | |
shplyLineString = lnDF.ix[0].geometry |
This file contains hidden or 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
weird = gpd.read_file('./temp/LakeBoundaryMatch/TOTAL.shp') | |
money = gpd.GeoDataFrame() | |
for idx, row in weird.iterrows(): | |
for shp in row.geometry: | |
mn = gpd.GeoDataFrame({'comid1':[row.comid1],'comid2':[row.comid2], 'VPU':[row.VPU]},geometry=pts) | |
money = pd.concat([money, mn]) |
This file contains hidden or 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 itertools | |
import rasterio as rs | |
import geopandas as gpd | |
from rasterio.crs import CRS | |
from rasterio import features | |
def makeAffine(tf, lbl, w, h): | |
if lbl == 'A': | |
return tf | |
if lbl == 'B': |
This file contains hidden or 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 os | |
import rasterio | |
import numpy as np | |
home = 'L:/Priv/CORFiles/Geospatial_Library/Data/Project/StreamCat/LandscapeRasters/QAComplete' | |
tifs = [] | |
for x in os.listdir(home): | |
if ".tif" in x and "mar14" in x and not 'xml' in x and not 'ovr' in x: | |
print x | |
tifs.append(x) |
This file contains hidden or 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 numpy as np | |
import geopandas as gpd | |
from geopandas.tools import sjoin | |
NHD_dir = "D:/NHDPlusV21" | |
inputs = np.load('%s/StreamCat_npy/zoneInputs.npy' % NHD_dir).item() | |
pt_file = "C:/Users/Rdebbout/Downloads/Stations_albers.shp" | |
pts = gpd.GeoDataFrame.from_file(pt_file) | |
l = "/NHDPlus" |
This file contains hidden or 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, os, sys | |
from arcpy import env | |
inputs = {'CA':['18'],'CO':['14','15'],'GB':['16'],'GL':['04'],'MA':['02'],'MS':['05','06','07','08','10L','10U','11'],'NE':['01'],'PN':['17'],'RG':['13'],'SA':['03N','03S','03W'],'SR':['09'],'TX':['12']} | |
# process one coordinate at a time, locating routes for all hydroregions before looping to next coordinate set | |
# note that once the flowlines are converted into routes, all attribute information will get dropped, we will process the Locate Routes tool again to determine COMID (to get to stream order) for all sites that fail the checks | |
sites = 'D:/Projects/WEMAP_WSA/SplitCatsNAD83/xyLayer_join.shp' |