Skip to content

Instantly share code, notes, and snippets.

View 3nids's full-sized avatar

Denis Rouzaud 3nids

View GitHub Profile
@3nids
3nids / gist:8652202
Created January 27, 2014 16:45
convert geometry
bool QgsVectorLayer::convertToLayerGeometry( QgsGeometry &geometry )
{
QGis::GeometryType layerGeomType = geometryType();
QGis::GeometryType geomType = geometry.type();
switch ( geomType )
{
// geometry type is point
case QGis::Point:
{
@3nids
3nids / gist:9509690
Created March 12, 2014 15:51
copy/paste from/to layer
src = iface.activeLayer()
dst = QgsMapLayerRegistry.instance().mapLayer("cadastre20140312152032371")
featReq = QgsFeatureRequest().setSubsetOfAttributes([])
k = 0
features = []
nonCopied = []
for f in src.getFeatures(featReq):
k += 1
if k % 100 ==0:
@3nids
3nids / qgis_geocoder.py
Last active September 4, 2015 04:20
Simple QGIS geocoder
import geocoder
g = geocoder.google("[% "__MYADDRESSFIELD__" %]".replace("'", r"\'"))
if not g.latlng:
print "adress not found"
else:
pt = QgsPoint(g.latlng[1],g.latlng[0])
tr = QgsCoordinateTransform( QgsCoordinateReferenceSystem( 4326 , QgsCoordinateReferenceSystem.EpsgCrsId ),
QgsCoordinateReferenceSystem( __MYEPSG__, QgsCoordinateReferenceSystem.EpsgCrsId ))
pt = tr.transform( pt )
print pt.x(), pt.y()
#!/usr/bin/env bash
set -e
# git clone --depth=1 https://github.com/qgis/QGIS.git
export TRAVIS_BUILD_DIR=/Users/denis/Documents/qgis/QGIS
export DOCKER_TAG=docker
export DOCKER_PUSH=fase
export TRAVIS_PULL_REQUEST=false
@3nids
3nids / qgep_project_prefix.sh
Created May 22, 2018 18:07
Used to fix the field renames in QGEP project (prefix in views)
#!/usr/bin/env bash
REACH_START=9358
REACH_END=12307
WS_START=12308
WS_END=14472
echo "a"
@3nids
3nids / qgis3_cmake.sh
Created June 11, 2018 12:23
QGIS cmake
#!/usr/bin/env bash
export PATH=/usr/local/opt/qt/bin:/usr/local/opt/ccache/libexec:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin
export CMAKE_PREFIX_PATH="/usr/local/opt/qt;/usr/local/opt/qt5-webkit;/usr/local/opt/qscintilla2;/usr/local/opt/qwt;/usr/local/opt/qwtpolar;/usr/local/opt/qca;/usr/local/opt/gdal2;/usr/local/opt/gsl;/usr/local/opt/geos;/usr/local/Cellar/proj/4.9.3/;/usr/local/opt/libspatialite;/usr/local/opt/spatialindex;/usr/local/opt/fcgi;/usr/local/opt/expat;/usr/local/opt/sqlite;/usr/local/opt/flex;/usr/local/opt/bison;/usr/local/opt/libzip;"
export QGIS_NINJA_BUILD=1
cmake -GNinja \
git clone og:OSGeo4A
cd OSGeo4A
# edit recipes/qgis/recipe.sh -> zip file and md5
docker build . -t opengisch/qfield-sdk:RELEASENUMBER
docker push opengisch/qfield-sdk:RELEASENUMBER
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os.path
from qgis.PyQt.QtCore import QCoreApplication
from qgis.core import QgsProject, QgsApplication
from qgis.utils import iface
# This is a python script intended to be used within QGIS to split a project according to its map theme collection.
# It will produce as many project file as existing themes.
# Configure hereafter and run using:
@3nids
3nids / qgis_resize_rectangle_action.py
Created June 27, 2019 09:52
Action to resize rectangles in QGIS 3
layer = QgsProject.instance().mapLayer('[% @layer_id %]')
from math import sqrt
from PyQt5.QtWidgets import QDialog, QFormLayout, QLabel, QDoubleSpinBox, QComboBox, QDialogButtonBox
class RectDialog(QDialog):
def __init__(self, width, length):
QDialog.__init__(self)
self.layout = QFormLayout(self)
#!/usr/bin/env python3
from github import Github, GithubException
import argparse
import os
GH_TOKEN_ENV_VAR_NAME = 'GH_TOKEN'
GH_REPO_SLUG = 'opengisch/OSGeo4A'