Search This Blog

Monday, November 24, 2014

Raspberry Pi



Notes on setting up Python on a Raspberry Pi remotely from a Mac


install Raspberry PI OS - Debian Wheezy  http://www.raspberrypi.org/downloads/


Connect from Mac to the Pi
Mac> ssh pi@192.168.0.3   (Pi IP address)

Install PIP on the Pi
Pi> sudo apt-get install python-setuptools
Pi> sudo easy_install pip

Add Python Packages using PIP
Pi> sudo pip install tweepy
Pi> sudo pip install shapely
etc

Transfer Files between Mac and Pi (using Finder on Mac)
Pi> sudo apt-get update
Pi> sudo apt-get install netatalk

Mac>open afp://192.168.0.3   (IP address of the PI)

Set up Remote Desktop 
Pi> sudo apt-get install xrdp  
                  (add protocol for RDP one time set up on the Pi)

Mac> use Microsoft Remote Desktop client to connect to Pi
(download the App from App Store - search for 'Remote Desktop')

Thursday, September 11, 2014

Internet of Things dev board

http://www.seeedstudio.com/depot/LinkIt-ONE-p-2017.html

About 50GBP

Includes ARM7 EJ-S™, GSM, GPRS, Wi-Fi, Bluetooth BR/EDR/BLE, GPS, Audio codec, and SD card connector on a single development board

 

Wednesday, September 10, 2014

Making Contours

Contours are just so great.... a simple idea but they can convey so much.

Here's some contours for Edinburgh, made from a LiDAR source.











Wednesday, August 27, 2014

Scottish Referendum

A quick look at the density / spatial pattern from geotweets (i.e. those from smartphones mainly)… filtered on keywords as detailed in the image.

Mainly North of the border then….

 

image

SQLITE to CSV on Mac

Open Terminal

cd to directory with sqlite database in it

 sqlite3 dbname

sqlite> .headers on
sqlite> .mode csv
sqlite> .output test.csv
sqlite> select * from tbl1;
sqlite> .output stdout

source:  http://stackoverflow.com/questions/6076984/how-to-export-the-results-of-my-query-to-csv-file-sqlite

Monday, August 25, 2014

Big-O notation notes

Big-O notation is a relative representation of the complexity of an algorithm. These notes taken from these 3 sources:
http://stackoverflow.com/questions/487258/plain-english-explanation-of-big-o
http://bigocheatsheet.com/
http://stackoverflow.com/questions/487258/plain-english-explanation-of-big-o

O(n2):
  • 1 item: 1 second
  • 10 items: 100 seconds
  • 100 items: 10000 seconds
Notice that the number of items increases by a factor of 10, but the time increases by a factor of 102. Basically, n=10 and so O(n2) gives us the scaling factor n2 which is 102.
O(n):
  • 1 item: 1 second
  • 10 items: 10 seconds
  • 100 items: 100 seconds
This time the number of items increases by a factor of 10, and so does the time. n=10 and so O(n)'s scaling factor is 10.
 
O(log n):
  • 1 item: 1 second
  • 10 items: 2 second
  • 100 items: 3 seconds

O(1):
  • 1 item: 1 second
  • 10 items: 1 second
  • 100 items: 1 second
















image


If we add two 100 digit numbers together we have to do 100 additions. If we add two 10,000 digit numbers we have to do 10,000 additions.
See the pattern? The complexity (being the number of operations) is directly proportional to the number of digits n in the larger number. We call this O(n) or linear complexity.
___________________________________
Now if you were instructing a computer to look up the phone number for "John Smith" in a telephone book that contains 1,000,000 names, what would you do? Ignoring the fact that you could guess how far in the S's started (let's assume you can't), what would you do?
A typical implementation might be to open up to the middle, take the 500,000th and compare it to "Smith". If it happens to be "Smith, John", we just got real lucky. Far more likely is that "John Smith" will be before or after that name. If it's after we then divide the last half of the phone book in half and repeat. If it's before then we divide the first half of the phone book in half and repeat. And so on.
This is called a binary search and is used every day in programming whether you realize it or not.
So if you want to find a name in a phone book of a million names you can actually find any name by doing this at most 20 times. In comparing search algorithms we decide that this comparison is our 'n'.
  • For a phone book of 3 names it takes 2 comparisons (at most).
  • For 7 it takes at most 3.
  • For 15 it takes 4.
  • For 1,000,000 it takes 20.
That is staggeringly good isn't it?
In Big-O terms this is O(log n) or logarithmic complexity. Now the logarithm in question could be ln (base e), log10, log2 or some other base. It doesn't matter it's still O(log n) just like O(2n2) and O(100n2) are still both O(n2).
It's worthwhile at this point to explain that Big O can be used to determine three cases with an algorithm:
  • Best Case: In the telephone book search, the best case is that we find the name in one comparison. This is O(1) or constant complexity;
  • Expected Case: As discussed above this is O(log n); and
  • Worst Case: This is also O(log n).
__________________________



__________________________

Polynomial Time

Another point I wanted to make quick mention of is that any algorithm that has a complexity of O(na) is said to have polynomial complexity or is solvable in polynomial time.
O(n), O(n2) etc are all polynomial time. Some problems cannot be solved in polynomial time. Certain things are used in the world because of this. Public Key Cryptography is a prime example. It is computationally hard to find two prime factors of a very large number. If it wasn't, we couldn't use the public key systems we use.

Monday, August 4, 2014

Flyover of Chambers Street in Edinburgh

Flyover of Chambers Street on a Digital Surface Model built from a LIDAR dataset.

Thursday, July 31, 2014

Foot tracking - part 2

More foot tracking.. this time along a corridor... down stairs.. and along another longer corridor with a bend in it....

Otherwise.. much the same as part 1!

Friday, July 25, 2014

Geotagged FlickR locations

Looking at the FlickR dataset… really amazing how many images are captured these days…

I’ve loaded the dataset into PostgreSQL/PostGIS which is doing a great job of handling it all. Shapefiles max out at 2GB so I needed about 11 of them to handle it.. which was pain.

 

Screenshot 2014-07-25 12.15.18

Also the new QGIS 2.4 Chugiak is so much faster at rendering… as it uses multithreading. Great stuff!

Screenshot 2014-07-25 12.09.08Europe

 

 

Screenshot 2014-07-25 12.18.04

                  Channel Islands

Wednesday, July 23, 2014

Notes from SICSA – future cities workshop

 

Some useful links from meeting in Dundee Uni on Tue 22 July 2014

SICSA - http://www.sicsa.ac.uk/
http://www.sicsa.ac.uk/themes/future-cities

 

Scottish Seven Cities
http://scottishcities.wordpress.com/
http://www.sckc.org.uk/
Aberdeen.
Dundee.
Edinburgh.
Glasgow.
Inverness.
Perth.
Stirling.

 

London Datastore — http://data.london.gov.uk/

Manchester - http://futureeverything.org/

Javascript version of processing   http://processingjs.org/

 

Smart Citizen - http://www.smartcitizen.me/

FAB LAB http://www.fablabbcn.org/

http://www.ncl.ac.uk/gps/staff/profile/wen.lin#tab_research

Monday, July 21, 2014

Foot Tracking - urban / indoor postioning

First trial of an IMU as a foot tracker.

This walk goes down 4 flights of stairs then up a shallow sloping driveway, then turn left along a flat road.









Thursday, July 3, 2014

VirtualBox - OSGEO Live - and MacOSX

I've been trying to get the shared folders to work on a Mac running Mavericks and VirtualBox hosting OSGEO Live VM.

The issues was getting the latest kernel headers... the answer is here... many thanks to Andrew Kirkpatrick for the solution.

http://www.andrew-kirkpatrick.com/2011/12/virtualbox-guest-additions-with-shared-folders-on-mac-os-x/


---- text copied from Andrew Kirkpatrick's Site as a backup -----

1
2
3
sudo mkdir /dev/dvd
sudo mount /dev/dvd1 /mnt/dvd/
cd /mnt/dvd
Then you should see VBoxLinuxAdditions in that directory, which you need to run as per the manual. If the above doesn’t work it might be because your DVD drive in VirtualBox is called something else, like dvd (instead of dvd1) which probably differs depending on which distro you’re using.
Then you need to run the installer.
?
1
sudo sh ./VBoxLinuxAdditions.run
Once that’s done you can restart.
?
1
sudo reboot now
Everything should be finished now installation/configuration-wise, but you might encounter some problems… (otherwise skip to Mount the host folder)

Kernel header problems

I got some missing kernel header problems when trying to install Guest Additions, which if building the main Guest Additions module fails will be logged.
?
1
cat /var/log/vboxadd-install.log
If you see something like this…
?
1
2
3
Error! Your kernel headers for kernel 2.6.35-28-generic cannot be found at
/lib/modules/2.6.35-28-generic/build or 
/lib/modules/2.6.35-28-generic/source.
?
1
2
You can use the --kernelsourcedir option to tell DKMS where it's located,
or you could install the linux-headers-2.6.35-28-generic package.
So you can do just that!
--------

Note: to find out which headers you need type this...
uname -a

--------
?
1
2
sudo apt-get install linux-headers-2.6.35-28-generic
sudo ./VBoxLinuxAdditions.run
Hopefully this should install now (although the XFree86 bit will fail, assuming you’re using the command-line) and you may need to restart the VM, although I’m not sure.

Mount the host folder

You can create the host folder in the VirtualBox Manager in the Shared Folders tab on the Settings for that VM. If you add it on the command-line it’ll appear under the machine folders anyways. If you want to type it though, here’s what you’d type into the Mac OS X terminal (note this is the only thing that you’d type into the host itself)
?
1
2
VBoxManage sharedfolder add "my-ubuntu-vm" \
--name "websites" --hostpath "/Users/andrew/pizza"
To mount the Shared Folder from within the guest, the instructions from Ubuntu (as my guest is Ubuntu, although I think this is a better way to mount it anyways) were very useful.
?
1
2
3
4
5
sharename="whatever.you.want.to.call.it";
sudo mkdir /mnt/$sharename \
sudo chmod 777 /mnt/$sharename \
sudo mount -t vboxsf -o uid=1000,gid=1000 $sharename /mnt/$sharename \
ln -s /mnt/$sharename $HOME/Desktop/$sharename