- ssh into the system from another Mac or linux machine
- sudo killall loginwindow

## Wednesday, December 14, 2011

### OS X logout from the command line

This morning I found my Mac desktop stuck on logout. I did not want to force reboot it so I did some peeking around for how to logout peacefully. Looks like it is very easy to do:

## Sunday, December 4, 2011

### Array permutation

Here is a snippet of Java code that will permute indexes of an array:
For working Java class see https://github.com/sorokine/FischerKrause

## Tuesday, May 31, 2011

### PostGIS function for a random point inside a polygon -- page on PostGIS wiki

I have created a page on PostGIS wiki with the description of the random point functions: http://trac.osgeo.org/postgis/wiki/UserWikiRandomPoint

## Monday, May 23, 2011

### PostGIS function for a random point inside a polygon -- REVISED

This is a revised random-point-in-polygon function first discussed in my earlier post. It turns out that in some weird cases (multipolygons consisting of a number of small and disperse polygons) the function takes too many iterations to complete. Below is a code for another function called RandomPointMulti that addresses this problem. RandomPointMulti breaks a multipolygon into polygons, randomly chooses a polygon with the probability proportional to the area of the polygon, and then calls original RandomPoint on that polygons. RandomPoint was also modified: some typos have been fixed, exception is thrown if the max number of iterations has been exceeded, and and max number of iterations can be specified as an argument.

## Wednesday, April 13, 2011

### PostGIS function for a random point inside a polygon

**Check the revised version of this post.**

This is a function that I wrote to generate a random point inside a polygon. It works by first generating a random point within the bounding box of the polygon and then checking if the point falls inside of the polygon. The limit is 1000 iterations. This limit is probably enough for most practical cases with the exception for polygons that occupy only a small part of its bounding box. This is my first foray into PostgreSQL functions, please judge accordingly. I did not check how the function performs on the geometries other than polygons.

Labels:
plpgsql,
PostGIS,
PostgreSQL

## Friday, January 7, 2011

### Importing GNIS into PostgreSQL - II

This is a continuation of my previous post.
To make GNIS useable with spatial queries you need to add geometry or geography column to the table and create a spatial index. Without the index traversing of a 2-million record table is very slow. This is how to do it assuming that the data from GNIS tables has been imported as described in the previous post:

Labels:
GIS,
GNIS,
PostGIS,
PostgreSQL

Subscribe to:
Posts (Atom)