T10-GeographicInformationSystems.ppt

Download Report

Transcript T10-GeographicInformationSystems.ppt

Introduction to Geographic
Information Systems
by
Mike Zielinski
Definition of GIS
• Stores geographic locations and attributes
about the location.
• Able to add information
• Edit information
• Examples terrain information, disease
information, tree information
Examples of GIS
•
•
•
•
•
Google Earth
Google Maps
CGIS – First Computerized GIS
ArcGIS-Current commercial GIS
Wikimapia
History of GIS
• First were cave paintings showing where
animals where located
• First known analytic use was cholera outbreak
in London in 1854 when Dr. John Snow used a
map to figure out how to stop the outbreak
Demos
• Google Maps
• Wikimapia
Google code
• Need key and a domain to embed in web site
• Uses Javascript
Sample Code
•
•
•
•
•
•
•
•
•
•
•
•
•
•
<script src="http://maps.google.com/maps?file=api&amp;v=2.x&amp;key=key"
type="text/javascript"></script>
<script type="text/javascript">
var map = null;
var geocoder = null;
function initialize() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(37.4419, -122.1419), 13);
}
}
</script>
More Code
• <body onload="initialize()" onunload="GUnload()">
•
<form id="form1" runat="server">
•
<div>
•
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
•
<asp:Button ID="Button1"
•
runat="server" Text="Button"
•
onclientclick="showAddress();return false"
•
UseSubmitBehavior="True" />
•
</div>
•
<br />
•
<div id="map_canvas" style="width:300px; height:500px"></div>
•
</form>
• </body>
Geolocating
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
function showAddress() {
geocoder = new GClientGeocoder();
var address=document.forms[0].TextBox1.value;
if (geocoder) {
geocoder.getLatLng(
address,
function(point) {
if (!point) {
alert(address + " not found");
} else {
map.setCenter(point, 13);
var marker = new GMarker(point);
map.addOverlay(marker);
marker.openInfoWindowHtml(address);
}
}
Wikimapia
wikimapiaRequestStr =
"http://api.wikimapia.org/?function=box&bbo
x=" + LonMin.Text + "," + LatMin.Text + "," +
LonMax.Text + "," + LatMax.Text + "&key=key”
The key can be gotten at wikimapia.org/api
Returns XML with places in the box
Can return other formats like JSON, KML and
also gzip it.
XML format
<code class="xml"> <?xml version="1.0" encoding="utf-8"?> <?access-control
allow="*"?> <folder language="en" version="1.0"> <!-- places folder, language and
version --> <place id="22139">
<name>Golden Gate National Recreation Area: Land's End</name>
<url>http://wikimapia.org/22139/</url> <!-- original url -->
<location> <lon>-122.4997044</lon> <lat>37.7887088</lat>
<north>37.788878</north> <south>37.78681</south> <east>-122.494082</east>
<west>-122.508352</west> </location>
<polygon> <point x="-122.5077081" y="37.7867756"/> <!-- points of polygon x longitude, y - latitude --> <point x="-122.494082" y="37.78681"/> <point x="122.4945974" y="37.7880983"/> <point x="-122.496593" y="37.7874539"/>
<point x="-122.4973226" y="37.7875896"/> <point x="-122.4997044"
y="37.7887088"/> <point x="-122.5002408" y="37.7885053"/> <point x="122.5024295" y="37.788234"/> <point x="-122.5035238" y="37.7880305"/>
<point x="-122.5060344" y="37.7882001"/> <point x="-122.5071502"
y="37.7875048"/> <point x="-122.5071502" y="37.7875048"/> <point x="122.5077081" y="37.7867756"/> </polygon> </place>
XML Parser in C#
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
XmlReader wikiReader = XmlReader.Create(wikimapiaStream);
while(wikiReader.Read()) {
if (wikiReader.IsStartElement()){
if (wikiReader.IsEmptyElement) {
name = wikiReader.Name;
}
else{
name = wikiReader.Name;
wikiReader.Read();
if (wikiReader.IsStartElement() {
name = wikiReader.Name;
}
content = wikiReader.ReadString();
if (name == "name"){
ListBox1.Items.Add(new ListItem(content));
}
Other Capabilities of
Wikimapia
• Can Search
• Can request URL for a place; need place id
gotten from Box
Can be used with Google Maps and
Google World
• THE KML format is used by Google Earth
• The KMZ format which is KML zipped can be
used by Google Maps to add information
about the area like Google Earth.
Spatial Databases
• Can add points, lines, and polygons to the
database in SQLServer and MySql
• I will talk about MySql but these are standards
that have been implemented so should work
for other databases.
Spatial Types
Point- POINT(12.5 13.1)
LineString- LINESTRING( 0 0, 0.5 0.4, 20.1 20.5)
Polygon- POLYGON( ………………………..)
MULTIPOINT holds many points
MULTILINESTRING holds many line strings
GEOMETRY can hold any type
Use of types
• Create Table PointsAndLines (pt POINT,Line
LINESTRING);
• Insert Into PointsAndLines
Values (GeomFromText(‘(POINT(1 1)’)),…);
• Select AsText(pt) From PointsAndLines.
References
•
•
•
•
Wikipedia-GIS
Wikimapia.org/api
code.google.com/apis/maps
dev.mysql.com