Skip to content

Instantly share code, notes, and snippets.

View kylefelipe's full-sized avatar
😀

Kyle Felipe kylefelipe

😀
View GitHub Profile
@maptastik
maptastik / ogrIntoPostGIS.md
Last active March 15, 2024 14:27
Import data into PostGIS with ogr2ogr#

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. Here are a few approaches to getting data into PostGIS with ogr2ogr.

This is probably the most basic approach:

 ogr2ogr -f "PostgreSQL" PG:"dbname=<db name> user=<username> password=<password> host=<host> port=<port #>" input.geojson -nln schema.table

Running this little command seems to work if you have need to specify the geometry type (Source):

@sirkonst
sirkonst / config.fish
Last active March 31, 2022 20:56
fish config for pyenv (~/.config/fish/config.fish)
set PYENV_ROOT $HOME/.pyenv
set -x PATH $PYENV_ROOT/bin $PATH
status --is-interactive; and . (pyenv init -|psub)
status --is-interactive; and . (pyenv virtualenv-init -|psub)
set -x VIRTUAL_ENV_DISABLE_PROMPT 1
@boniattirodrigo
boniattirodrigo / removerAcentosECaracteresEspeciais.py
Last active December 28, 2023 18:38
Remover acentos e caracteres especiais em Python
import unicodedata
import re
"""
A remoção de acentos foi baseada em uma resposta no Stack Overflow.
http://stackoverflow.com/a/517974/3464573
"""
def removerAcentosECaracteresEspeciais(palavra):
/* Function: ST_Buffer_Meters(geometry, double precision)
DROP FUNCTION ST_Buffer_Meters(geometry, double precision);
Usage: SELECT ST_Buffer_Meters(the_geom, num_meters) FROM sometable; */
CREATE OR REPLACE FUNCTION ST_Buffer_Meters(geometry, double precision)
RETURNS geometry AS
$BODY$
DECLARE
orig_srid int;
@lptorres
lptorres / multi2single.py
Created December 4, 2013 01:55
A simple script that converts shapefiles with multipart polygons into singlepart polygons, and copies the fields of the source shapefile. This script is based on a script by Paolo Corti, found here: https://gist.github.com/anonymous/735330 The original script only converts multipolygons by creating a new feature for each part of a multipolygon. …
import os
from osgeo import gdal, ogr, osr
import sys
def initFields(in_lyr, out_lyr):
#Arbitrarily get the first feature
feat = in_lyr[0]
#loop over each field