Skip to content

Instantly share code, notes, and snippets.

# -*- coding: utf-8 -*-
from PyQt5.QtCore import QCoreApplication
from qgis.core import (QgsProcessing,
QgsFeatureSink,
QgsProcessingAlgorithm,
QgsProcessingParameterFeatureSource,
QgsProcessingParameterFeatureSink)
import processing
# -*- coding: utf-8 -*-
"""
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
@ghtmtt
ghtmtt / gist:b719344c6170ea2504a7
Created November 19, 2015 17:46
no plot plotly
In [1]: from plotly.offline import download_plotlyjs, init_notebook_mode, iplot
In [2]: init_notebook_mode()
<IPython.core.display.HTML object>
In [3]: iplot([{"x": [1, 2, 3], "y": [3, 1, 6]}])
<IPython.core.display.HTML object>
<IPython.core.display.HTML object>
# -*- coding: utf-8 -*-
from PyQt5.QtCore import QCoreApplication, QVariant
from qgis.core import (QgsProcessing,
QgsFeatureSink,
QgsField,
QgsFields,
QgsProcessingUtils,
QgsProcessingException,
QgsProcessingAlgorithm,
@ghtmtt
ghtmtt / geocoding.py
Last active September 14, 2021 04:40
Geocoding in QGIS Field Calculator
# the function needs geopy
# for Windows users, to install geopy, open the OSGEO4W Shell and type:
# py3_env
# pip3 install geopy
from qgis.core import *
from qgis.gui import *
from geopy.geocoders import Nominatim
locator = Nominatim(user_agent="myGeocoder")
@ghtmtt
ghtmtt / qgis_network_analysis.py
Created July 8, 2021 06:48
qgis_network_analysis
project = QgsProject.instance()
start_points = project.mapLayersByName('start_points')[0] # start
end_points = project.mapLayersByName('end_points')[0] # end
network = project.mapLayersByName('network')[0] # network
## from polyline to director
director = QgsVectorLayerDirector(
source=network,
# -*- coding: utf-8 -*-
"""
/***************************************************************************
DataPlotlyDialog
A QGIS plugin
D3 Plots for QGIS
-------------------
begin : 2020-08-17
git sha : $Format:%H$
copyright : (C) 2017 by matteo ghetta
import ee
from ee_plugin import Map
# Sentinel data
collection = ee.ImageCollection('COPERNICUS/S5P/OFFL/L3_NO2')
# Band of NO2
collection = collection.select('tropospheric_NO2_column_number_density')
# 2019 data
collection2019 = collection.filterDate('2019-03-01', '2019-04-30')
# -*- coding: utf-8 -*-
"""
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
import pandas as pd
import plotly.express as px
df = pd.read_csv("https://gist.github.com/ghtmtt/66164cc25a7b160cef99fa61b2feca59/raw/3034facfdecf7358934d9f0a78341c4d13f2af47/covid-pandas.csv")
col = [col for col in df.columns if '20' in col]
dfm = pd.melt(
df,
id_vars=["Province/State", "Country/Region", "continent", "Lat", "Long"],
value_vars=col,