1. Voronoi polygons with R

    Wed 16 September 2009
    cfarmer

    To create a nice bounded Voronoi polygons tessellation of a point layer in R, we need two libraries: sp and deldir. The following function takes a SpatialPointsDataFrame as input, and returns a SpatialPolygonsDataFrame that represents the Voronoi tessellation of the input point layer.

    read more

    comments

  2. Watch’ long running processes

    Wed 08 July 2009
    cfarmer

    The other day I was loading a shapefile of approximately 11 million records into a PostGIS database (stay tuned for more on that later) and I wanted to know when shp2pgsql was done. Instead of continually checking the console, I decided to ‘watch’ the process using the *nix command watch. I discovered this handy tool a while ago, and have found that for long running processes, I can use watch to notify me when the process has finished, using the following command:

    watch -ben 1 "ps u -C shp2pgsql"
    

    read more

    comments

  3. gedit: The ultimate LaTeX editor

    Fri 12 December 2008
    cfarmer

    Out of the box gedit is a basic text editor, but it comes equipped with about 12 standard plugins, and another 9 readily available. In addition to this, there are a range of ‘third-party’ plugins developed to do various specific tasks, such as assist you in writing and exporting LaTeX documents! First, get all the basic plugins:

    sudo apt-get install gedit-plugins`
    

    and enable them in gedit by going to Edit > Preferences > Plugins, and checking the ones that you want.

    Second, make sure you have all the required dependencies for the actual \(\LaTeX\) plugin: 1. The plugin is written in Python ...

    read more

    comments

  4. Quick guide to setting up a PostGIS database

    Fri 28 November 2008
    cfarmer

    Recently I decided to seriously start using PostGIS to manage my spatial data. As I have several projects on the go, organizing and managing my data effectively has become extremely important, and PostGIS is by far the most convenient way to do this. There is lots of documentation out there that explains in detail how to set up PostGIS, but by far the best reference I’ve found is from Tim Sutton’s blog, mainly because he uses Ubuntu, and sudo-apt gets everything you need to have PostGIS working in minutes.

    read more

    comments

  5. View spatial data attribute tables in R

    Tue 14 October 2008
    cfarmer

    Many GIS offer the ability to view the attribute table of a vector layer. While this is perhaps less obvious in the R environment, it is not impossible. The following command allows you to visually inspect, and change any data.frame (or other vector, matrix, etc.), including Spatial*DataFrames.

    read more

    comments

  6. R spatial indentify tool

    Tue 23 September 2008
    cfarmer

    This is useful for visually exploring R spatial data such as SpatialPointDataFrames or SpatialGridDataFrames. By clicking on various features, the value at that point will be displayed.

    library(rgdal)
    y = readGDAL(system.file("pictures/Rlogo.jpg", package="rgdal")[1], band=1)
    y.grid = y@grid
    y.coords = coordinates(y.grid) 
    image(y)
    identify(x=y.coords, y=NULL, n=1)
    

    where x and y refer to coordinates (in this case because y.coords contains both x and y coordinates, y can be set to NULL), and n is the number of features to identify.

    read more

    comments

  7. Find and replace multiple files

    Mon 08 September 2008
    cfarmer

    Recently, I had to do a find and replace over several individual python files.There are plenty of scripts out there which will accomplish this, but I was interested in something simple, and preferably a single line command. After a lot of Google-ing, I ended up finding this post, which does a great job of explaining how to do this in linux. The basic command is:

    find . -name "\*.py" -print | xargs sed -i 's/foo/bar/g'
    

    where find . -name "*.py" is used to find all python files (recursively) in your directory, and xargs sed -i 's/foo/bar/g ...

    read more

    comments

2 / 2

twitter

recent visitors