This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
keys = ['a', 'b', 'c'] | |
values = [1, 2, 3] | |
dictionary = dict(zip(keys, values)) | |
#result looks like this {'a': 1, 'b': 2, 'c': 3} | |
# ordered dictionary | |
import collections | |
keys = ['a', 'b', 'c'] | |
values = [1, 2, 3] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE OR REPLACE FUNCTION ST_CreateFishnet( | |
nrow integer, ncol integer, | |
xsize float8, ysize float8, | |
x0 float8 DEFAULT 0, y0 float8 DEFAULT 0, | |
OUT "row" integer, OUT col integer, | |
OUT geom geometry) | |
RETURNS SETOF record AS | |
$$ | |
SELECT i + 1 AS row, j + 1 AS col, ST_Translate(cell, j * $3 + $5, i * $4 + $6) AS geom | |
FROM generate_series(0, $1 - 1) AS i, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import shapefile | |
import shapely | |
#Load the shapefile of polygons and convert it to shapely polygon objects | |
polygons_sf = shapefile.Reader("C:/PolygonShapeFile.shp") | |
polygon_shapes = polygons_sf.shapes() | |
polygon_points = [q.points for q in polygon_shapes ] | |
from shapely.geometry import Polygon | |
polygons = [Polygon(q) for q in polygon_points] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ftplib | |
import os | |
import sys | |
import subprocess | |
from optparse import OptionParser | |
from datetime import datetime | |
DB_USER = 'databaseuser' | |
DB_NAME = 'databasename' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from os.path import isfile, join | |
import shutil | |
my_path = "/home/username/Pictures" | |
file_types = ('.JPG', '.jpg', '.AVI') | |
year = '2010' | |
destination_folder = "/home/username/Pictures/final_2010" | |
for root, dirs, files in os.walk(my_path): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BoundingBox(coordinate_list): | |
""" | |
Return a 2D bounding box from a set of points | |
Example input: mypoints = [(0,2),(3,4),(5,6)] | |
Example Usage: BoundingBox(mypoints) | |
Example Usage: bbox = BoundingBox(mypoints) | |
bbox.width | |
bbox.height | |
bbox.centroid | |
""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--QGIS 3 Ubuntu 16.04 | |
sudo sh -c 'echo "deb https://qgis.org/ubuntugis xenial main" >> /etc/apt/sources.list' | |
sudo sh -c 'echo "deb-src https://qgis.org/ubuntugis xenial main" >> /etc/apt/sources.list' | |
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable | |
wget -O - https://qgis.org/downloads/qgis-2017.gpg.key | gpg --import | |
gpg --fingerprint CAEB3DC3BDF7FB45 | |
gpg --export --armor CAEB3DC3BDF7FB45 | sudo apt-key add - |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# source: https://dev.to/mariamxl | |
# https://dev.to/mariamxl/dijkstras-algorithm-in-python-algorithms-for-beginners-dkc | |
from collections import deque, namedtuple | |
# we'll use infinity as a default distance to nodes. | |
inf = float('inf') | |
Edge = namedtuple('Edge', 'start, end, cost') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// using font awesome 5 free version | |
var faFlagSolidStyle = new ol.style.Style({ | |
text: new ol.style.Text({ | |
text: '\uf024', // fas flag solid | |
scale: 1, | |
font: 'normal 18px FontAwesome', | |
offsety: -30, | |
offsetx: -10, | |
fill: new ol.style.Fill({color: 'black'}), | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<filter> | |
<filter-name>CorsFilter</filter-name> | |
<filter-class>org.apache.catalina.filters.CorsFilter</filter-class> | |
<init-param> | |
<param-name>cors.allowed.origins</param-name> | |
<param-value>*</param-value> | |
</init-param> | |
<init-param> | |
<param-name>cors.allowed.methods</param-name> | |
<param-value>GET,POST,HEAD,OPTIONS,PUT</param-value> |