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
| # Update legend so it contains only Types present in the layer. | |
| # This script detaches the legend from automatic updates! | |
| # Change parameters to match the layer name, print_layout name, and the id of the legend element in the print layout | |
| layer_name = "PLOCHY S ROZDÍLNÝM ZPŮSOBEM VYUŽITÍ" | |
| layout_name = 'Layout 1' | |
| legend_id = "Legend" | |
| field_name = 'Typ' | |
| project = QgsProject.instance() |
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
| ogr2ogr -f "PostgreSQL" -a_srs "EPSG:4326" -lco SCHEMA=<schema> PG:"host=<ip or hostname> user=<user> password=<password> dbname=<dbname>" -nlt MULTIPOLYGON -nln <table_name> <shapefile_name>.shp |
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
| # given that you accidentally added a large file to git branch feature/adding, then removed it in another commit, you can reduce the repo size by the following commands | |
| # for more details and alternatives see https://confluence.atlassian.com/bitbucket/reduce-repository-size-321848262.html | |
| git checkout develop | |
| git merge --squash feature/adding | |
| git branch -D feature/adding | |
| #git reflog expire --expire=now --all | |
| git gc --prune=now | |
| git commit -m "Merged" |
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 sqlite3 | |
| from contextlib import closing | |
| import multiprocessing | |
| def prepare_db(db, tbl, col): | |
| sql = "CREATE TABLE {0} ({1} text);".format(tbl, col) | |
| with closing(sqlite3.connect(db)) as cnn: | |
| cursor = cnn.cursor() | |
| cursor.execute('DROP TABLE IF EXISTS {0};'.format(tbl)) | |
| cursor.execute(sql) |
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
| from osgeo import ogr, osr | |
| def read_splt(db): | |
| drvr = ogr.GetDriverByName('SQLite') | |
| ds = drvr.Open(db, 0) | |
| layer=ds.GetLayer('pts') | |
| for feature in layer: | |
| print(feature) | |
| break |
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 sys, os | |
| sys.path.insert(0, r'C:\OSGeo4W\apps\Python27\Lib\site-packages') | |
| #sys.path.insert(0, r'C:\OSGeo4W\lib') | |
| sys.path.insert(0, r'C:\OSGeo4W\bin') | |
| #os.environ['PATH'] = os.environ['PATH'] + ';' + r'C:\OSGeo4W\lib' | |
| os.environ['PATH'] = os.environ['PATH'] + ';' + r'C:\OSGeo4W\bin' |
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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>Minimal Leaflet</title> | |
| <link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.5/leaflet.css" /> | |
| <style> | |
| #map{ | |
| width: 150px; | |
| height:250px; | |
| } |
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
| # A trivial example for parallel computation using R snowfall package | |
| require(snowfall) | |
| sfInit(paralell=TRUE, cpus=2) | |
| fn <- function(x){ | |
| return(x*x) | |
| } | |
| d <- 1:1000 | |
| result <- sfLapply(d, fn) |
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
| # Convert between geojson and sp spatial objects in R | |
| require(rgdal) | |
| # https://stat.duke.edu/~cr173/Sta523_Fa14/spatial_data.html | |
| s <- '{ "type": "MultiPolygon", "coordinates": [ | |
| [ [[40, 40], [20, 45], [45, 30], [40, 40]] ], | |
| [ [[20, 35], [10, 30], [10, 10], [30, 5], [45, 20], [20, 35]], | |
| [[30, 20], [20, 15], [20, 25], [30, 20]] | |
| ] | |
| ]}' |
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
| # https://confluence.atlassian.com/display/STASH/Basic+Git+commands | |
| # simplest example | |
| git clone https://github.com/some/repo repo | |
| cd repo | |
| # make changes to files | |
| git commit -a -m "Commit message" | |
| # you can check status by `git status` | |
| git push origin master |
NewerOlder