GIS Tool in DrupalPNW Drupal Summit - Seattle    October 20th, 2012  Mack Hardy & Tom Nightingale        @AffinityBridge
History of Maps with Drupal Tools
Location Module,proximity and filter
Storage and Import
Storage - GeoFieldWhere do we store data in drupal?A common field formatfor geodata • WKT • Lat Lon • Bounding
Spatial ImportHow do we import data from external sources?ShapefilesKML filesUses GeoPHP and ogr2ogrSpatial module -> Save...
ogr2ogrWrapper module for the GDAL ogr2ogr library- Spatial module calls ogr2ogr- Converts data from source formats to WKT...
Query
Sync_PostGIS Module• Allows drupal to query PostGIS as a spatial query  service, much in the way SOLR is used for search• ...
Sync_PostGIS Module
What does sync_postgis tell us?  Intersections with other data points  Within a buffer of 5km
Testing for Intersectionfunction geoquery_intersects($item1, $item2) {  $params = array($item1, $item2);  foreach ($params...
Testing for Buffer Distancefunction geoquery_dwithin($item1, $item2, $distance = 0, $srid = 4326){  $params = array($item1...
Displaying the resultsWith the results from the PostGISbackend, we can show the useruseful informationIn this case they kn...
Scaling
Beyond Vector Based MapsWe want to show huge datasets, the vector model requires"painting" the data onto the map, which is...
Comparing Vector vs MB TilesVector - 2.30 MB of transfer - Client side renderTiles - 529 kB of transfer - Server side render
TilestachePython application for serving tilestilestache takes inputs of :--- mbtiles which are pre-generated--- mapnik co...
Composite maps from PostGIS Data• base map satellite images• tilestache provides the data  layers from PostGIS via mapnik•...
WAX interactivity• parcel data with tiles in JSON• on mouseover and on click behaviours• need to pre-cache WAX styling
WAX interactivity
WAX interactivity  Demo
WAX interactivityHow UTF8 grid workshttp://mapbox.com/demo/visiblemap/
Random Tools
Leaflet Draw
Leaflet Paste
Search APINext we want to be able to return data items from SOLRto a mapSearch on non-geographic facets - just like a view...
Discussionmack@affinitybridge.com http://affinitybridge.com
Server side geo_tools_in_drupal_pnw_2012
Server side geo_tools_in_drupal_pnw_2012
Server side geo_tools_in_drupal_pnw_2012
Upcoming SlideShare
Loading in...5
×

Server side geo_tools_in_drupal_pnw_2012

1,319

Published on

Mack Hardy @mackaffinity from Affinity Bridge @affinitybridge discusses server side mapping tools for drupal, using PostGIS as a spatial backend, generating tiles and managing large sets of geodata and displaying it in Drupal CMS

0 Comments
4 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,319
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
12
Comments
0
Likes
4
Embeds 0
No embeds

No notes for slide
  • Location module - geocoding and showing on a map Location module - proximity searches for points, small sets * some example of some old timey proximity tools *  Performance issues  as > 500 markers
  • Make a simpler verison? Remove this slide?
  • Make a simpler verison? Remove this slide?
  • Now that the geodata is in postgis, we can pull the data from postgis into other applications some examples of this would be  tilestache, and tilemill
  • Now that the geodata is in postgis, we can pull the data from postgis into other applications some examples of this would be  tilestache, and tilemill
  • http://ctweb06.cantrusthosting.com:8888/fnfn-stories--water/preview.html#10/58.6809/-121.8900 http://ctweb06.cantrusthosting.com:8888/fnfn-stories--roads/preview.html#10/58.6809/-121.8900 http://ctweb06.cantrusthosting.com:8888/fnfn-stories--survey/preview.html#10/58.6809/-121.8900 http://ctweb06.cantrusthosting.com:8888/fnfn-stories--sites/preview.html#10/58.6809/-121.8900
  • http://ctweb06.cantrusthosting.com:8888/fnfn-stories--water/preview.html#10/58.6809/-121.8900 http://ctweb06.cantrusthosting.com:8888/fnfn-stories--roads/preview.html#10/58.6809/-121.8900 http://ctweb06.cantrusthosting.com:8888/fnfn-stories--survey/preview.html#10/58.6809/-121.8900 http://ctweb06.cantrusthosting.com:8888/fnfn-stories--sites/preview.html#10/58.6809/-121.8900
  • http://ctweb06.cantrusthosting.com:8888/fnfn-stories--water/preview.html#10/58.6809/-121.8900 http://ctweb06.cantrusthosting.com:8888/fnfn-stories--roads/preview.html#10/58.6809/-121.8900 http://ctweb06.cantrusthosting.com:8888/fnfn-stories--survey/preview.html#10/58.6809/-121.8900 http://ctweb06.cantrusthosting.com:8888/fnfn-stories--sites/preview.html#10/58.6809/-121.8900
  • http://ctweb06.cantrusthosting.com:8888/fnfn-stories--water/preview.html#10/58.6809/-121.8900 http://ctweb06.cantrusthosting.com:8888/fnfn-stories--roads/preview.html#10/58.6809/-121.8900 http://ctweb06.cantrusthosting.com:8888/fnfn-stories--survey/preview.html#10/58.6809/-121.8900 http://ctweb06.cantrusthosting.com:8888/fnfn-stories--sites/preview.html#10/58.6809/-121.8900
  • http://ctweb06.cantrusthosting.com:8888/fnfn-stories--water/preview.html#10/58.6809/-121.8900 http://ctweb06.cantrusthosting.com:8888/fnfn-stories--roads/preview.html#10/58.6809/-121.8900 http://ctweb06.cantrusthosting.com:8888/fnfn-stories--survey/preview.html#10/58.6809/-121.8900 http://ctweb06.cantrusthosting.com:8888/fnfn-stories--sites/preview.html#10/58.6809/-121.8900
  • http://ctweb06.cantrusthosting.com:8888/fnfn-stories--water/preview.html#10/58.6809/-121.8900 http://ctweb06.cantrusthosting.com:8888/fnfn-stories--roads/preview.html#10/58.6809/-121.8900 http://ctweb06.cantrusthosting.com:8888/fnfn-stories--survey/preview.html#10/58.6809/-121.8900 http://ctweb06.cantrusthosting.com:8888/fnfn-stories--sites/preview.html#10/58.6809/-121.8900
  • Server side geo_tools_in_drupal_pnw_2012

    1. 1. GIS Tool in DrupalPNW Drupal Summit - Seattle October 20th, 2012 Mack Hardy & Tom Nightingale @AffinityBridge
    2. 2. History of Maps with Drupal Tools
    3. 3. Location Module,proximity and filter
    4. 4. Storage and Import
    5. 5. Storage - GeoFieldWhere do we store data in drupal?A common field formatfor geodata • WKT • Lat Lon • Bounding
    6. 6. Spatial ImportHow do we import data from external sources?ShapefilesKML filesUses GeoPHP and ogr2ogrSpatial module -> Saves as WKT -> Geofieldhttp://drupal.org/project/spatial
    7. 7. ogr2ogrWrapper module for the GDAL ogr2ogr library- Spatial module calls ogr2ogr- Converts data from source formats to WKThttp://drupal.org/project/ogr2ogr
    8. 8. Query
    9. 9. 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
    10. 10. Sync_PostGIS Module
    11. 11. What does sync_postgis tell us? Intersections with other data points Within a buffer of 5km
    12. 12. 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(); }
    13. 13. 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(); }}
    14. 14. Displaying the resultsWith the results from the PostGISbackend, we can show the useruseful informationIn this case they know that- target is in the protected area- target intersects 2 traplines- target is within a 5 km buffer of 4other nodes of interest
    15. 15. Scaling
    16. 16. Beyond Vector Based MapsWe want to show huge datasets, the vector model requires"painting" the data onto the map, which is computationallyexpensivePre-rendering the dataset onto a tile, means the client canload the data quickly, and tiles are easy to cacheObvious downside of caching, is that it doesnt work wellwith frequently changing dataTilemill has been great for creating base tiles, butregenerating the entire tileset when the data changes ishard and time consuming
    17. 17. Comparing Vector vs MB TilesVector - 2.30 MB of transfer - Client side renderTiles - 529 kB of transfer - Server side render
    18. 18. TilestachePython application for serving tilestilestache takes inputs of :--- mbtiles which are pre-generated--- mapnik configuration (to generate tiles on the fly)--- vector (geojson, arcjson)--- combinations of these inputs as compositeWe are generating using mapnik with PostGIS as a datasource- provides a caching layer for serving tiles
    19. 19. 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
    20. 20. WAX interactivity• parcel data with tiles in JSON• on mouseover and on click behaviours• need to pre-cache WAX styling
    21. 21. WAX interactivity
    22. 22. WAX interactivity Demo
    23. 23. WAX interactivityHow UTF8 grid workshttp://mapbox.com/demo/visiblemap/
    24. 24. Random Tools
    25. 25. Leaflet Draw
    26. 26. Leaflet Paste
    27. 27. Search APINext we want to be able to return data items from SOLRto a mapSearch on non-geographic facets - just like a viewSearch on geographic facets - facet controls pull datafrom PostGIS, or use SOLRs spatial extensionshttp://drupal.org/project/search_api_location
    28. 28. Discussionmack@affinitybridge.com http://affinitybridge.com
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×