GIS at Holy Cross

A blog providing resources and support related to using geographic information systems (GIS) software at the College of the Holy Cross

Tapping Into the Power of Python


This article (pdf file, approximately 2mb) from the ESRI website is a good introduction into use of the Python programming language to do geoprocessing tasks using tools from ArcGIS. The article has an accompanying text file containing the Python code referenced in the article.


ArcGIS 9.3 Service Pack 1


Click here to download Service Pack 1 for ArcGIS 9.3.  Fixes lots of bugs.


Inserting Google Maps into the cells of an HTML table


This example extends a technique described in a previous post (Inserting Google Maps into a Web Page) to show how to insert different Google Maps into the cells of a table created with HTML.  (After displaying the example in your web browser, use the “View page source” option to look at the HTML code.)   There are two approaches.  In the first approach, using the Google Maps API, you make multiple map objects, one for each table cell, and assign each map object to a different JavaScript variable.  Change the latitude-longitude coordinates of the map center to produce different maps.  Then, in the body of your HTML page, insert each map into a table cell using the div tag.  Be sure to use a different variable name in each cell of your table (unless you want to have duplicate maps).  Set the size of the maps (and therefore, the size of the table cells) using the width and height attributes of the div tag.  Normally you would want each map and table cell to be the same size.

The second approach uses the same HTML table, but the contents of each cell are an iframe tag generated by Google Maps.  This method is simpler than the first because it mainly involves copying and pasting HTML code generated automatically by Google Maps once you have produced the map you want.  This method is also the simplest way to embed a single Google Map into your web page–just copy and paste the iframe code automatically generated by Google Maps.


Adding data to a shapefile in Quantum GIS (joining tables)


 ”Joining tables” in database parlance means essentially “splicing” two tables together.  This forum post explains how to do this in Quantum GIS, a popular open-source, cross-platform GIS.


Review of some GIS applications for the Mac


This article was written in 2006, and provides a review of some GIS software that runs on the Mac OS.


How to Capture Google Maps for Printing and Poster Design


If you want to make a large poster of a map created with Google Maps, you have to create a mosaic out of zoomed-in map pieces, because the screen resolution is too small to make a suitable large-format print.  This tutorial shows a way to do this, using some screen-grabbing and image-stitching software available for free (at least for a limited trial period) on the Web.


How to position a Google Map on a web page


If you use the default settings to insert a customized Google Map into a web page, the map is aligned with the left margin of the page.  If you would rather center the map on the page, you have to add a centering attribute to your HTML code.  To do this, use correct (that is, non-deprecated) HTML to write a <div> tag for your Google Map object like this:

<div id=”map” style=”width: 700px; height: 500px; margin: 0 auto;”></div>

The “margin: 0 auto;” attribute is what does the centering.  The margin keyword is a CSS (Cascading Style Sheet) attribute that controls the four margins of a particular object in a web page.  The margin value of zero sets the top and bottom margins of the map to zero width, and the auto value lets the browser set the left and right margins, which it does such that the map ends up being centered on the page.  The width and height attributes set the dimensions of the map in pixels.  The margin style attribute can have up to four values, one for each of the 4 possible margins (top, bottom, left, right).  For example, if  you used a <div> tag that looked like this:

<div id=”map” style=”width: 700px; height: 500px; margin: 5cm 5cm 5cm 5cm”></div>

your map would have 5-centimeter margins all around.  So by writing a <div> tag with a margin attribute you can finely control where your Google Map appears on your web page.

The above HTML code examples assume that you have named your map object map; you should insert whatever name you have used.  The code also assumes that you are familiar with the Google Maps API and have done all of the other things needed to implement Google Maps in your web page.  For more details, see this post.


Inserting Google Maps into a Web Page


For the simplest method, create your desired map view in Google Maps, then use the option to “Paste HTML to embed in website” that you get when you click the “Link” link found at the upper right corner of the map display.  This generates code for an iframe tag that you can simply copy and paste into your web page HTML code.

You can also insert interactive maps in your web pages by using a little JavaScript and the Google Maps API.  This is more complicated than the previous method, but it gives you much more control over how the map looks.  For a simple example, go here.

The JavaScript code required to implement customized Google Maps is straightforward, and can be created by cutting and pasting from existing examples, such as those found here (use the “View Source” menu option on your web browser to display the HTML and JavaScript code for the examples, which you can then copy and paste into your own web pages).  Most of the code that produces the map in the above example looks like this:

function load() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map"));
map.setCenter(new GLatLng(42.233664, -71.811815), 13);
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
}
}

In object-oriented programming jargon, the above code creates a Google Maps object (the variable “map”), and the rest involves calling the various methods contained within that object.  Thus with a little bit of programming effort, you can harness all of the mapping power of Google Maps for your own web pages.


Get Latitude and Longitude values from Google Earth


The simplest way to capture the latitude and longitude of a point location in Google Earth is to first create a placemark.  When you create the placemark, a box will pop up displaying, among other things, the coordinates of the current location of the placemark.  By dragging the placemark around on the Google Earth display with your mouse, the coordinates will be updated.  You can then copy and paste the coordinates for use elsewhere.

A different approach is described here, involving running KML files in Google Earth.  These tools, developed as part of the Global Biodiversity Information Facility,  allow you to capture coordinates for both point and polygon features.


Get Latitude and Longitude values from Google Maps


Google Maps does not automatically display the latitude and longitude of a location, but the following technique will allow you to capture the coordinates of the center of a Google Map.    In Google Maps, when you have created your map, paste the following JavaScript code into the address bar of your web browser, then press Enter:

javascript:void(prompt('',gApplication.getMap().getCenter()));

A window containing the latitude and longitude of the center of the map, in decimal degrees, will pop up.  You can then use the coordinates by copying and pasting.

For more information on this technique, go here.