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 pandas as pd | |
df = pd.read_csv('..\data\hospitals.csv') | |
#print(df.to_json(orient='records')) | |
with open('..\data\hospitals.json', 'w') as outfile: | |
outfile.write(df.to_json(orient='records')) |
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 tableName set columnName = json_build_object('keyfieldname1',fieldname1,'keyfieldname2',fieldname2) | |
-- keyfieldname1 is any text name you give to the key | |
-- fieldname1 is an existing column name you have in your table | |
-- docs https://www.postgresql.org/docs/9.5/static/functions-json.html |
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 psycopg2 | |
conn = psycopg2.connect(host='localhost', user='someuser', port='5432', password='verysecretpwd', database='myDbName') | |
cur = conn.cursor() | |
def generate_poi_translation_template(filename): | |
# query the database table for the list of names you want to translate | |
sel_building_floor_id = """SELECT f.cat_name FROM ( | |
SELECT DISTINCT ON (cat_name) cat_name, parent_id |
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
x-geom | |
substr(to_string(geom_to_wkt(transform( $geometry ,'EPSG:4326','EPSG:3857'))),7,16) | |
y-geom | |
substr(to_string(geom_to_wkt(transform( $geometry ,'EPSG:4326','EPSG:3857'))),25,16) | |
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 json | |
from geojson import Feature | |
from django.contrib.gis.db.models.functions import Centroid, AsGeoJSON | |
from buildings.models import Space | |
from rest_framework.decorators import api_view | |
from rest_framework.response import Response | |
@api_view(['GET']) | |
def get_room_center(request, unique_id): |
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 django.db import models | |
class AppQueryset(models.QuerySet): | |
pass | |
class AppManager(models.Manager): | |
queryset_class = AppQuerySet | |
def get_queryset(self): | |
return self.queryset_class(self.model) |
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
## Common Packages | |
# --------------- | |
sudo apt-get -y update | |
sudo apt-get -y upgrade | |
sudo apt-get -y install software-properties-common libssl-dev openssl wget | |
## Install latest Python 3 | |
# ----------------------- | |
PY_VERSION=3.4.3 | |
PY_URL="https://www.python.org/ftp/python/$PY_VERSION/Python-$PY_VERSION.tgz" |
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 | |
import shutil | |
import distutils | |
import subprocess | |
base_source_path = r"E:\WEBGIS\source\trunk\mysite" # svn source location | |
base_deploy_path = r"C:\inetpub\mysite" | |
source_dir3 = r"C:\Python27\Lib\site-packages\django_admin_bootstrapped\static\admin" |
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 | |
import django | |
from myapp import models | |
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myapp.settings") | |
django.setup() | |
print models.MyModel.objects.get(pk=1) |
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 pyproj import Proj, transform | |
## my test coordinates, location is on the end of a peer on lake Wörthersee | |
## if the tranformation is wrong our point will be in the water | |
# these coorinates below I believe I can trust | |
# and are all TRUE for reference ( source KAGIS Atlas 17.10.2014) | |
# epsg proj coord | |
# epsg:31252 GK M31 70534.8 165013.4 |