“Improving” GPlates output with Automator and Applescript

When you export reconstructed shapefiles from GPlates, you get two options: either dump all the shapefiles into one (but then not include an attribute field that can be used to separate the input files, or dump each shapefile into a folder named for its input file.  Since I’ve been working with multiple input shapefiles, this results in multiple folders of output:

Folder_Top
--my_first_shapefile
----reconstruction.00Ma.dbf
----reconstruction.00Ma.prj
----reconstruction.00Ma.shp
----reconstruction.00Ma.shx
--my_second_shapefile
----reconstruction.00Ma.dbf
----reconstruction.00Ma.prj
----reconstruction.00Ma.shp
----reconstruction.00Ma.s
etc.

I would rather have this:

Folder_Top
–my_first_shapefile.dbf
–my_first_shapefile.prj
–my_first_shapefile.shp
–my_first_shapefile.shx
–my_second_shapefile.dbf
–my_second_shapefile.prj
–my_second_shapefile.shp
–my_second_shapefile.shx
etc.

The attached [email me if you need it, I need a reason to dig it up and share it again. 2014-02-18] Automator script (Mac only) takes whatever folders you input (e.g., my_first_shapefile and my_second_shapefile), renames the contents of each to match the folder name, and then moves all of these files to the parent of the input folders (e.g., Folder_Top).  It has a bit of applescript based on this post and this one.

Tested on: Mac OS X 10.6.8 (Snow Leopard)
Requires: Dispense Items Incrementally Automator action
Input: One or more folders, dragged onto script icon (can be modified in Automator to pop up a dialog box)
Released under: CRAPL
Download: rename files to folder name automator.zip
Installation: Unzip file.  I think you need ro run Automator, open the unzipped file, and then “Save As” to hook everything up to your system correctly.

 

 

[notes] Converting MRSID to GeoTIFF using GDAL in Mac OS 10.6 (Snow Leopard)

Just found out how to convert MrSID files (from NZ geology) to other formats using GDAL.

  • Followed instructions here: http://www.photo-mark.com/notes/2008/nov/12/converting-mrsid-gis-files/
  • Needed most recent version of GDAL with frameworks (1.8 Complete): http://www.kyngchaos.com/software/frameworks
  • Had to change command to “/Library/Frameworks/GDAL.framework/Versions/Current/Programs/gdal_translate -of PNG /Users/Matt/Desktop/whangarei/inputmap.sid /Users/Matt/Desktop/whangarei/outputmap.png”
  • That makes an image file, but I think I’ll convert to geotiff for GIS:
    • /Library/Frameworks/GDAL.framework/Versions/Current/Programs/gdal_translate /Users/Matt/Desktop/whangarei/inputmap.sid /Users/Matt/Desktop/whangarei/outputmap.tif
  • Map source: http://www.gns.cri.nz/Home/Our-Science/Energy-Resources/Geological-Mapping/Geological-Maps/1-250-000-QMAP/Map-downloads
  • Map coordinate system: New Zealand Map Grid (Geodetic Datum 1949)
  • gdal_translate man: http://www.gdal.org/gdal_translate.html

yweather help

In case you want more out of your yweather script when you use it for Geektool, here are some other switches you can use:

I’ve figured out some of it, so I guess my only tip is to not try to use more than one argument at a time (except as shown below with the units example) and therefore to use a bunch of geeklets if you want to show a lot of information.

Also, I believe that ‘weather.png’ in the images folder is the current weather, so you should be able to show it using an image geeklet.

Yahoo Weather Information

Usage:
./yweather.pl -ct Displays current temperature

In case you want more out of your yweather script when you use it for Geektool, here are some other switches you can use:

I’ve figured out some of it, so I guess my only tip is to not try to use more than one argument at a time (except as shown below with the units example) and therefore to use a bunch of geeklets if you want to show a lot of information.

Also, I believe that ‘weather.png’ in the images folder is the current weather, so you should be able to show it using an image geeklet.

Yahoo Weather Information

Usage:
	./yweather.pl -ct	Displays current temperature

Arguments:
	-lc 			City
	-lr			Region
	-lt			Country
	-cc			Weather Code (used for images)
	-ct			Current Temperature
	-cw			Current Weather Description
	-cd			Current Date
	-ah			Current Humidity
	-av			Current Visibilty
	-ap			Current Barometric Pressure
	-ar			Change in Barometric Pressure
	-sr			Time of Sunrise
	-ss			Time of Sunset
	-wc			Current Wind Chill
	-wd			Current Wind Direction
	-ws			Current Wind Speed
	-ut			Temperature Unit
	-ud			Distance Unit
	-up			Pressure Unit
	-us			Speed Unit
	-fd1			Today's Day
	-fg1			Today's Date
	-fl1			Today's Low Temp
	-fh1			Today's High Temp
	-ft1			Today's Description
	-fc1			Today's Weather Code
	-fd2			Tomorrow's Day
	-fg2			Tomorrow's Date
	-fl2			Tomorrow's Low Temp
	-fh2			Tomorrow's High Temp
	-ft2			Tomorrow's Description
	-fc2			Tomorrow's Weather Code
	--copyimage		Copy Appropriate Image to Current Image (deprecated)
	--update		Update xml source file

All data is returned without units. To get data with units,
use a combination of commands.

Example: (Displays Current temperature with unit)
	./yweather.pl -ct && ./yweather.pl -ut

http://macenstein.com/default/2009/11/how-to-add-a-bunch-of-useless-stuff-to-your-desktop-with-geektool-yahoo-widgets-and-more/
http://code.google.com/p/yweather/wiki/howtousage

Trying something new . . . again (part 1)

Since I just had to reinstall Leopard and lost all my custom PHP and MySQL installations (and the MySQL databases, unfortunately), I tried to remedy that yesterday and today.

I’m still pissed off that OS X doesn’t come with working PHP and MySQL out of the box, including the PHP libraries. With a simple way to know where the data are being stored, and a way to back it up (in one’s Home folder, perhaps). But I digress–I’m sick of spending hours getting things to work when they ought to work.

So I decided to try out XAMPP for Mac (I tried it a few years back for Windows and enjoyed it), and it worked. Here are a few notes.

1. Everything is installed in the Applications folder. I’m not sure I like this, since I hate having stupid little folders (and DATA) in the Applications folder. I’m not sure if this can be easily changed, perhaps with a symbolic link to somewhere else (such as my Home folder, so it will get backed up).

2. Leopard MySQL was running when I installed, so I had to kill it with ‘sudo killall mysql’ and it will hopefully not start up again when I restart. The main reason I was having issues was that Leopard AGAIN lost mysql.sock.

3. I turned off Web Sharing in System Preferences. This is probably a good thing, and it will at least keep my computer from trying to run two Apache servers at once.

4. I wanted to keep the Sites folder as my web root for localhost, so I opened /Applications/xampp/etc/httpd.conf and changed DocumentRoot to point toward my Sites directory (e.g., “/Users/Matt/Sites”). I then copied everything in /Applications/xampp/xamppfiles/htdocs into /Users/Matt/Sites, and things seem to still work fine.

5. The MySQL databases, in case you want them backed up with the rest of the file structure rather than using phpMyAdmin, are stored in /Applications/xampp/xamppfiles/var/mysql. I may try to move them (with a symbolik link) to be stored in my Home folder since I won’t be keeping a lot of data in them but it’s annoying when I lose settings for various PHP applications (Simple Machines Forum, OpenX, Drupal, Serendipity, etc.).

6. I cannot get MySQL to work if I set a password for it, which means no logging into phpMyAdmin and no access to the MySQL databases. I get “Access denied for user ‘root’@’localhost’ (using password: NO)” instead, until I reset the password to blank. (Note to self, to do this, the command is [sudo ./bin/mysqladmin -u root -p password ”] (no brackets). The -p is important, because it will them ask you for your current password rather than assuming that you just didn’t want to supply it. Idiotic.)

7. Overall, aside from having to install all my databases again (not the fault of XAMPP), it seems to be working well so far. It just miffs me that I have a non-functioning version of MySQL on my laptop as well as an unused (although missing certain useful libraries) version of PHP 5 floating around. At this point I’ll take what I can get.

Fun extras with the OS X terminal

I’m writing some more R scripts today to make up for the discrepancy between different people’s interpretation of the concept of disparity and variance, and I felt the need to add a signal that the script was done running. I’ve used play() in the past, but it seems silly to use an extra library when I have other methods…

system("say All done!");

I was also playing with the system volume, but decided not to do too much, since I’m usually listening to music, and blowing my ears out is not my preferred method of learning that my function has completed running.

Change the system volume from the command line – OS X Daily Check out Kevin’s comment for some more tricky things.

Of course, you can always just play a sound without the play() function–just use Terminal! http://forums.macosxhints.com/showthread.php?t=33962

Leopard upgrade notes

Here I am, finally having upgraded from Tiger to Leopard on my 1.67 MHz 15″ Powerbook. I’m still not sure if its faster or better yet, but I hope to keep reporting on what I find out about it.

Issues:
1. When I first restarted after upgrading, I wouldn’t get past being able to see the desktop, some icons, the dock and the info bar at the top. Then I would get the grey screen of disappointment (read: kernel panic!) and have to restart. This was due to a problem with startup items. It looks like the problem was Little Snitch, but I haven’t tried anything else to see if it could have been Mail, iCal, SizzlingKeys, or iChat.

2. The Sites folder didn’t work! Luckily, this guy figured this out before me. However, it also looks like PHP didn’t carry over for some reason, so I am downloading a new PHP install to work with Apache 2 from my favorite PHP/MySQL site.

3. The dock is kind of ugly–what’s with the shiny floor? Luckily, it looks like there is a solution. This worked for me.

4. Azureus has just quit a couple times while I wasn’t watching, but I’m downloading the latest version, which should work out better. UPDATE: Seems to be working fine now!

Happy Leoparding! Does anyone have any other stories?