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 requests, json, geopandas as gpd | |
def remoteGeoJSONToGDF(url, display = False): | |
"""Import remote GeoJSON to a GeoDataFrame | |
Keyword arguments: | |
url -- URL to GeoJSON resource on web | |
display -- Displays geometries upon loading (default: False) | |
""" | |
r = requests.get(url) | |
data = r.json() |
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 csv | |
with open('output.csv', 'w', newline = '') as csvfile: | |
writer = csv.writer(csvfile) # Create writer object | |
writer.writerow(['Column 1', 'Column 2', 'Column 3', 'Column 4']) # Define the header row | |
with arcpy.da.SearchCursor('input_layer', ['Field1', 'Field2', 'Field3', 'Field4']) as cursor: # Define cursor object | |
for row in cursor: | |
writer.writerow([row[0], row[1], row[2], row[3]]) # Write values from each item in cursor to csv |
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
csvs-to-sqlite tbl.csv tbl.db && \ | |
curl "<URL to enpoint and/or query that returns GeoJSON>" | \ | |
ogr2ogr -f geojson -nln input /vsistdout/ /vsistdin/ | \ | |
ogr2ogr -f geojson \ | |
-dialect sqlite \ | |
-sql "select input.*, tbl.* from inputjoin 'tbl.db'.tbl AS tbl on input.<primary key> = tbl.<foreign key>" \ | |
output.geojson /vsistdin/ && \ | |
del tbl.db |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
ffmpeg -i animated.gif -movflags faststart -pix_fmt yuv420p -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" video.mp4 |
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 pandas as pd | |
df = pd.DataFrame({'a': [1,2,3], 'b': [2,3,4], 'c':['dd','ee','ff'], 'd':[5,9,1]}) | |
df['e'] = df[['a', 'b', 'd']].sum(axis = 1) | |
######################### | |
## RESULT ## | |
######################### | |
# a b c d e # COLUMNS | |
# 0 1 2 dd 5 8 # ROW |
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 quantile_bins(quantiles, min = 0, max = 100): | |
"""Return a list of quantiles including floor and ceiling values | |
Args: | |
quantile (list): Quantile values in order | |
min (numeric): Floor value of data range | |
max (numeric): Ceiling value of data range | |
Returns: | |
list: An inclusive list of quantile bin 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
def quantile_percentiles(quantile_count: int = 5) -> list: | |
"""Return quantile percentile values for a given number of quantiles. | |
Args: | |
quantile_count (int): Number of quantiles to generate percentile values for (default 5) | |
Returns: | |
list: Equally spaced quantile percentile values based on quantile_count | |
Examples: |
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
-- ABOUT ----------------------------------------------------------------------- | |
-- This script is meant to outline a procedure for updating a PostgreSQL table | |
-- with the latest features even if there are views that depend on the table. | |
-- In other words, this method allows you to update the table without deleting | |
-- it and recreating it with the latest data. There are definitely some | |
-- opportunities for improvement - there may be a bit too much redundancy - but | |
-- this should get the job done, especially on datasets where size is trivial. | |
-------------------------------------------------------------------------------- | |
-- NOTES ----------------------------------------------------------------------- |