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
<!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 ] } }
#!/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
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)
@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 = ''
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@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
@trolleway
trolleway / ricohthetas_offshutter.txt
Last active June 26, 2016 17:57
Ricoh Theta S turn off shutter sound
POST /osc/commands/execute
{
"name": "camera.startSession",
"parameters": {}
}
#shoot
192.168.1.1/osc/commands/execute
{
"name": "camera.takePicture",
exiftool -a -G1 -s R0010031.JPG
[ExifTool] ExifToolVersion : 10.08
[System] FileName : R0010031.JPG
[System] Directory : .
[System] FileSize : 4.0 MB
[System] FileModifyDate : 2016:01:11 22:16:42+03:00
[System] FileAccessDate : 2016:01:11 23:27:07+03:00
[System] FileCreateDate : 2016:01:11 23:27:07+03:00
[System] FilePermissions : rw-rw-rw-
[File] FileType : JPEG
@trolleway
trolleway / photo2geojson.py
Created January 3, 2016 15:07
Generate a geojson file with coordinates of all photos in folder.
# -*- coding: UTF-8 -*-
'''
Generate a geojson file with coordinates of all photos in folder.
Using exiftool via exiftool module
Usage:
python geo3.py "E:\PHOTO\z_bat\geo\test1"
@trolleway
trolleway / html_generator.py
Last active December 30, 2015 12:42
Постановление Правительства Москвы от 8 декабря 2015 г. N 829-ПП "О мерах по обеспечению сноса самовольных построек на отдельных территориях города Москвы"
#!/usr/bin/python
# -*- coding: utf-8 -*-
import ijson
from shapely.geometry import Polygon, MultiPolygon
import urllib