Archive for the 'Tip' Category

Slightly belated Thursday Tip Day: Find and replace text in multiple files

Apologies for the delay- it’s been a roller-coaster week at Archaeogeek Towers due to family health issues. Hopefully it’s getting sorted now though.

In the process of preparing Portable GIS, I needed to change a string in multiple files of multiple formats within multiple folders. I looked at various windows- based options, most of which had a charge associated with them, but one of my colleagues suggested a linux approach.

“Sed” is the command that you need, found in most linux systems. In windows you can install it as part of the unxutils toolkit. The following command in linux works recursively through the folders in a root directory changing string1 for string2 (be careful with those single quotes if copy and pasting as wordpress likes to restyle them):

find ./ -type f -exec sed -i ’s/string1/string2/’ {} \;

With a large number of files this might take some time to work (a usb stick took an hour to work through on my ubuntu server vm but maybe that’s not a fair benchmark).

Thursday Tip Day: On USB keys at the linux command line

How to mount a USB stick in Ubuntu server using the command prompt only:

Do a sudo tail -f /var/log/syslog and plug the usb drive in.
Look for lines like these:
Feb 18 12:58:32 shuchi kernel: [17192272.616000] sda: assuming drive cache: write through
Feb 18 12:58:32 shuchi kernel: [17192272.616000] sda: sda1

Make a directory in /media named usbdrive.
Mount it like this: sudo mount /dev/sda1 /media/usbdrive

To unmount before ejecting:
sudo umount /media/usbdrive

If you get a message saying that the device is busy you can find out what process is using it using with the fuser command, with the -u parameter to see which user it is:

fuser -u /media/usbdrive

This will give you a number which refers to a process, and a user, then run ps -A to list all the processes and see which one it is. If you need to kill that process (USE WITH CAUTION) then run:

sudo kill -9 yourprocessnumber

You should then be able to safely unmount your USB drive

Thursday Tip Day: Fixing Google Desktop

I’ve been a big fan of google desktop for a while now, not so much for the search options but because I like the gadgets. There’s nothing like the Remember The Milk gadget for making you feel guilty about tasks you’ve put off, and I’m currently addicted to the Twitter gadget. However, for some time, Google desktop refused to let me click any web links, access the options, view my google calendar, open links in google chats etc.

A search of the google group suggested it might work if I set Internet Explorer as my default browser, and it does, which is great except for the fact that I loathe IE7 upwards with a passion. Curse it’s non-default layout and shiny tabs and buttons. However, I finally found a solution:

In registry editor (type regedit at the run prompt), and find the following key:

HKEY_CLASSES_ROOT\htmlfile\shell\open\command

and change it’s value from the path to Internet Explorer on your system to the path to Firefox.

Now, I guess I ought to caution you about making changes to your registry and how it might accidentally cause your hamster to get run over or similar, so consider yourself cautioned…

Thursday Tip Day: Converting free contour data for use in GIS

Firstly, if you’ve seen this post before, apologies. It got lost in a previous re-organisation of the blog and I thought it was worth re-posting…

You can get free contour data for the UK from the Scottish Mountaineering Club website. It’s based on public domain NASA data, cleaned up by the club and made freely available. It comes in garmin .img format, in several zip files, which roughly represent areas of the country. See their web page for an explanation of the areas.

Edit: Leszek has some great alternatives methods and options for data- check the comments.

  1. To convert the img files to something (more) useful, the best programme I’ve found is gpsmapedit. You need to register it to get the full functionality. This costs 42 euros (umm, about 32 pounds at the moment) but allows you to use the programme on up to four computers.
  2. In gpsmapedit, click “open” or “add” and load up all the img files you want to convert. Note that they will be merged into one big file so for the sake of your poor computer, choose only the areas that you need.
  3. Go to file/export/mapinfo file, select level “0″, this includes the minor contours (down to 10m) as well as the major contours (100m)
  4. When it has finished exporting, you can shut it down. If you’re using mapinfo, then skip to step 6.
  5. In ArcGIS, crack open ArcCatalog, and load the “Arcview 8.x tools” toolbar. Move your mapinfo files to a location on your computer that has no spaces in it’s path name and a short path. No really, do. It will crash otherwise. Choose the “mif to shapefile” converter. Alternatively, you could do this with ogr2ogr. See the website for usage.
  6. The resulting file (mapinfo or shape) is in wgs84 projection, with the height values in feet, so for use in a British National Grid environment you need to re-project it. The height values are in the attribute field “label”, so add another field for holding the converted height and use the tool of your choice to convert the values in the “label” column to metres.

Note that this data is good for broad-based terrain modelling only. If you need something more accurate you’re going to have to buy it…

If you have any alternatives to this method let me know in the comments!

« Previous PageNext Page »

bodybuilding steroids