Summary and Recap: CSES’s Impact on the PNW Implications for Climate Services in the PNW
GIS Tool in Drupal PNW Drupal Summit - Seattle October 20th, 2012
description
Transcript of GIS Tool in Drupal PNW Drupal Summit - Seattle October 20th, 2012
![Page 1: GIS Tool in Drupal PNW Drupal Summit - Seattle October 20th, 2012](https://reader036.fdocuments.net/reader036/viewer/2022062809/568157ed550346895dc5639c/html5/thumbnails/1.jpg)
GIS Tool in DrupalPNW Drupal Summit - Seattle
October 20th, 2012
Mack Hardy & Tom Nightingale@AffinityBridge
![Page 2: GIS Tool in Drupal PNW Drupal Summit - Seattle October 20th, 2012](https://reader036.fdocuments.net/reader036/viewer/2022062809/568157ed550346895dc5639c/html5/thumbnails/2.jpg)
History of Maps with Drupal Tools
![Page 3: GIS Tool in Drupal PNW Drupal Summit - Seattle October 20th, 2012](https://reader036.fdocuments.net/reader036/viewer/2022062809/568157ed550346895dc5639c/html5/thumbnails/3.jpg)
Location Module, proximity and filter
![Page 4: GIS Tool in Drupal PNW Drupal Summit - Seattle October 20th, 2012](https://reader036.fdocuments.net/reader036/viewer/2022062809/568157ed550346895dc5639c/html5/thumbnails/4.jpg)
![Page 5: GIS Tool in Drupal PNW Drupal Summit - Seattle October 20th, 2012](https://reader036.fdocuments.net/reader036/viewer/2022062809/568157ed550346895dc5639c/html5/thumbnails/5.jpg)
![Page 6: GIS Tool in Drupal PNW Drupal Summit - Seattle October 20th, 2012](https://reader036.fdocuments.net/reader036/viewer/2022062809/568157ed550346895dc5639c/html5/thumbnails/6.jpg)
Storage and Import
![Page 7: GIS Tool in Drupal PNW Drupal Summit - Seattle October 20th, 2012](https://reader036.fdocuments.net/reader036/viewer/2022062809/568157ed550346895dc5639c/html5/thumbnails/7.jpg)
Storage - GeoField
Where do we store data in drupal?
A common field format for geodata• WKT• Lat Lon• Bounding
![Page 8: GIS Tool in Drupal PNW Drupal Summit - Seattle October 20th, 2012](https://reader036.fdocuments.net/reader036/viewer/2022062809/568157ed550346895dc5639c/html5/thumbnails/8.jpg)
![Page 9: GIS Tool in Drupal PNW Drupal Summit - Seattle October 20th, 2012](https://reader036.fdocuments.net/reader036/viewer/2022062809/568157ed550346895dc5639c/html5/thumbnails/9.jpg)
Spatial Import
How do we import data from external sources?
Shapefiles
KML files
Uses GeoPHP and ogr2ogr
Spatial module -> Saves as WKT -> Geofield
http://drupal.org/project/spatial
![Page 10: GIS Tool in Drupal PNW Drupal Summit - Seattle October 20th, 2012](https://reader036.fdocuments.net/reader036/viewer/2022062809/568157ed550346895dc5639c/html5/thumbnails/10.jpg)
ogr2ogr
Wrapper module for the GDAL ogr2ogr library
- Spatial module calls ogr2ogr
- Converts data from source formats to WKT
http://drupal.org/project/ogr2ogr
![Page 11: GIS Tool in Drupal PNW Drupal Summit - Seattle October 20th, 2012](https://reader036.fdocuments.net/reader036/viewer/2022062809/568157ed550346895dc5639c/html5/thumbnails/11.jpg)
Query
![Page 12: GIS Tool in Drupal PNW Drupal Summit - Seattle October 20th, 2012](https://reader036.fdocuments.net/reader036/viewer/2022062809/568157ed550346895dc5639c/html5/thumbnails/12.jpg)
Sync_PostGIS Module
• Allows drupal to query PostGIS as a spatial query service, much in the way SOLR is used for search
• Syncs data from Drupal entities with geofields to PostGIS
• Provides query methods for testing intersection, within, buffer conditions
http://drupal.org/project/sync_postgis
![Page 13: GIS Tool in Drupal PNW Drupal Summit - Seattle October 20th, 2012](https://reader036.fdocuments.net/reader036/viewer/2022062809/568157ed550346895dc5639c/html5/thumbnails/13.jpg)
Sync_PostGIS Module
![Page 14: GIS Tool in Drupal PNW Drupal Summit - Seattle October 20th, 2012](https://reader036.fdocuments.net/reader036/viewer/2022062809/568157ed550346895dc5639c/html5/thumbnails/14.jpg)
What does sync_postgis tell us?
Intersections with other data pointsWithin a buffer of 5km
![Page 15: GIS Tool in Drupal PNW Drupal Summit - Seattle October 20th, 2012](https://reader036.fdocuments.net/reader036/viewer/2022062809/568157ed550346895dc5639c/html5/thumbnails/15.jpg)
Testing for Intersectionfunction geoquery_intersects($item1, $item2) { $params = array($item1, $item2); foreach ($params as &$param) { if (is_scalar($param)) { $param = array('entity_type' => 'node', 'eid' => $param); } } if ($connection = sync_postgis_get_postgis_connection()) { $geo_query = new syncPgQuery($connection); return $geo_query->booleanRelQuery('intersects', $params[0], $params[1])->execute(); }
![Page 16: GIS Tool in Drupal PNW Drupal Summit - Seattle October 20th, 2012](https://reader036.fdocuments.net/reader036/viewer/2022062809/568157ed550346895dc5639c/html5/thumbnails/16.jpg)
Testing for Buffer Distancefunction geoquery_dwithin($item1, $item2, $distance = 0, $srid = 4326) { $params = array($item1, $item2); foreach ($params as &$param) { if (is_scalar($param)) { $param = array('entity_type' => 'node', 'eid' => $param); } } if ($connection = sync_postgis_get_postgis_connection()) { $geo_query = new syncPgQuery($connection, $srid); return $geo_query->booleanRelQuery('dwithin', $params[0], $params[1], $distance)->execute(); }}
![Page 17: GIS Tool in Drupal PNW Drupal Summit - Seattle October 20th, 2012](https://reader036.fdocuments.net/reader036/viewer/2022062809/568157ed550346895dc5639c/html5/thumbnails/17.jpg)
Displaying the results
With the results from the PostGIS backend, we can show the user useful information
In this case they know that
- target is in the protected area - target intersects 2 traplines
- target is within a 5 km buffer of 4 other nodes of interest
![Page 18: GIS Tool in Drupal PNW Drupal Summit - Seattle October 20th, 2012](https://reader036.fdocuments.net/reader036/viewer/2022062809/568157ed550346895dc5639c/html5/thumbnails/18.jpg)
Scaling
![Page 19: GIS Tool in Drupal PNW Drupal Summit - Seattle October 20th, 2012](https://reader036.fdocuments.net/reader036/viewer/2022062809/568157ed550346895dc5639c/html5/thumbnails/19.jpg)
Beyond Vector Based Maps
We want to show huge datasets, the vector model requires "painting" the data onto the map, which is computationally expensive
Pre-rendering the dataset onto a tile, means the client can load the data quickly, and tiles are easy to cache
Obvious downside of caching, is that it doesn't work well with frequently changing data
Tilemill has been great for creating base tiles, but regenerating the entire tileset when the data changes is hard and time consuming
![Page 20: GIS Tool in Drupal PNW Drupal Summit - Seattle October 20th, 2012](https://reader036.fdocuments.net/reader036/viewer/2022062809/568157ed550346895dc5639c/html5/thumbnails/20.jpg)
Comparing Vector vs MB Tiles
Vector - 2.30 MB of transfer - Client side render
Tiles - 529 kB of transfer - Server side render
![Page 21: GIS Tool in Drupal PNW Drupal Summit - Seattle October 20th, 2012](https://reader036.fdocuments.net/reader036/viewer/2022062809/568157ed550346895dc5639c/html5/thumbnails/21.jpg)
Tilestache
Python application for serving tiles
tilestache takes inputs of : --- mbtiles which are pre-generated --- mapnik configuration (to generate tiles on the fly)--- vector (geojson, arcjson) --- combinations of these inputs as composite
We are generating using mapnik with PostGIS as a datasource
- provides a caching layer for serving tiles
![Page 22: GIS Tool in Drupal PNW Drupal Summit - Seattle October 20th, 2012](https://reader036.fdocuments.net/reader036/viewer/2022062809/568157ed550346895dc5639c/html5/thumbnails/22.jpg)
Composite maps from PostGIS Data
• base map satellite images• tilestache provides the data
layers from PostGIS via mapnik• leaflet map definition points to
layers in the layer switcher
Image credit http://mike.teczno.com/notes/tilestache.html
![Page 23: GIS Tool in Drupal PNW Drupal Summit - Seattle October 20th, 2012](https://reader036.fdocuments.net/reader036/viewer/2022062809/568157ed550346895dc5639c/html5/thumbnails/23.jpg)
WAX interactivity
• parcel data with tiles in JSON• on mouseover and on click behaviours• need to pre-cache WAX styling
![Page 24: GIS Tool in Drupal PNW Drupal Summit - Seattle October 20th, 2012](https://reader036.fdocuments.net/reader036/viewer/2022062809/568157ed550346895dc5639c/html5/thumbnails/24.jpg)
WAX interactivity
![Page 25: GIS Tool in Drupal PNW Drupal Summit - Seattle October 20th, 2012](https://reader036.fdocuments.net/reader036/viewer/2022062809/568157ed550346895dc5639c/html5/thumbnails/25.jpg)
WAX interactivity
Demo
![Page 26: GIS Tool in Drupal PNW Drupal Summit - Seattle October 20th, 2012](https://reader036.fdocuments.net/reader036/viewer/2022062809/568157ed550346895dc5639c/html5/thumbnails/26.jpg)
WAX interactivity
How UTF8 grid workshttp://mapbox.com/demo/visiblemap/
![Page 27: GIS Tool in Drupal PNW Drupal Summit - Seattle October 20th, 2012](https://reader036.fdocuments.net/reader036/viewer/2022062809/568157ed550346895dc5639c/html5/thumbnails/27.jpg)
Random Tools
![Page 28: GIS Tool in Drupal PNW Drupal Summit - Seattle October 20th, 2012](https://reader036.fdocuments.net/reader036/viewer/2022062809/568157ed550346895dc5639c/html5/thumbnails/28.jpg)
Leaflet Draw
![Page 29: GIS Tool in Drupal PNW Drupal Summit - Seattle October 20th, 2012](https://reader036.fdocuments.net/reader036/viewer/2022062809/568157ed550346895dc5639c/html5/thumbnails/29.jpg)
Leaflet Paste
![Page 30: GIS Tool in Drupal PNW Drupal Summit - Seattle October 20th, 2012](https://reader036.fdocuments.net/reader036/viewer/2022062809/568157ed550346895dc5639c/html5/thumbnails/30.jpg)
Search API
Next we want to be able to return data items from SOLR to a map
Search on non-geographic facets - just like a view
Search on geographic facets - facet controls pull data from PostGIS, or use SOLRs spatial extensions
http://drupal.org/project/search_api_location