Geographic Web Applications for Perfectionists with Deadlines

Slides:



Advertisements
Similar presentations
New Release Announcements and Product Roadmap Chris DiPierro, Director of Software Development April 9-11, 2014
Advertisements

Components of GIS.
Object Relational Model Spatial Queries. Query Model Spatial Layer Data Table where coordinates are stored Primary Filter Spatial Index Index retrieves.
TileMill Quickly and Easily Design Maps for the Web Shaky Sherpa Matt Berg Modi Research Group The Earth Institute. Columbia University.
Visualise | communicate | ENGAGE Instant Atlas™ is a registered trademark of GeoWise Limited ©Copyright 2008 | Geowise Limited IA Desktop to LIS Solution.
Building an online tool for spatial joins using open source software Karsten Vennemann Seattle.
Jennifer Lana, GISP GIS Manager Cobb County, GA October 3, 2012 Cobb County uses ‘Workflow Modeling’ for Purpose Driven Web & Mobile GIS Solutions.
Open Source GIS How we use free tools to do cool things Martin Catala Donald Hayward.
CAMERON GOODALE PAUL RAMIREZ GIS and Python. PyCon March 7 th -11 th in Santa Clara, CA Largest gathering of Python Developers.
Esri International User Conference | San Diego, CA Technical Workshops | What is a Web Application? Ben Ramseth July 13, 2011.
Using GeoDjango for user participation in enriching web GIS systems Bo Zhao University of Florida July 15 th, 2009.
TECNOLOGIAS DE ARMAZENAMENTO DE INFORMAÇÃO ESPACIAL.
1 Alternate Title Slide: Presentation Name Goes Here Presenter’s Name Infrastructure Solutions Division Date GIS Perfct Ltd. Autodesk Value Added Reseller.
Open Source Databases and GIS
Rebecca Boger Earth and Environmental Sciences Brooklyn College.
Esri International User Conference | San Diego, CA Technical Workshops | ArcGIS Runtime Euan Cameron Mary Harvey Ralf Gottschalk Road Ahead.
Web Development Methodologies Yuan Wang(yw2326). Basic Concepts Browser/Server (B/S) Structure Keywords: Browser, Server Examples: Websites Client/Server.
 >> django-admin.py startproject mysite /mysite __init__.py manage.py settings.py urls.py.
OMap By: Haitham Khateeb Yamama Dagash Under Suppervision of: Benny Daon.
Web Frameworks: Django Department of Biomedical Informatics University of Pittsburgh School of Medicine
Django Web Framework 김형용, 이정민 Framework 2.1. Django High-level Python Web Framework Develop fast Automate the repetitive stuff Follow best practices.
Esri International User Conference | San Diego, CA Technical Workshops | ArcGIS for Server Road Ahead Ismael Chivite, Anne Reuland.
Dj(T)ango with Python Ritika Virmani. What is Django? It’s not a Hawaiian dance Developed by Adrian Holovaty and Simon Willison Rapid Web Development.
MapServer and SDE Howard Butler Center for Survey Statistics & Methodology Iowa State University Beginning Middle End.
Web-Based Tool and Why Cross Platform Support Multi-User No special software to install… just a browser Offload real work to server No worrying about versions.
UVa cs1120 David Evans Lecture 34: Djustifying Django.
건전지로 달리는 쟝고 세미나. 파트2 Last time MVC Views and URLconfs.
Oracle Application Express (Oracle APEX), formerly called HTML DB, is a Free rapid web application development tool for the Oracle database.
Business Solutions Using Microsoft ® Office SharePoint ® Server ROADSHOW.
Codeigniter is an open source web application. It occupies a very small amount of space in the memory and is most useful for developers who aim to develop.
Computer Science 111 Fundamentals of Programming I Overview of Programming.
Introduction to ArcGIS for Environmental Scientists Module 2 – Fundamentals Chapter 7 – Queries.
Open Source GIS Web Mapping Solutions Sachindra Singh ICT Systems Developer 2010 Pacific Islands Geographical Information Systems and Remote Sensing User.
BLU-ICE and the Distributed Control System Constraints for Software Development Strategies Timothy M. McPhillips Stanford Synchrotron Radiation Laboratory.
CHAPTER 3 VECTOR DATA MODEL.
A Geoprocessing Framework using Python and ESRI SDE Howard Butler Center for Survey Statistics & Methodology Iowa State University Beginning Middle End.
ArcGIS Server for Administrators
Pushing the envelope… New and innovative ways to leverage Open Source Toolkits for the ERMA portal Aaron Racicot (Z-Pulley Inc) Dane Springmeyer (DBSGeo)
Spatial Tajo Supporting Spatial Queries on Apache Tajo Slideshare Shorten URL : goo.gl/j0VLXpgoo.gl/j0VLXp.
Geosimulation Geosimulation models are developed to represent phenomena that occur in urban systems in highly realistic manner In particular, Cellular.
Django 101 By: Jason Sumner. Django Overview Django was started in 2003, released under BSD in 2005, and the Django Software Foundation was established.
27/11/ Oussama Marseli, Census of Population and Housing Implementation and Processing Manager GIS enabled application.
John Pickford IBM H11 Wednesday, October 4, :30. – 14:30. Platform: Informix Practical Applications of IDS Extensibility (Part 2 of 2)
LBR & WS LAB 1: INTRODUCTION TO GIS.
WalkLite in Mobile GIS: A Schema to Extend and Symbolize SpatiaLite Dr. X. Chen Walkinfo Tech. Co. Ltd.
Adding ArcGIS Online to Your GIS Curriculum
SWGData and Software Access - 1 UCB, Nov 15/16, 2006 THEMIS SCIENCE WORKING TEAM MEETING Data and Software Access Ken Bromund GST Inc., at NASA/GSFC.
Open Spatial Adds Scalable Functionality to As Constructed Design Certification Validation Portal Using Microsoft Azure MICROSOFT AZURE APP BUILDER PROFILE:
U.S. Census Data & TIGER/Line Files
Understand Windows Services Software Development Fundamentals LESSON 5.3.
ERDDAP The Next Generation of Data Servers Bob Simons DOC / NOAA / NMFS / SWFSC / ERD Monterey, CA Disclaimer: The opinions expressed.
Open Source GIS The Ecotrust mission to utilize new innovative technology Aaron Racicot – GIS Programmer
OSSIM Technology Overview Mark Lucas. “Awesome” Open Source Software Image Map (OSSIM)
 David Hietpas  Library Web Developer  University of Wisconsin - Polk Library.
MARPLOT: Building a Desktop GIS for Emergency Response from FOSS Components May 3, 2016 Michael Katz, Software Engineer 6/12/20161.
The Django Web Application Framework zhixiong.hong
© 2012 Autodesk Gordon Luckett – Municipal Asset Management with Autodesk® Software Gordon Luckett GIS Consultant, Developer.
Geocoding Chapter 16 GISV431 &GEN405 Dr W Britz. Georeferencing, Transformations and Geocoding Georeferencing is the aligning of geographic data to a.
DreamFactory for Microsoft Azure Is an Open Source REST API Platform That Enables Mobilization of Data in Minutes across Frameworks and Storage Methods.
Geospatial Data Abstraction Library(GDAL) Sabya Sachi.
RE-ENGINEERING FLEX APP TO JAVASCRIPT APP By Imtiaz Syed.
Fundamentals of Programming I Overview of Programming
Geographic Search & Display
PYTHON: AN INTRODUCTION
PHP / MySQL Introduction
Building an online tool for spatial joins using open source software
TechEd /22/2019 9:22 PM © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks.
From Development to Production: Optimizing for Continuous Delivery
From Development to Production: Optimizing for Continuous Delivery
Introduction to Portal for ArcGIS
Presentation transcript:

Geographic Web Applications for Perfectionists with Deadlines GeoDjango Geographic Web Applications for Perfectionists with Deadlines Justin Bronn (jbronn@gmail.com) Travis L. Pinney (travis.pinney@gmail.com) FOSS4G 2007 September 25, 2007

Overview Background Third-Party Components and ctypes interfaces Building a Spatial Web Application with U.S. Census data.

Background Legal Stuff: Django® is a registered trademark of Lawrence Journal-World (Lawrence, KS) The opinions herein are solely the authors and do not necessarily represent or reflect the opinions of the Django Project and/or the Lawrence Journal-World.

Background – Quick Bios Justin Bronn B.S. Computer Science, Trinity University, San Antonio, Texas 4+ Years at Southwest Research Institute, San Antonio, Texas Third-year Law Student, University of Houston Travis L. Pinney B.S. Computer Science, Trinity University 10+ years programming experience, including HP/Compaq 6+ years developing in Python

How’d we get into this stuff? Background How’d we get into this stuff? Justin created a website, Houston Crime Maps using Django. In the process, learned open source GIS software. Wouldn’t it be nice if my hacks could be part of a coherent package… Met Django developers at 2007 PyCon “gis” branch created in February, obtained commit access in March.

Background – What is Django? Django High-level rapid web application development framework. “For perfectionists with deadlines.” Philosophies “MTV” Models Templates Views High-level rapid web application development framework Don’t Repeat Yourself (DRY) Explicit is better then implicit Excellent documentation Loose coupling You work in your problem domain instead of fighting with the framework Not magical, it cannot do everything for you – a “80/20” solution.

Background – Why Django? Rapid web application development. RESTful URLs (e.g., foo.com/calendar/2007/ instead of foo.com/calendar.asp?year=2007&session=331337) Lightweight With little effort you can display your data to many different formats such as xml, json, html, csv or whatever format you want. Because of the loose coupling it allows you to extend it easily.

Background – What is GeoDjango? “The GIS branch of Django intends to be a world-class geographic web framework. Our goal is to make it as easy as possible to build GIS web applications and harness the power of spatially enabled data.” 1 1 http://code.djangoproject.com/wiki/GeoDjango

Background – Requirements Python PostgreSQL/PostGIS psycopg2 PROJ.4 GEOS GDAL/OGR (optional, but recommended)

Third-Party Components – Overview GEOS GDAL/OGR GeoIP Spatial Database Support

Third-Party Components – Why? Problem: Good GIS code, Troublesome SWIG Interfaces. Compiling w/SWIG is daunting for new users, let alone experienced developers. Cross-platform compatibility is problematic.

Third-Party Components – Why? GEOS SWIG Python interface no longer supported, maintainer Sean Gillies left to work on PCL (Python Cartographic Library) and, more recently, ShapeLy. GDAL/OGR Old bindings are no-longer supported; project transitioning to “next-generation” SWIG interfaces. For example, GDAL 1.4.1 had issues w/Python 2.5.

Third-Party Components – ctypes Solution ctypes is a Python interface for accessing external C library capabilities in Python “A fundamental shift in how to integrate languages.” GeoDjango has ctypes interfaces for the following C APIs: GEOS GDAL/OGR MaxMind GeoIP Advantages No longer dependent on temperamental SWIG Python interfaces. Portability: interfaces are highly-cross platform. For example, the GEOS interfaces work with Windows, Linux, Mac, and Solaris. Have access to very powerful routines in a “Pythonic” way: mpoly = GEOSGeometry(wkt) for poly in mpoly: for ring in poly: …

Third-Party Components – GEOS >>> from django.contrib.gis.geos import * >>> pnt = Point(5, 23) >>> ring = LinearRing((0, 0), (0, 50), (50, 50), (50, 0), (0, 0)) >>> poly = Polygon(ring) >>> print poly.contains(pnt) True >>> print poly POLYGON ((0.0000000000000000 0.0000000000000000, 0.0000000000000000 50.0000000000000000, 50.0000000000000000 50.0000000000000000, 50.0000000000000000 0.0000000000000000, 0.0000000000000000 0.0000000000000000))

Third-Party Components – GDAL >>> from django.contrib.gis.gdal import * >>> s1 = SpatialReference(4326) >>> s2 = SpatialReference(’NAD83’) >>> s3 = SpatialReference(’+proj=lcc +lat_1=27.5 +lat_2=35 +lat_0=18 +lon_0=-100 +x_0=1500000 +y_0=5000000 +ellps=GRS80 +units=m +no_defs’) >>> geom = OGRGeometry(’POINT(5 23)’)

Third-Party Components – GeoIP >>> from django.contrib.gis.utils import GeoIP >>> g = GeoIP() >>> print g.country(’refractions.net’) {'country_name': 'Canada', 'country_code': 'CA'} >>> print g.city(‘refractions.net’) {'city': 'Vancouver', 'region': 'BC', 'area_code': 0, 'longitude': -123.13330078125, 'country_code3': 'CAN', 'latitude': 49.25, 'postal_code': 'v6c2b5', 'dma_code': 0, 'country_code': 'CA', 'country_name': 'Canada'} >>> print g.geos(‘refractions.net’) POINT (-123.1333007812500000 49.2500000000000000)

Census Geoapp – Building a web enabled GIS application in 10 minutes (+ 10 minutes to explain what is being done) Application will be able to explore the State Boundaries, the County Boundaries, and the Urban Areas of the entire U.S. Shapefile Data obtained from the U.S. census bureau Cartographic Boundary Files website.

Census Geoapp – Overview Setting-up. Inspecting the Data Importing the Data with LayerMapping Spatial Queries Using databrowse and admin to build a dynamic website.

Census Geoapp – Setting Up Create new Django project Create geoapp application. Begin editing models. Edit settings. Syncing the database

C:\> python django-admin.py startproject foss4g C:\> cd foss4g C:\foss4g> python manage.py startapp geoapp

Census Geoapp – Inspecting the Data Start Django shell Use ogrinfo utility to explore shapefiles. Use DataSource to explore. Use only what you need in your models!

In [1]: from django.contrib.gis.utils import ogrinfo In [2]: ogrinfo(‘C:/gis_data/st99_d00.shp, num_features=1)

In [1]: from django.contrib.gis.utils import ogrinfo In [2]: ogrinfo(‘C:/gis_data/st99_d00.shp, num_features=1) data source : C:/projects/gis_data/st99_d00.shp ==== layer 0 shape type: Polygon # features: 273 srs: None extent: (-179.14734000000001, 17.884813000000001) - (179.77847, 71.352560643999809) Displaying the first 1 features ==== === Feature 0 AREA: Real (271.25438) PERIMETER: Real (227.17142) ST99_D00_: Real (2.0) ST99_D00_I: Real (1.0) STATE: String ("02") NAME: String ("Alaska") LSAD: String ("01") REGION: String ("4") DIVISION: String ("9") LSAD_TRANS: String (None)

In [3]: from django.contrib.gis.gdal import * In [4]: ds = DataSource(‘C:/gis_data/st99_d00.shp’) In [5]: layer = ds[0] In [6]: print layer.fields ['AREA', 'PERIMETER', 'ST99_D00_', 'ST99_D00_I', 'STATE', 'NAME', 'LSAD', 'REGION', 'DIVISION', 'LSAD_TRANS'] In [7]: print max(map(len, layer.get_fields('NAME'))) 20

Census Geoapp – Geographic Models The following Geographic Models are available: PointField LineStringField PolygonField MultiPointField MultiLineStringField MultiPolygonField GeometryCollectionField

from django.contrib.gis.db import models # Create your models here class State(models.Model, models.GeoMixin): fips = models.CharField(maxlength=2) name = models.CharField(maxlength=20) region = models.CharField(maxlength=1) division = models.CharField(maxlength=1) poly = models.PolygonField(srid=4269) objects = models.GeoManager() class Admin: pass def __unicode__(self): return unicode(self.name)

Census Geoapp – Editing settings.py DATABASE_ENGINE = 'postgresql_psycopg2' DATABASE_NAME = 'foss4g' DATABASE_USER = 'foss4g' DATABASE_PASSWORD = 'foss‘ INSTALLED_APPS = ( 'foss4g.geoapp', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.databrowse', 'django.contrib.gis', 'django.contrib.sessions', 'django.contrib.sites', )

C:\foss4g> python manage.py sqlall geoapp BEGIN; CREATE TABLE "geoapp_state" ( "id" serial NOT NULL PRIMARY KEY, "fips" varchar(2) NOT NULL, "name" varchar(20) NOT NULL, "region" varchar(1) NOT NULL, "division" varchar(1) NOT NULL ); SELECT AddGeometryColumn('geoapp_state', 'poly', 4269, 'POLYGON', 2); ALTER TABLE "geoapp_state" ALTER "poly" SET NOT NULL; CREATE INDEX "geoapp_state_poly_id" ON "geoapp_state" USING GIST ( "poly" GIST_GEOMETRY_OPS ); COMMIT;

C:\foss4g> python manage.py syncdb Creating table geoapp_state Installing custom SQL for geoapp.State model Loading 'initial_data' fixtures... No fixtures found. C:\foss4g>

Census Geoapp – LayerMapping LayerMapping was created to automate repetitive code in importing and transforming geographical data from OGR-supported data sources (SHP files) Requires GDAL/OGR ctypes interface.

In [1]: from django.contrib.gis.utils import LayerMapping In [2]: from foss4g.geoapp.models import State In [3]: from foss4g.mapping import * In [4]: lm = LayerMapping(State, shp_file, mapping, source_srs=4269, encoding=‘cp437’) In [5]: lm.save(verbose=True)

Census Geoapp – Spatial Queries Most of the PostGIS operations are available through GeoDjango’s database API.

Census Geoapp – Spatial Queries Available Spatial Lookup Types overlaps, bboverlaps overlaps_left, overlaps_right overlaps_below, overlaps_above strictly_below, strictly_above left,right same_as/exact contained, bbcontains equals, disjoint, touches, crosses, within, intersects, relate dwithin, coveredby, covers (PostGIS 1.3.1+ only)

Census Geoapp – Spatial Queries Available Spatial Lookup Types overlaps, bboverlaps overlaps_left, overlaps_right overlaps_below, overlaps_above strictly_below, strictly_above left,right same_as/exact contained, bbcontains equals, disjoint, touches, crosses, within, intersects, relate dwithin, coveredby, covers (PostGIS 1.3.1+ only)

In [1]: from foss4g.geoapp.models import County In [2]: bexar = County.objects.get(name=‘Bexar’) In [3]: print bexar Bexar In [4]: bexar = County.objects.transform(‘poly’, srid=3084).get(name=‘Bexar’) In [5]: print bexar.poly.geom_type Polygon In [6]: print bexar.poly.wkt POLYGON ((1630726.0407146986000000 6311696.3955783 …

In [7]: print bexar.poly.srid 3084 In [8]: buf = bexar.poly.buffer(1.0) In [9]: qs = County.objects.filter(poly__intersects=buf) In [10]: print qs [<County: Kendall>, <County: Comal>, <County: Bandera>, <County: Guadalupe>, <County: Bexar>, <County: Medina>, <County: Wilson>, <County: Atascosa>]

Census Geoapp – Configuring URLs URLs are configured with regular expressions. Parameters are strictly defined, no unexpected data. Encourages making your application RESTful

Databrowse dynamically creates a rich, browsable Web site by introspecting your models. The admin interfaces provides a built-in utility for manipulating your spatial data.

Census Geoapp – Configuring Databrowse and Admin from django.conf.urls.defaults import * from django.contrib import databrowse from foss4g.geoapp.models import County, State, UrbanArea databrowse.site.register(County) databrowse.site.register(State) databrowse.site.register(UrbanArea) urlpatterns = patterns('', (r'^admin/', include('django.contrib.admin.urls')), (r'^(.*)$', databrowse.site.root), )

For more information, see http://code. djangoproject We need help, bugfixes, implementing features, etc. – please contribute.

Any Questions?