Skip to content

Instantly share code, notes, and snippets.

@uekeueke
uekeueke / mergepols.sql
Created February 21, 2016 20:02
merge pols function postgis
CREATE OR REPLACE FUNCTION test(VARIADIC param_geoms geometry[])
RETURNS geometry AS
$$
DECLARE result geometry := param_geoms[1];
BEGIN
IF array_upper(param_geoms,1)>1 AND NOT ST_IsEmpty(param_geoms[1]) THEN
FOr i IN2 .. array_upper(param_geoms,1) LOOP
result := ST_Intersection(result, param_geoms[i]);
IF ST_IsEmpty(result) THEN
SELECT
sum(cast(pob2013 as real))
FROM iaac_parcelar02
with markets as (
select * from iaac_cac where bcn3 = 'MERCATS')
,
nonmarkets as (
select * from iaac_cac where bcn3 != 'MERCATS'
)
select
row_number() over() as cartodb_id,
count(*),
markets.the_geom_webmercator as the_geom_webmercator
@uekeueke
uekeueke / gist:abb459d8e7f5a9be845c
Created September 7, 2015 10:11
reset password postgres
# sudo -u postgres psql
could not change directory to "/root"
psql (9.1.11)
Type "help" for help.
postgres=# \password
Enter new password:
Enter it again:
postgres=# \q
#
@uekeueke
uekeueke / gist:1809aef185a03c34764c
Last active September 7, 2015 07:58
con my server
https://trac.osgeo.org/postgis/wiki/UsersWikiPostGIS21UbuntuPGSQL93Apt
https://www.digitalocean.com/community/tutorials/how-to-install-and-use-postgresql-on-ubuntu-14-04
apt-get install postgresql-9.4
sudo apt-get install postgresql-9.4-postgis-2.1 pgadmin3 postgresql-contrib
createuser -d -E -i -l -P -r -s uekeueke
@uekeueke
uekeueke / gist:c68e4d1528f1e31ade57
Created September 7, 2015 07:17
install postgis
https://www.digitalocean.com/community/tutorials/how-to-install-and-use-postgresql-on-ubuntu-14-04
How To Install and Use PostgreSQL on Ubuntu 14.04
How To Install and Use PostgreSQL on Ubuntu 14.04
Apr 28, 2014 PostgreSQL Ubuntu
Introduction
Relational database management systems are a key component of many web sites and applications. They provide a structured way to store, organize, and access information.
Uninstall just postgis
sudo apt-get remove postgis
This will remove just the postgis package itself.
Uninstall postgis and it's dependencies
sudo apt-get remove --auto-remove postgis
This will remove the postgis package and any other dependant packages which are no longer needed.
Purging your config/data too
If you also want to delete your local/config files for postgis then this will work.
-- Table: "cpMad"
-- DROP TABLE "cpMad";
CREATE TABLE "cpMad"
(
id serial NOT NULL,
geom geometry(MultiPolygon,25830),
id_cp character varying(254),
postal_cod character varying(254),
-- Table: categorias25830
-- DROP TABLE categorias25830;
CREATE TABLE categorias25830
(
pid serial NOT NULL,
geom geometry(Point,25830),
merchant_category_key character varying,
merchant_sub_category_key character varying,
-- Table: agg_barrio_dis_mens
-- DROP TABLE agg_barrio_dis_mens;
CREATE TABLE agg_barrio_dis_mens
(
geom geometry(MultiPolygon,25830),
geocodigo character varying(15),
sum_dif double precision,
es_barsandrestaurants double precision,