Skip to content

Instantly share code, notes, and snippets.

View trolleway's full-sized avatar
🎯
Python, PostGIS, PostgreSQL, GIS

Artem Svetlov trolleway

🎯
Python, PostGIS, PostgreSQL, GIS
View GitHub Profile
@trolleway
trolleway / qgis_hstore_search.py
Last active March 19, 2016 13:12
Python code. Search in hstore values for function editor in QGIS
"""
Define new functions using @qgsfunction. feature and parent must always be the
last args. Use args=-1 to pass a list of values as arguments
"""
from qgis.core import *
from qgis.gui import *
import re
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@trolleway
trolleway / config.py
Last active December 16, 2020 18:57
Post photo from web to vk.com in python
vk_gid = '' #user id
#obtain client_id from VK: create new standalone app at https://vk.com/editapp?act=create
vk_client_id = ''
vk_scope = 'wall,photos'
#open in browser https://oauth.vk.com/authorize?client_id=0000000000&scope=wall,photos&v=5.60&response_type=token&redirect_uri=https://oauth.vk.com/blank.html
#and paste token here
vk_token = ''
import requests
import urllib2
ngw_root = 'http://trolleway.nextgis.com'
ngw_creds = ('', '')
headers = {'Content-type': 'application/x-www-form-urlencoded'}
payload = {'file':urllib2.urlopen('http://trolleway.nextgis.com/api/resource/826/feature/5/attachment/37/image'),'name':'filename.jpg'}
print 'Upload attachment to ' + ngw_root + '/api/component/file_upload/upload'
req = requests.post(ngw_root + '/api/component/file_upload/upload', data=payload, auth=ngw_creds, headers=headers)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# parse each file from the photo collection and export data into CSV.
# will need: os.listdir(path)
#http://robertcarlsen.net/2010/02/23/parsing-foursquare-kml-files-1113
import sys
import os
import codecs
<!DOCTYPE html>
<html>
<head>
<script>
function str2feature(str) {
/*
input: string "lat_deg = 54.66972|lon_deg = 25.28512|position=right|label = Вильнюс}}"
output: GeoJSON Feature { "type": "Feature", "properties": { "label": "dsfdsf", "position": "dsfdsf" }, "geometry": { "type": "Point", "coordinates": [ 30.7096, 59.8684 ] } }
REM склейка кадров в видео с заданным fps
"c:\Program Files (x86)\RICOH THETA\tools\ffmpeg.exe" -y -f image2 -framerate 60 -i %04d.jpg -vf format=yuv420p 103-3-30.mp4
REM создание клипа со статической картой, увеличение масштаба до размера кадра
"c:\Program Files (x86)\RICOH THETA\tools\ffmpeg.exe" -loop 1 -f image2 -t 4 -i map.png -vf scale=4608:2592 -pix_fmt yuv420p map.mp4
REM вклеить в начало ролика карту
"c:\Program Files (x86)\RICOH THETA\tools\ffmpeg.exe" -y -i map.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate1.ts
"c:\Program Files (x86)\RICOH THETA\tools\ffmpeg.exe" -y -i 103-3-30.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate2.ts
"c:\Program Files (x86)\RICOH THETA\tools\ffmpeg.exe" -y -i "concat:intermediate1.ts|intermediate2.ts|intermediate1.ts" -c copy -bsf:a aac_adtstoasc 103-4.mp4
REM Добавить музыку
"c:\Program Files (x86)\RICOH THETA\tools\ffmpeg.exe" -y -i 103-4.mp4 -i "C:\Users\trolleway\Downloads\De Lorra - Tomorrow.mp3" -codec copy -shortest 103-5.mp4

I need to geotag every photo from trip to .gpx track, but GPX Logger accidentaly stopped. Luckly, i has turned on Google location history.

  1. Takeout location history from google.
  2. Extract .json file
git clone https://github.com/Scarygami/location-history-json-converter.git
location-history-json-converter-master\location_history_json_converter.py -f gpx -s 2017-05-06 -e 2017-05-07 "Takeout/Location History\Location History.json"
"c:\Program Files (x86)\GPSBabel\gpsbabel.exe" -i gpx -f "Takeout/Location History\Location History.gpx" -x transform,trk=wpt -o gpx -F track.gpx
@trolleway
trolleway / shapes2geopackage.py
Created June 20, 2017 10:27
shapes2geopackage.py
# -*- coding: utf-8 -*-
'''
'''
from __future__ import unicode_literals
import config

Dockerfiles

Standart dockerfile

FROM registry.nextgis.com/sshd:0.1.0
#там ubuntu с gdal

ARG DEBIAN_FRONTEND=noninteractive
ARG APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=DontWarn