Skip to content

Instantly share code, notes, and snippets.

View fjcerignoni's full-sized avatar

Felipe Cerignoni fjcerignoni

  • Kynetec
  • Piracicaba - SP
View GitHub Profile
-- public.st_safe_intersection()
CREATE OR REPLACE FUNCTION ST_Safe_Intersection(geom_a geometry, geom_b geometry)
RETURNS geometry
LANGUAGE plpgsql
IMMUTABLE STRICT
AS $function$
BEGIN
RETURN ST_Intersection(geom_a, geom_b);
EXCEPTION
"""
This script should be run from the Python consol inside QGIS.
It adds online sources to the QGIS Browser.
Each source should contain a list with the folowing items (string type):
[sourcetype, title, authconfig, password, referer, url, username, zmax, zmin]
You can add or remove sources from the sources section of the code.
Script by Klas Karlsson
#---------------------------------------------------------------------------------------------
# VAZIOS DO CADASTRO AMBIENTAL RURAL
#
# Autores: Felipe Cerignoni e Vinicius Guidotti
# Ultima atualização: 07/2022
#---------------------------------------------------------------------------------------------
# IMPORTING MODULES
import arcpy
from arcpy import env
gdal_rasterize -a rast -a_nodata NoData -l 1_pa_br_hidro_urbano_ibge -ts 155239 158459 -te -74.8973961 -34.79175510 -33.0613262 7.9120915 -ot UInt16 -co "TILED=YES" -co "BLOCKXSIZE=256" -co "BLOCKYSIZE=256" -co "COMPRESS=LZW" 1_pa_br_hidro_urbano_ibge.shp 1_pa_br_hidro_urbano_ibge.tif
gdal_rasterize -a rast -a_nodata NoData -l 2_pa_br_territorio_indigena_funai_h_2022 -ts 155239 158459 -te -74.8973961 -34.79175510 -33.0613262 7.9120915 -ot UInt16 -co "TILED=YES" -co "BLOCKXSIZE=256" -co "BLOCKYSIZE=256" -co "COMPRESS=LZW" 2_pa_br_territorio_indigena_funai_h_2022.shp 2_pa_br_territorio_indigena_funai_h_2022.tif
gdal_rasterize -a rast -a_nodata NoData -l 3_pa_br_territorio_indigena_funai_nh_2022 -ts 155239 158459 -te -74.8973961 -34.79175510 -33.0613262 7.9120915 -ot UInt16 -co "TILED=YES" -co "BLOCKXSIZE=256" -co "BLOCKYSIZE=256" -co "COMPRESS=LZW" 3_pa_br_territorio_indigena_funai_nh_2022.shp 3_pa_br_territorio_indigena_funai_nh_2022.tif
gdal_rasterize -a rast -a_nodata NoData -l 4_pa_br_ucs_pi_mma_2020 -ts 15
INSERT INTO spatial_ref_sys (srid,auth_name,auth_srid,srtext,proj4text) VALUES
(97823,'sr-org',7823,'PROJCS["Conica_Equivalente_de_Albers_Brasil",GEOGCS["GCS_SIRGAS2000",DATUM["D_SIRGAS2000",SPHEROID["Geodetic_Reference_System_of_1980",6378137,298.2572221009113]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Albers"],PARAMETER["standard_parallel_1",-2],PARAMETER["standard_parallel_2",-22],PARAMETER["latitude_of_origin",-12],PARAMETER["central_meridian",-54],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["Meter",1]]','+proj=aea +lat_1=-2 +lat_2=-22 +lat_0=-12 +lon_0=-54 +x_0=0 +y_0=0 +ellps=GRS80 +units=m +no_defs');
--DROP MATERIALIZED VIEW limites.pa_br_limite_line;
CREATE MATERIALIZED VIEW limites.pa_br_limite_line AS (
WITH dump AS (
SELECT (st_dump(geom)).geom FROM limites.pa_br_limite
)
SELECT row_number() OVER () as id, st_exteriorring(geom) as geom FROM dump
);
@fjcerignoni
fjcerignoni / atlas_postgis_addons.sql
Created December 13, 2022 14:10
Conjunto de funções espaciais para auxiliar os processamentos com dados geográficos do Atlas da Agropecuária Brasileira
-- Functions to help to process Atlas Layers
-------------------------------------------------------------------------------
-- ST_Safe_Intersection
-----------------------------------------------------------
-- Felipe Cerignoni ([email protected])
-- 2020
-----------------------------------------------------------
CREATE OR REPLACE FUNCTION ST_Safe_Intersection(geom_a geometry, geom_b geometry)
--=====================================================================================
-- CLEANING THE CAR
--=====================================================================================
-- Author: Felipe Cerignoni
-- Institution: Imaflora
-- Last update: 10/05/2021
--=====================================================================================
---------------------------------------------------------------------------------------
-- MATERIALIZED VIEW TO IDENTIFY ALL OVERLAPS------------------------------------------
CREATE MATERIALIZED VIEW car.pa_br_20210412_areaimovel_ovlps
import React from 'react';
// constraints_sample = {
// enableHighAccuracy: true,
// timeout: 5000,
// maximumAge: 0,
// };
export function useGeoLocation(constraints) {
const [location, setLocation] = React.useState(null);
@fjcerignoni
fjcerignoni / download-deter-data.py
Created September 15, 2020 13:31 — forked from andre-carvalho/download-deter-data.py
A simple example to download geography data of DETER Amazon project via WFS service using authentication.
"""
Download WFS
Download Shapefile DETER
Copyright 2020 TerraBrasilis
Usage:
download-deter-data.py
Options: