Skip to content

Instantly share code, notes, and snippets.

View petrasovaa's full-sized avatar

Anna Petrasova petrasovaa

  • NCSU
  • Raleigh, USA
View GitHub Profile
@petrasovaa
petrasovaa / extract_nodes_by_num_connections.py
Created August 27, 2022 13:20
Extracts nodes by number of line connections
#!/usr/bin/env python3
import grass.script as gs
def parse_node(line):
node, n_lines, xyz, y, z = line.split(",")
_, cat = node.split("=")
cat = int(cat.strip())
_, n_lines = n_lines.split("=")
@petrasovaa
petrasovaa / wxChatDjango.py
Last active March 2, 2020 14:19
Desktop wxPython chat application prototype chatting with Django Channels tutorial chat room
import wx
from wxasync import AsyncBind, WxAsyncApp, StartCoroutine
import asyncio
from asyncio.events import get_event_loop
import websockets
import logging
import sys
import json
@petrasovaa
petrasovaa / TL_class.py
Created February 1, 2019 04:23
Student's code snippets for Tangible Landscape
# Ruixue Wang
def run_contour(scanned_elev,env,**kwargs):
gscript.run_command('r.contour',input=scanned_elev,output='Ruixue_contour',step=2,env=env)
# Rohith
def run_mvwatershed(scanned_elev, env, **kwargs):
gscript.run_command('r.watershed', elevation=scanned_elev, accumulation='flow_accum',
basin='watersheds', threshold=800, env=env)
gscript.run_command('r.slope.aspect', elevation=scanned_elev, slope='slope', env=env)
gscript.run_command('r.stats.zonal', base='watersheds', cover='slope', method='average',
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# -*- coding: utf-8 -*-
"""
Created on Thu Sep 27 11:13:02 2018
@author: anna
"""
import os
import sys
import atexit
import grass.script as gs
@petrasovaa
petrasovaa / blender_patches.py
Created April 13, 2017 19:08
Analyses files for US-IALE demo planting application
# -*- coding: utf-8 -*-
"""
Created on Tue Mar 28 17:32:38 2017
@author: tangible
"""
import os
import shutil
import glob
@petrasovaa
petrasovaa / g.gui.drawing
Last active October 12, 2016 01:45
Test example of GRASS GUI plugin for drawing point with high update rate
dummy file just to have nice name on gist
r.lake elevation=JR_topobathy@JR_2014 water_level=0 lake=sound_water_level_0 coordinates=912401.339286,250065.561224 --o
r.lake elevation=JR_topobathy@JR_2014 water_level=0.3048 lake=sound_water_level_1 coordinates=912401.339286,250065.561224 --o
r.lake elevation=JR_topobathy@JR_2014 water_level=0.6096 lake=sound_water_level_2 coordinates=912401.339286,250065.561224 --o
r.lake elevation=JR_topobathy@JR_2014 water_level=0.9144 lake=sound_water_level_3 coordinates=912401.339286,250065.561224 --o
r.lake elevation=JR_topobathy@JR_2014 water_level=1.2192 lake=sound_water_level_4 coordinates=912401.339286,250065.561224 --o
r.lake elevation=JR_topobathy@JR_2014 water_level=1.524 lake=sound_water_level_5 coordinates=912401.339286,250065.561224 --o
r.lake elevation=JR_topobathy@JR_2014 water_level=1.8288 lake=sound_water_level_6 coordinates=912401.339286,250065.561224 --o
r.lake elevation=JR_topobathy@JR_2014 water_level=1.8288 lake=sound_water_level_7 coordinates=912401.339286,250065.561224 --o
r.lake elevation=JR_to
# Images to video
avconv -r 13 -i compare_%03d.png -c:v mpeg4 -b:v 25000k compare.mp4
# Horizontally append images in loop
for I in `seq -f "%03g" 1 390`
do
convert +append a_$I.png b_$I.png ab_$I.png
done