Skip to content

Instantly share code, notes, and snippets.

View mtreg's full-sized avatar

Mike Treglia mtreg

View GitHub Profile
@neogis-de
neogis-de / postgis_split_polygons.sql
Created November 12, 2015 09:09
postgis split polygons with polygons
CREATE TABLE public.testpolygons1
(
gid serial PRIMARY KEY,
geom geometry(Polygon,3857)
);
CREATE TABLE public.testpolygons2
(
gid serial PRIMARY KEY,
geom geometry(Polygon,3857)
@syafiqfaiz
syafiqfaiz / how-to-copy-aws-rds-to-local.md
Last active October 16, 2024 20:51
How to copy production database on AWS RDS(postgresql) to local development database.
  1. Change your database RDS instance security group to allow your machine to access it.
    • Add your ip to the security group to acces the instance via Postgres.
  2. Make a copy of the database using pg_dump
    • $ pg_dump -h <public dns> -U <my username> -f <name of dump file .sql> <name of my database>
    • you will be asked for postgressql password.
    • a dump file(.sql) will be created
  3. Restore that dump file to your local database.
    • but you might need to drop the database and create it first
    • $ psql -U <postgresql username> -d <database name> -f <dump file that you want to restore>
  • the database is restored
@planemad
planemad / Updating NYC building footprints.md
Created April 19, 2016 06:43 — forked from maning/Updating NYC building footprints.md
Refreshing NYC building footprints

NYC had an import of over 1 million building footprints and 900,000 addresses in 2014 from the New York City Department of Information Technology and Telecommunications (DoITT). The DoITT GIS releases an updated shapefile of the footprints every quarter, and the latest version can be accessed here: Building footprints | Address points

Open datasets like these are a great opportunity to explore how OSM can be used as a bridge between authoritative information and that crowdsourced by citizens. Two years after the import, it is interesting to see how the OSM data compares with the latest official footprints. The interesting questions to ask is:

  • What has improved in the DoITT footprints that can be updated in OSM?
  • What has
@timelyportfolio
timelyportfolio / .block
Created December 17, 2017 17:09
leaflet + plotly crosstalk no shiny
license: mit
library(tidycensus)
library(tmap)
library(tmaptools)
library(sf)
library(tigris)
library(magick)
library(tidyverse)
options(tigris_use_cache = TRUE)
ctys <- c("Dallas", "Tarrant", "Collin County", "Denton",
@ThomasG77
ThomasG77 / load_xyz_sources.py
Created February 27, 2018 15:48
PyQGIS script to save/load/wipe XYZ sources in Browser Panel in QGIS3
# -*- coding: utf-8 -*-
"""
/***************************************************************************
Name : XYZ manager
Description : Script to save/load/wipe WYZ sources in QGIS 3.0
Date : February 27, 2017
copyright : (C) 2017 by Thomas Gratier
email : thomas.gratier@webgeodatavore.com
fast_extract <- function(x, y, ...) {
## BEWARE no extract options are respected
raster::extract(x, sfpoly_cells(x, y))
}
sfpoly_cells <- function(rast, sfpoly) {
## BEWARE, could be a big-data, this is not
## sparsely specified, so it's wasteful on memory, but fast (if you have the mem)
which(!is.na(fasterize::fasterize(sfpoly, rast)[]))
}
@kgjenkins
kgjenkins / readme.md
Last active February 21, 2023 18:53
Interpolate points along lines using QGIS virtual layers

Interpolate points along lines using QGIS virtual layers

Suppose we want to interpolate a number of points along each line in a layer:

image

We have a column called stations that specifies how many points to interpolate on each line:

image