Thursday, June 24, 2010

lazy about tex equations

It's only been a 15 year hiatus but i am now seriously working on a .tex file.

Although I have no problem with brute-force typing in equations, the lazy part of me wishes there were something that would take the MathType output and generate the equation code. Just for efficiency's sake, you know? There are a lot of equations.

I found this thing, which helps. You have to click in the symbols, but for a beginner like me, it's a good way to learn the syntax.

http://www.codecogs.com/latex/eqneditor.php

.dbf files

ArcGIS output may be saved as a .dbf file, with no immediately apparent way to save as a .txt, or even to copy and paste the cells to a simple spreadsheet program (why? why?).

I had no idea what to do about this so I just downloaded a small program that converts the .dbf to .csv.

http://www.fileguru.com/DBF-To-CSV/download

I did this a couple days ago so now I have no recollection of how it worked, I just remember that it worked, and I copied the data into a google docs spreadsheet. Open Office won't even install on my computer, how lame is that?

If anyone else knows a more intelligent way to do this, please share.

Somebody else talks about .dbf and .xls:
http://gisatvassar.blogspot.com/2008/02/excel-dbf-files-and-arcgis-92.html

Note, 7/14/2010, This is the way to do it:
http://matlabor.blogspot.com/2010/07/export-table-to-ascii.html

Monday, June 21, 2010

Elevation statistics of traced polygons

I wanted to find the mean, min, max, stddev elevation of a bunch of traced terraces, but this can be done with any input files of a zone dataset (i.e. shapefile of polygons) and a value raster (i.e. raster of elevation values).

1. Make the zone dataset, in my case, make a shapefile of polygons [make polygon layer]

2. Add field(s) to the Attribute Table to define the zones. I have a separate ID for each polygon and also the field "Name" for the groupings Qt1, Qt2, etc. To add fields, open the shapefile in ArcCatalog and in the Fields tab, just click in the table to add the Field Name and Data Type (must be integer or text).

Then edit the field to define your zones. First add the zone dataset to the map.
Then, Editor toolbar -> Start edit session -> right-click on your shapefile layer in the leftbar -> Open Attribute Table -> click in the table and fill in.

Stop edit session and Save changes.

3. Zonal analysis by attribute
Spatial Analyst toolbar -> Zonal Statistics
Fill in stuff in the pop up window:
Zone dataset: shapefile of polygons
Zone field: ID or Name or whatever your defining field is
Value raster: elevation dataset
Check or uncheck Ignore NoData and Join output table to zone layer (I like to join)
Chart statistic: I checked Mean but got min, max, range, mean, std, sum in the output table
Specify output table

4. Click OK, the output table pops up, and you're Done.

Friday, June 18, 2010

make polygons

To make some @#$*%$@#% polygons in arcgis (e.g. trace fluvial terrace deposits):

1. Open Arc Catalog
2. In the Location bar, navigate to the folder where you want to put the polygons (shapefile)
3. File -> New -> Shapefile
4. Name it and choose Feature Type -> Polygon
5. If you want, edit the Coordinate System
Select -> Projected Coordinate Systems ->
(UTM NAD 1983 10 N for local stuff)

In ArcCatalog you can right-click a shapefile and edit Properties - e.g add Fields and specify the DataType (text, long integer, double, etc.). But I think the shapefile can't be open in ArcMap if you want to edit it.

6. Add the (empty) layer to the ArcMap window by dragging or using the AddData button
7. Start an edit session (Edit Toolbar)
8. Task dropdown menu: Create New Feature
9. Target dropdown menu: choose your shapefile - if the target drop down is empty, it might be a bug, restart ArcMap and ArcCatalog

10. Use the Sketch button (pencil icon), click and double-click to make vertices and close polygon
11. Stop edit session, Save

12. *Get mean elevation of each polygon from an elevation raster (TBD)

obtain and view seismic data from IRIS

This is deteriorating from a pedagogical tool to a storage place for cryptic notes. But, better than nothing.

One way to get some seismic data from IRIS and look at it

1. Use the GMAP (google map) interface on the IRIS site
http://www.iris.washington.edu/gmap/

The instructions tell you what to enter in the URL
lat/lon example:
http://www.iris.edu/gmap/?minlat=46&maxlat=49&minlon=-125&maxlon=-117

2. A map will load in your browser, Click on a station, click on the "more information" link

3. Look for BHZ data (Broadband H-something z-orientation )

a. cursory look
   4. Click on "Explore with QUACK"
   5. Click on "NEIC PDF PLOT"
   6. Click on "by Year" and look at monthly variation

b. download the actual data
   7. Click on "Make a batch request for data (breq_fast)
   8. Network, Station, and Channel should already be filled in for you, fill in other required (starred) data - Start and End time (GMT - HHMMSS), and contact info
   9. In some amount of minutes, you will be emailed with a link to the data, download it to linux desktop

10. In the directory with the .seed file, unpack the .seed data with rdseed (make sure your .cshrc and .login are set up for this)

Use all defaults except:
Options: d for dump
R for raw

you might need to edit Start/End/Sample Buffer Length depending on the length of the data and what you want

You will get a bunch of .sac files

12. Use pql to view data

13. Use sac to view data

read: r *.SAC
plot: p1
bandpass: bp
ylim
etc.

14. Use matlab (yay. hopefully there will be some posts about this at some point)

Wednesday, June 16, 2010

hillshade from seamless data

It's ArcGIS time. First, let's reflect on how Arc is the anti-google in terms of user-friendliness. It's a constant source of exasperation and I am here to document my exasperation and hopefully avoid some in the future.

Starting from the beginning, here's an example if you want to download high resolution topographic data (1/9 arc second, where 1 arc second at the equator is ~31 m)  from the USGS Seamless Server, reproject it to UTM, and then make a hillshade.

1. Download stuff from seamless - http://seamless.usgs.gov/

Click on the "view and download united states data" image [link].

a. On the right hand side of the screen:
In the Display Tab, under Layer Extents, specify NED 1/9 arc second (National Elevation Dataset). This shows where that data exists.
In the Download Tab, click 1/9 arc sec, assuming that's what you want (default is 1 arc).

b. On the left hand side of the screen, under the Downloads section, define your area:
The way I like to do it is with the 2nd button, Define download area by coordinates, because then you know exactly what the boundaries are, if you need to mosaic it later or whatever. I like to get my lat/lon coordinates from Google Earth.

c. Fill in the window that pops up and then click "Add Area", another window will pop up telling you your request is in a queue and then the file will be downloaded to your default location. If the area you specify is large (I don't know how large), it will be divided into separate files.

Note: Sometimes one or more of the files will stall during downloading, and since the naming convention is incomprehensible (an 8-digit string, seemingly random), it is hard to figure out what part you are missing. Oh well.

2. Unzip all files in the directory you want

3. If there are multiple files, make a mosaic from the separate files

In ArcMap,

a. Make sure the Spatial Analyst extension turned on (Tools -> Extensions -> Spatial Analyst)
(!$#%!#$)%!#$%& that this is not on by default)

b. Click on red tool box (or bring up the toolbar with View ->Toolbars ->Tools)

Click Data management Tools -> Raster -> Raster Dataset -> Mosaic to New Raster

if you don't specify an extension, it will default to GRID

4. Convert from lat/lon to UTM

In Data Management Tools,
Projections and Transformations -> Raster -> Project Raster -> UTM

Input: make sure to erase the default output name .img extension, and make under 13 characters (bug in GIS)

usual convention for new projection: name_prj

Select -> Projected Coordinate Systems

NAD 1983 Zone 10N (for local CA stuff)

Scroll down to Resampling technique-> change to CUBIC (the default method tends to create striping)

5. Restart ARC because it is possible that it thinks it is still in lat/lon

6. Make hillshade

In tools:
Spatial Analyst Tools -> Surface -> Hillshade

You should have a nice hillshade of the topo data.

Tuesday, June 15, 2010

LaTeX on windows

Matlabor is back, but not only about matlab. It's a place to put things that I would otherwise forget.

Today we're going to document how to do LaTeX on windows. Why? Let's just assume the following
(1) I had ubuntu working but when I tried to upgrade it yesterday, I ended up three hours later very demoralized with no more ubuntu on my computer (the fault of incomplete wubi uninstall, and my incomplete understanding of computers)
(2) I've always wanted to be cool enough for LaTeX
(3) I'm just not cool enough for a mac

Here are some steps
(following http://doams.wordpress.com/2009/10/11/how-to-setup-latex-on-windows-7/)

1. install MikTeX
http://miktex.org/2.8/setup

2. install TeXnicCenter
http://www.texniccenter.org

When you start TeXnicCenter for the first time you will be asked where your MiKTeX executables are located (in my case it is in …\program files\MiKTeX2.8\miktex\bin).

Then you will be asked what program you want t use for displaying Post Script files. Skip that part.


3. download journal-specific templates
e.g.
http://www.agu.org/pubs/authors/manuscript_tools/journals/latex/index.shtml

4. add the new class and style files to the path

I got errors if I didn't exactly follow their directory naming conventions:

Make this directory and put the .cls and .sty files in here:
C:\Local TeX Files\tex\latex\misc

Add  C:\Local TeX Files
to MikTeX, following the directions here:
http://docs.miktex.org/manual/localadditions.html

5. Open TeXnicCenter, edit template, and ctrl-shift-F5
I like LaTeX -> PDF

Getting the bibliography to work will be for another day, but I'm hoping that everything will work nicely with JabRef.