Look at this existing tutorial https://lerryws.xyz/posts/PyQGIS-in-Jupyter-Notebook
This file contains 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
# Example of downloading all data from a GeoServer WFS server | |
# and loading it into a PostGIS database. Use with caution | |
# as you could put a lot of load on someone's server if they | |
# host a lot of data which might make them sad. | |
# In response to: http://underdark.wordpress.com/2012/09/26/wfs-to-postgis-in-3-steps/ | |
BASEURL="http://data.wien.gv.at/daten/geoserver/ows?service=WFS&version=1.1.0" | |
for LAYERNAME in `wget -qO- $BASEURL"&request=GetCapabilities" | xpath -q -e "//FeatureType/Name/text()"` ; do | |
PARTS=(${LAYERNAME//:/ }) |
This file contains 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
# coding: utf-8 | |
# requires: pattern http://www.clips.ua.ac.be/pages/pattern | |
from pattern.web import * | |
import csv | |
import sys | |
# yeah I know | |
reload(sys) | |
sys.setdefaultencoding("utf-8") |
This file contains 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
WITH deltas as ( | |
SELECT | |
st_distance(the_geom::geography, lag(the_geom::geography, 1) over(order by timestamp)) as ddist, | |
timestamp - lag(timestamp, 1) over(order by timestamp) as dt | |
from out_2 offset 1000 | |
) | |
select avg(ddist/dt) as speed from deltas |
This file contains 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 org.apache.spark.SparkContext | |
import org.apache.spark.sql.expressions.{MutableAggregationBuffer, UserDefinedAggregateFunction} | |
import org.apache.spark.sql.types._ | |
import org.apache.spark.sql.{Column, Row, SQLContext} | |
/*** | |
* UDAF combining maps, overriding any duplicate key with "latest" value | |
* @param keyType DataType of Map key | |
* @param valueType DataType of Value key | |
* @param merge function to merge values of identical keys |
This file contains 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
-- Convenience Functions | |
CREATE OR REPLACE FUNCTION to_epoch(IN timestamptz, OUT epoch float8) AS | |
$$ SELECT extract(epoch from $1) $$ LANGUAGE SQL; | |
CREATE OR REPLACE FUNCTION ts_at_tod(IN timestamptz, IN timetz, OUT timestamptz) AS | |
$$ SELECT date($1) + $2 $$ LANGUAGE SQL; | |
-- Get list of target time between start and end | |
CREATE OR REPLACE FUNCTION times_between(IN range_start timestamptz, IN range_end timestamptz, IN t timetz) | |
RETURNS setof timestamptz AS $$ | |
SELECT * FROM |
This file contains 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 requests | |
import csv | |
import datetime | |
import calendar | |
import time | |
i=0 | |
# Change the range depending on how long you like to record the data | |
for i in range (0,50): | |
This file contains 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
if ( | |
distance( | |
overlay_nearest( | |
layer:='poligono', | |
expression:= $geometry )[0], $geometry) < | |
distance( | |
overlay_nearest( | |
layer:='linea', | |
expression:= $geometry )[0], $geometry),overlay_nearest( | |
layer:='poligono', |