Sunday, December 19, 2010

Reading copy/pasted data into an array in R

If you copy data from somewhere and paste it into R, you can easilyt import it as a data.frame using the textConnection function

dat <- textConnection("1 0 7 0 0 1 0 0 0 5 0 0 0 0 2 0 0 0 0 1 0 0 0 1
1 0 0 1 0 0 0 3 0 0 0 0 1 0 0 0 1
0 0 0 1 0 0 0 2 0 0 0 0 1 0 0 0 1 0 1 0 0 1
1 0 0 1 0 3 0 0 0 0 1 0 0 0 1
0 0 0 1 0 0 0 2 0 0 0 0 1 0 0 0 1 0 1 0 0 1 1 2 1 0 1 0 1")
df <- data.frame(scan(dat, fill = TRUE, what = as.list(rep(1, 29))))

Thursday, December 16, 2010

Ubuntu login problem

gdm says:" error initiating conversation with authentication system - general failure"

The problem was solved after commenting out the following row in /etc/pam.d/gdm

@include common-pamkeyring

Hacking Linux rescue mode

http://www.linuxtopia.org/online_books/system_administration_books/ubuntu_starter_guide/ch08.html#gainrootinstallcd

Monday, December 13, 2010

R commander plugin

install.packages("RcmdrPlugin.HH")
library(RcmdrPlugin.HH)

Quick-R

http://www.statmethods.net
http://graphpad.com/quickcalcs/posttestintro.cfm

Friday, December 3, 2010

Line to polygon conversion in GRASS

http://osgeo-org.1803224.n2.nabble.com/converting-lines-to-polygons-td5557002.html

v.in.ogr -o dsn=C:\path\to\shapefile\or\dxf.file output=circles1 type=line
v.clean input=circles1 output=circles2 tool=snap,break,rmdupl thresh=0.2,0,0
v.type input=circles2 output=circles3 type=line,boundary
v.centroids input=circles3 output=circles4 option=add

Be sure to play with the treshold parameter of v.clean

Tuesday, November 16, 2010

Launching linux programs with a specific locale

To launch a program in Linux with a different locale, use the syntax :

LANG=en_US.UTF-8 R

if it does not work, use

LANGUAGE=en_US.utf8 R

This command launches R with the en_US.UTF-8 locale.

Friday, October 22, 2010

Subversion in Debian server/Ubuntu client

#In the debian server :

#Create an empty data repository
cd /data/aaworks/
svnadmin create R_repository

#Import already existing source files into it
svn import SeaWiFS_bio/Rfiles/Ekumen_R/ file:///data/aaworks/R_repository/Ekumen_R/

#List the imported files
svn list file:///data/aaworks/R_repository/Ekumen_R

#Create a working directory and checkout
cd ~
mkdir Ekumen_R/
svn checkout file:///data/aaworks/R_repository/Ekumen_R

cd Ekumen_R/
svn list

#After modifiying a source file, one can commit :
svn commit

#You can checkout files in the ubuntu client through ssh :
svn checkout svn+ssh://ekumen/data/aaworks/R_repository/Ekumen_R

Friday, October 1, 2010

Julian date conversion in R

Convert the Julian day into Date format
strptime("180", "%j")

or

strptime("1998249", "%Y%j")
[1] "1998-09-06"

Friday, September 24, 2010

Compiling Orfeo on Ubuntu Lucid

For OTB, install the following ubuntu packages :

libfltk1.1-dev libcurl3-dev libfftw3-dev libgdal1-1.7.0 mercurial fluid cmake-curses-gui libglu1-mesa-dev libgeotiff-dev uuid-dev libexpat1-dev

Thursday, September 23, 2010

Running SEADAS in 32-bits mode in Ubuntu 64-bits

Simply install the Ubuntu package ia32-libs

Wednesday, August 25, 2010

Monday, August 23, 2010

Configuring postgresql in debian

After the installation from the debian packages, you should run :

sudo pg_createcluster 8.3 main

To make the server listen to the network edit /etc/postgresql/8.3/main/postgresql.conf and modify it to read :

listen_addresses = '*' # what IP address(es) to listen on;

and edit /etc/postgresql/8.3/main/pg_hba.conf and add a line for each user you would like to authorize the user called "myuser" who is located on network 201.171.245.62/32 for using the database "mydb" :

host mydb my user 201.171.245.62/32 md5

and then grant privileges to that user on the table geometry_columns :

psql mydb
GRANT select, insert, update, delete ON TABLE public.geometry_columns TO myuser;

debian : locales problem

export LANGUAGE=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
locale-gen en_US.UTF-8
dpkg-reconfigure locales

Monday, August 9, 2010

debian : choosing java VM

update-alternatives --config java
update-alternatives --config javac

Saturday, August 7, 2010

OpenStreetMap+PostGIS+Geoserver in Ubuntu

After a fresh install one needs to create access to PostgreSQL. Use the instructions
in https://wiki.ubuntu.com/PostgreSQL

Create the database "osm"
createdb osm

Prepare the database
psql osm -c "ALTER TABLE spatial_ref_sys OWNER TO acizmeli"
psql osm -c "ALTER TABLE geometry_columns OWNER TO acizmeli"
psql -d osm -f /usr/share/postgresql/8.4/contrib/postgis-1.5/postgis.sql
(debian) psql -d osm -f /usr/share/postgresql-8.3-postgis/lwpostgis.sql
(debian) psql -d osm -f /usr/share/postgresql-8.3-postgis/spatial_ref_sys.sql
createlang plpgsql osm


Enable the projection SRS 900913 in PostGIS (Spherical Mercator)
wget http://svn.openstreetmap.org/applications/utils/export/osm2pgsql/900913.sql
psql -f 900913.sql osm

Downlod the OSM data files (for Turkey)
http://downloads.cloudmade.com/asia/turkey#downloads_breadcrumbs

Download the world coastline database (as described in http://wiki.openstreetmap.org/wiki/Mapnik)
wget http://tile.openstreetmap.org/world_boundaries-spherical.tgz (50 MB)
wget http://tile.openstreetmap.org/processed_p.tar.bz2 (357 MB)
wget http://tile.openstreetmap.org/shoreline_300.tar.bz2 (48 MB)
wget http://www.naturalearthdata.com/download/10m/cultural/10m-populated-places.zip (1.5 MB)
wget http://www.naturalearthdata.com/download/110m/cultural/110m-admin-0-boundary-lines.zip (38 KB)

Extract the Marmara region from the high resolution land polygon and assign the missing projection information "EPSG:3785"
ogr2ogr -s_srs "EPSG:3785" -a_srs "EPSG:3785"  -where
"tile_x >= 228  AND tile_x <= 233  AND tile_y >= 248 AND tile_y <= 251"
Marmara_land_polygon_EPSG_3785.shp processed_p.shp     

Edit the OSM data in JOSM and fix the following features :
* Give the Küçükçekmece dam the attribute landuse=reservoir
* Create the polygon for the Durugöl dam (which did not exist)   

Import the OSM data in PostGIS osm2pgsql -d osm OSM/turkey.osm     

Worked the coastline edges of the mahalle polygons in OpenJump for it to match
those of Marmara_land_polygon.

A shapefile output from OpenJump does not put projection info in the output file.
To set it manually : 

ogr2ogr -a_srs EPSG:900913 mahalle_EPSG_900913_reworked.shp /WIN_C/Users/user/Desktop/mahalle_EPSG_900913_reworked.shp   

gdalwarp -wo SOURCE_EXTRA=125 -srcnodata "11 10 50"
-dstalpha  -t_srs '+proj=ortho +datum=WGS84' geoworld.tif ortho.tif   

Saturday, July 24, 2010

MicroSD adapter mounted read-only in Ubuntu Lucid

Try to remount it with the command :

sudo mount -o remount,rw /dev/mmcblk0p1 /media/microSD/

Thursday, July 22, 2010

installing a downloaded R source package file

From within R :

If the destdir argument is used, the downloaded packages are not deleted after the installation (or if the compilation fails) :
> install.packages("rJava", dep = T, destdir = "/home/user/Downloads/") :

If the compilation fails, one can get back later on the process by specifying the source file on disk :
> install.packages("/home/user/Downloads/rJava_0.8-4.tar.gz", repos=NULL)

Thursday, June 24, 2010

Shrinking Vista Partition

The "Shrink Volume" option of "Computer Management" tool in Windows Vista would not shrink as much as you want it to. To improve the situation, one can download the trial version of PerfectDisk Professional and perform 3 different types of defragmantation :

  • Consolidate Free Space
  • Boot Time defragmentation
Especially the latter is valuable as it is able to move Vista's normally unmovable system files, substantially (though not optimally) increasing the amount of volume to be gained from the shrink operation. More info is available.

Monday, May 10, 2010

DNS now working in VirtualBox client after network switch

I have a laptop and regularly change network connections. I don't shut the machine down but let it hibernate in between. I use VirtualBox, windows host (sorry, this is it for now but I promise it will change soon ;o), Linux guest.

I had to configure the Google free DNS service in the Linux guest so that the DNS works even when I change network (going home from work, etc.) :

http://code.google.com/speed/public-dns/docs/using.html

Saturday, April 10, 2010

Installing the R package : rgl

On Ubuntu 12.04 (precise) : sudo apt-get install libgl1-mesa-dev libglu-dev libxt-dev libfreetype6-dev fontconfig mesa-utils To install in Ubuntu karmic the R package "rgl", one needs to install the X11 header files :

sudo apt-get install xorg-dev

and the OpenGL libraries :

sudo apt-get install freeglut3 freeglut3-dev libgl1-mesa-dev libglu1-mesa-dev libice-dev libsm-dev libx11-dev libxau-dev libxdmcp-dev libxext-dev libxt-dev mesa-common-dev x11proto-core-dev x11proto-input-dev x11proto-kb-dev x11proto-xext-dev xlibmesa-gl-dev xtrans-dev

The installation of "rgl" then should work in R :
install.packages("rgl", dep=T)

Wednesday, March 10, 2010

Virtualbox mounting a Windows host directory under Linux client

C_DRIVE /C_DRIVE vboxsf uid=acizmeli 0 0


or


Documents /home/me/Host vboxsf uid=1000,gid=1000,nodev,noexec,nosuid,auto,rw 0 0

(http://ericgazoni.wordpress.com/2011/03/25/mounting-virtualbox-osx-share-on-ubuntu-guest/)

Thursday, February 11, 2010

Geoserver GeoWebCache Tile Seeding

If there is a "." in the Geoserver layer name, the "Seed this layer" link in the GeoWebCache interface does not work. Simply removing the "." makes it work.