R spatial indentify tool

Free open-source software (FOSS), Geographic information science/systems (GIS), Helpful tips, How to, Linux, R spatial No Comments »

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.

C

Find and replace multiple files

Helpful tips, How to, Linux No Comments »

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' is used to replace all occurrences of ‘foo’ in the files with ‘bar’.
The link above gives a good explanation of each command (find, xargs, sed), and how they combine together to create this useful single line command.

C

Original design by j david macor.com.Original WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in