SlideShare uma empresa Scribd logo
1 de 47
Baixar para ler offline
GeoDjango in a nutshell
                                 Vasyl Dizhak
                           http://djangostars.com/




Friday, August 26, 2011
• Into
                     • Standards
                     • Django/GeoDjango
                     • Demo app
                     • Open source

Friday, August 26, 2011
Friday, August 26, 2011
“80% of projects and
                     services include spatial
                            data” Cliché



Friday, August 26, 2011
“nere things are more
                   related than distant
                         things”
                          W.R.Tobler (1970)




Friday, August 26, 2011
Geographic information
                     systems(GIS)
                     • Standards, spatial
                          data, coordinate
                          systems

                     • Maps are flat, world is
                          not




Friday, August 26, 2011
Coordinate systems
             Geodetic (coordinates are in angels latitude/
                            longitude)
               Projected (represents world surface in a flat way,
                 using linear units and play with various distortions)




Friday, August 26, 2011
Standards
                     •    OGC: Open Geospatial Consortium. Inc.

                          •   Promulgates standards for geospatial
                              and location based services

                     •    SFS: Simple Feature Access for SQL

                          •   OGC standard for spatial databases

                          •   The most popular

                     •    WKT: Well Known Text

                          •   Geometries

                          •   Coordinate systems



Friday, August 26, 2011
•    WKB: Well Known Binary

                          •   Binary representation of geometries

                          •   HEX: Binary

                     •    EWKT

                     •    EWKB, HEXEWKB

                     •    GML: Geometry Markup Language (XML based)

                     •    KML: Keyhole Markup Language

                          •   Google Earth/Maps Format

                     •    WMS: Web Mapping Service(serves up images)

                     •    WFS: Web Feature Service (serves up vector data)


Friday, August 26, 2011
Near things
                     •    GeoJSON: Geometry JSON (not in OGC
                          standard)

                     •    SRS: Spatial Reference System

                     •    CRS: Coordinate Reference System (same as SRS)

                     •    EPSG: European Petroleum Survey Group

                     •    SRID: Spatial Reference Indenifier (corresponds to
                          EPSG number)



Friday, August 26, 2011
Geometry objects

         •        Point
         •        LineString
         •        LinearRing
         •        Polygon

         •        MultiPoint

         •        MultiString

         •        MultiPolygon

         •        GeometryCollection


Friday, August 26, 2011
Django

                     • Python based framework
                     • Powerful ORM
                     • MTV concepts
                     • Support unix and windows platforms

Friday, August 26, 2011
GeoDjango

                     • Based on the top of django, so include all
                          benefits :)
                     • Include python interfaces for GEOS,
                          GDAL, GeoIP thanks to ctypes support in
                          python




Friday, August 26, 2011
Friday, August 26, 2011
http://houstoncrimemaps.com/


Friday, August 26, 2011
History
                     • Initially created by Justin Bronn
                     • Started in 2006
                     • 2008 - 1.0 release
                     • 2009 - 1.1 release
                     • 2010 - 1.2 release
                     • 2011 - 1.3 release
Friday, August 26, 2011
Real using




                          http://www.everyblock.com/

Friday, August 26, 2011
• http://www.nytimes.com/
                     • http://projects.latimes.com/mapping-la/
                       neiborhoods/

                     • http://marinemap.org/
                     • http://earth.burningman.com/
                     • http://about.nsw.gov.au/
                     • and others ...

Friday, August 26, 2011
GEOS
                          • Geometry Engine Open Source
                            In [3] from django.contrib.gis.geos import *

                            In [4]: point = GEOSGeometry('Point(0 10)')

                            In [5]: point.coords

                            Out[5]: (0.0, 10.0)




Friday, August 26, 2011
In [7]: coords = ((0, 0), (0, 10), (10, 13), (0, 0))

                      In [8]: polygon = Polygon(coords)

                      In [9]: mpolygon = MultiPolygon(polygon)




Friday, August 26, 2011
In [33]: polygon.wkt

Out[33]: 'POLYGON ((0.0000000000000000 0.0000000000000000,
0.0000000000000000 10.0000000000000000, 10.0000000000000000 13.0000000000000000,
 0.0000000000000000 0.0000000000000000))'

In [34]: polygon.contains(Point(11, 12))

Out[34]: False

In [35]: polygon.json

Out[35]: '{ "type": "Polygon", "coordinates":
[ [ [ 0.000000, 0.000000 ], [ 0.000000, 10.000000 ],
[ 10.000000, 13.000000 ], [ 0.000000, 0.000000 ] ] ] }'

In [36]: polygon.kml

Out[36]: '<Polygon><outerBoundaryIs><LinearRing>
<coordinates>0.0,0.0,0 0.0,10.0,0 10.0,13.0,0 0.0,0.0,0</coordinates>
</LinearRing></outerBoundaryIs></Polygon>'




Friday, August 26, 2011
GDAL
                          Geospatial Data Abstraction Library
                   In [2]: from django.contrib.gis.gdal import *
                   ...
                   In [28]: k = DataSource('data/ukraine_administrative.shp')
                   In [29]: layer = k[0]
                   In [30]: layer
                   Out[30]: <django.contrib.gis.gdal.layer.Layer object at
                   0x10325f990>
                   In [31]: len(layer)
                   Out[31]: 9976
                   In [32]: layer.fields
                   Out[32]: ['NAME', 'ADMIN_LEVE']
Friday, August 26, 2011
You can transform coordinates from one projection to
                             another

                     In [37]: s = SpatialReference(4326)

                     In [39]: k = GEOSGeometry('Point(10 10)', s)

                     In [40]: k.transform(900913)




Friday, August 26, 2011
GeoIP
                          IP-based Geolocation binding to MaxMind
         In [1]: from django.contrib.gis.utils import GeoIP
         In [2]: g = GeoIP()
         In [6]: g.country('it-jam.ciklum.net')
         Out[6]: {'country_name': 'Ukraine', 'country_code': 'UA'}
         In [7]: g.city('it-jam.ciklum.net')
         Out[7]: {'city': None, 'region': None, 'area_code': 0, 'longitude': 32.0, 'country_code3': 'UKR',
         'latitude': 49.0, 'postal_code': None, 'dma_code': 0, 'country_code': 'UA', 'country_name':
         'Ukraine'}
         In [8]: g.geos('it-jam.ciklum.net')
         Out[8]: <Point object at 0x103482fd0>
         In [9]: g.geos('it-jam.ciklum.net').coords
         Out[9]: (32.0, 49.0)




Friday, August 26, 2011
Geometry Fields
                          •   GeometryField

                          •   PointField

                          •   LineStringField

                          •   PolygonField

                          •   MultiPointField

                          •   MultiLineStringField

                          •   MultiPolygonField

                          •   GeometryCollectionField



Friday, August 26, 2011
Models example

            from django.contrib.gis.db import models

            class Checkin(models.Model):
               type = models.CharField(max_length=1, choices=CHECKIN_TYPE)
               title = models.CharField(max_length=255, blank=True, null=True)
               geodata = models.PointField()
               updated = models.DateTimeField(auto_now=True)

                   objects = models.GeoManager()




Friday, August 26, 2011
PostgreSQL SQL




Friday, August 26, 2011
Geometry Field Options
                     • srid (Spatial Reference System Identity,
                          corresponding to spatial_ref_sys db
                          table, default is 4326)
                     • spatial_index (Spatial indexes are created
                          by default)
                     • dim (Set dimension if backend supports
                          this, default is 2, postgis only)
                     • geography

Friday, August 26, 2011
Spatial Lookups




Friday, August 26, 2011
Lookup types
   PostGIS is a rock star :)
  As parameters lookups
 can be any data that can
 be converted into GEOS
      geometry like
   GeoJSON, WKT etc.

       https://docs.djangoproject.com/en/dev/ref/contrib/gis/db-api/#spatial-lookup-compatibility




Friday, August 26, 2011
Example
            In[8]: pnt = Point(40.187953, 49.9658546)

            In[9]: Administrative.objects.get
            (geodata__contains=pnt)

            Out[10]: <Administrative: 9976>




Friday, August 26, 2011
Measurement objects

                          Conversation between measurement units




Friday, August 26, 2011
Distance, D
                In [1]: from django.contrib.gis.measure import D

                In [2]: dist = D(km=500)

                In [3]: dist.mi

                Out[3]: 310.68559611866698

                In [4]: dist.rod

                Out[4]: 99419.390757973422


Friday, August 26, 2011
Area, A
                 In [1]: from django.contrib.gis.measure import A

                 In [2]: a = A(sq_m = 10)

                 In [3]: a.sq_km

                 Out[3]: 1.0000000000000001e-05

                 In [4]: a.sq_rod

                 Out[4]: 0.39536861034746451



Friday, August 26, 2011
Distance queries*
                  In [10]: Checkin.objects.filter(geodata__distance_gte=(pnt, 7000))

                  Out[10]: [<Checkin: Ресторан «Домашня Кухня»>, <Checkin:
                  Великий Вiз>, <Checkin: Ресторан «Домашня Кухня»>,
                  <Checkin: Станція швидкісного трамвая "Польова">, <Checkin:
                  НТУУ "КПИ", корпус 7>]




Friday, August 26, 2011
GeoQuerySet Methods

  MySQL does not
support any of these




                          more ...


Friday, August 26, 2011
Aggregate Methods

                     • collect
                     • extend
                     • extend3d
                     • make_line
                     • unionagg

Friday, August 26, 2011
Output methods
          Done more on db level

                     • kml()
                     • gml()
                     • svg()
                     • geojson()
                     • geohash()

Friday, August 26, 2011
Measurement methods

                     • area()(attachs the area to each geometry
                          field in the queryset as Area object )
                     • distance(geom)
                     • length()
                     • perimeter()

Friday, August 26, 2011
Geometry operations

                     • difference(geom)
                     • intersection(geom)
                     • union(geom)
                     • sym_difference(geom)

Friday, August 26, 2011
Geometry methods
                     • centroid()
                     • envelope()
                     • point_on_surface()
                     • scale(x, y, z=0)
                     • translate(x, y, z=0)
                     • transform(srid)
Friday, August 26, 2011
In [10]: k = Administrative.objects.kml().svg().perimeter
().point_on_surface().get(id=10)

In [11]: k.point_on_surface.coords

Out[11]: (22.153155999999999, 48.512821000000002)

In [12]: k.kml

Out[12]:
u'<LineString><coordinates>22.166018,48.5771299


Friday, August 26, 2011
Show time



Friday, August 26, 2011
Related projects

                     • FeatureServer http://featureserver.org
                     • TileCache http://tilecache.org
                     • TileStache http://tilestache.org/
                     • Mapproxy http://mapproxy.org/



Friday, August 26, 2011
Cartography

                     • Mapnik http://mapnik.org
                     • MapServer http://mapserver.org




Friday, August 26, 2011
Frontend interaction
                     • OpenLayers http://openlayer.org
                     • Google maps js api
                     • Polymaps http://polymaps.org/
                     • Wax http://mapbox.github.com/wax/
                          manual/
                     • TileMill http://tilemill.com/pages/index.html
Friday, August 26, 2011
Many thanks
              Vasyl Dizhak
                 http://twitter.com/rootart
                http://twitter.com/djangostars
                      http://geojam.djangostars.com
                      http://github.com/rootart/geojam
             Questions?




Friday, August 26, 2011

Mais conteúdo relacionado

Destaque

Social Networks and Computer Science
Social Networks and Computer ScienceSocial Networks and Computer Science
Social Networks and Computer Sciencedragonmeteor
 
Paris Presentation
Paris PresentationParis Presentation
Paris Presentationnewellm
 
Complex and Social Network Analysis in Python
Complex and Social Network Analysis in PythonComplex and Social Network Analysis in Python
Complex and Social Network Analysis in Pythonrik0
 
Sustainability Power Point
Sustainability Power PointSustainability Power Point
Sustainability Power PointHowardLitwak
 
Power Point project on Paris
Power Point project on ParisPower Point project on Paris
Power Point project on Pariskimmy
 
Case study of Uttarakhand Flood Disaster 2013 - by Narendra Yadav
Case study of Uttarakhand Flood Disaster 2013 - by Narendra YadavCase study of Uttarakhand Flood Disaster 2013 - by Narendra Yadav
Case study of Uttarakhand Flood Disaster 2013 - by Narendra YadavNarendra Yadav
 

Destaque (7)

Social Networks and Computer Science
Social Networks and Computer ScienceSocial Networks and Computer Science
Social Networks and Computer Science
 
Paris Presentation
Paris PresentationParis Presentation
Paris Presentation
 
Complex and Social Network Analysis in Python
Complex and Social Network Analysis in PythonComplex and Social Network Analysis in Python
Complex and Social Network Analysis in Python
 
Geodjango
GeodjangoGeodjango
Geodjango
 
Sustainability Power Point
Sustainability Power PointSustainability Power Point
Sustainability Power Point
 
Power Point project on Paris
Power Point project on ParisPower Point project on Paris
Power Point project on Paris
 
Case study of Uttarakhand Flood Disaster 2013 - by Narendra Yadav
Case study of Uttarakhand Flood Disaster 2013 - by Narendra YadavCase study of Uttarakhand Flood Disaster 2013 - by Narendra Yadav
Case study of Uttarakhand Flood Disaster 2013 - by Narendra Yadav
 

Semelhante a GeoDjango in a nutshell

Pycon 2012 Taiwan
Pycon 2012 TaiwanPycon 2012 Taiwan
Pycon 2012 TaiwanDongpo Deng
 
Developing Geospatial software with Python, Part 1
Developing Geospatial software with Python, Part 1Developing Geospatial software with Python, Part 1
Developing Geospatial software with Python, Part 1Paolo Corti
 
Covering the earth and the cloud the next generation of spatial in sql server...
Covering the earth and the cloud the next generation of spatial in sql server...Covering the earth and the cloud the next generation of spatial in sql server...
Covering the earth and the cloud the next generation of spatial in sql server...Texas Natural Resources Information System
 
Big Geo Data: Open Source and Open Standards
Big Geo Data: Open Source and Open StandardsBig Geo Data: Open Source and Open Standards
Big Geo Data: Open Source and Open StandardsGeorge Percivall
 
[PR12] You Only Look Once (YOLO): Unified Real-Time Object Detection
[PR12] You Only Look Once (YOLO): Unified Real-Time Object Detection[PR12] You Only Look Once (YOLO): Unified Real-Time Object Detection
[PR12] You Only Look Once (YOLO): Unified Real-Time Object DetectionTaegyun Jeon
 
LocationTech Projects
LocationTech ProjectsLocationTech Projects
LocationTech ProjectsJody Garnett
 
Open Source GIS and Modeling Tools
Open Source GIS and  Modeling ToolsOpen Source GIS and  Modeling Tools
Open Source GIS and Modeling ToolsJohn Doxaras
 
Big Linked Data Federation - ExtremeEarth Open Workshop
Big Linked Data Federation - ExtremeEarth Open WorkshopBig Linked Data Federation - ExtremeEarth Open Workshop
Big Linked Data Federation - ExtremeEarth Open WorkshopExtremeEarth
 
PINOGIO : A simple way to create a web infographic map (피노지오 : 웹 인포그래픽 맵을 만드는...
PINOGIO : A simple way to create a web infographic map (피노지오 : 웹 인포그래픽 맵을 만드는...PINOGIO : A simple way to create a web infographic map (피노지오 : 웹 인포그래픽 맵을 만드는...
PINOGIO : A simple way to create a web infographic map (피노지오 : 웹 인포그래픽 맵을 만드는...HaNJiN Lee
 
LocationTech Tour 2016 - Vectortiles
LocationTech Tour 2016 - Vectortiles LocationTech Tour 2016 - Vectortiles
LocationTech Tour 2016 - Vectortiles Morgan Thompson
 
OpenMapTiles: Vector tiles from OpenStreetMap
OpenMapTiles: Vector tiles from OpenStreetMapOpenMapTiles: Vector tiles from OpenStreetMap
OpenMapTiles: Vector tiles from OpenStreetMapPetr Pridal
 
Geographica: A Benchmark for Geospatial RDF Stores - ISWC 2013
Geographica: A Benchmark for Geospatial RDF Stores - ISWC 2013Geographica: A Benchmark for Geospatial RDF Stores - ISWC 2013
Geographica: A Benchmark for Geospatial RDF Stores - ISWC 2013Kostis Kyzirakos
 
GeoNetwork workshop introduction mapwindow conference 2012 Velp
GeoNetwork workshop introduction mapwindow conference 2012 VelpGeoNetwork workshop introduction mapwindow conference 2012 Velp
GeoNetwork workshop introduction mapwindow conference 2012 Velppvangenuchten
 
Cloud conf-varna-2014-mihail mateev-spatial-data-and-microsoft-azure-sql-data...
Cloud conf-varna-2014-mihail mateev-spatial-data-and-microsoft-azure-sql-data...Cloud conf-varna-2014-mihail mateev-spatial-data-and-microsoft-azure-sql-data...
Cloud conf-varna-2014-mihail mateev-spatial-data-and-microsoft-azure-sql-data...Mihail Mateev
 
Comprehensive Overview of the Geoweb
Comprehensive Overview of the GeowebComprehensive Overview of the Geoweb
Comprehensive Overview of the GeowebGovernment/CU Denver
 
Spatial Data in SQL Server
Spatial Data in SQL ServerSpatial Data in SQL Server
Spatial Data in SQL ServerEduardo Castro
 
Drupal mapping modules
Drupal mapping modulesDrupal mapping modules
Drupal mapping modulesPatrick Hayes
 

Semelhante a GeoDjango in a nutshell (20)

GWT Plus HTML 5
GWT Plus HTML 5GWT Plus HTML 5
GWT Plus HTML 5
 
Pycon 2012 Taiwan
Pycon 2012 TaiwanPycon 2012 Taiwan
Pycon 2012 Taiwan
 
Developing Geospatial software with Python, Part 1
Developing Geospatial software with Python, Part 1Developing Geospatial software with Python, Part 1
Developing Geospatial software with Python, Part 1
 
Covering the earth and the cloud the next generation of spatial in sql server...
Covering the earth and the cloud the next generation of spatial in sql server...Covering the earth and the cloud the next generation of spatial in sql server...
Covering the earth and the cloud the next generation of spatial in sql server...
 
State of JTS 2018
State of JTS 2018State of JTS 2018
State of JTS 2018
 
Big Geo Data: Open Source and Open Standards
Big Geo Data: Open Source and Open StandardsBig Geo Data: Open Source and Open Standards
Big Geo Data: Open Source and Open Standards
 
[PR12] You Only Look Once (YOLO): Unified Real-Time Object Detection
[PR12] You Only Look Once (YOLO): Unified Real-Time Object Detection[PR12] You Only Look Once (YOLO): Unified Real-Time Object Detection
[PR12] You Only Look Once (YOLO): Unified Real-Time Object Detection
 
LocationTech Projects
LocationTech ProjectsLocationTech Projects
LocationTech Projects
 
Open Source GIS and Modeling Tools
Open Source GIS and  Modeling ToolsOpen Source GIS and  Modeling Tools
Open Source GIS and Modeling Tools
 
Dario izzo - grand jupiter tour
Dario izzo - grand jupiter tourDario izzo - grand jupiter tour
Dario izzo - grand jupiter tour
 
Big Linked Data Federation - ExtremeEarth Open Workshop
Big Linked Data Federation - ExtremeEarth Open WorkshopBig Linked Data Federation - ExtremeEarth Open Workshop
Big Linked Data Federation - ExtremeEarth Open Workshop
 
PINOGIO : A simple way to create a web infographic map (피노지오 : 웹 인포그래픽 맵을 만드는...
PINOGIO : A simple way to create a web infographic map (피노지오 : 웹 인포그래픽 맵을 만드는...PINOGIO : A simple way to create a web infographic map (피노지오 : 웹 인포그래픽 맵을 만드는...
PINOGIO : A simple way to create a web infographic map (피노지오 : 웹 인포그래픽 맵을 만드는...
 
LocationTech Tour 2016 - Vectortiles
LocationTech Tour 2016 - Vectortiles LocationTech Tour 2016 - Vectortiles
LocationTech Tour 2016 - Vectortiles
 
OpenMapTiles: Vector tiles from OpenStreetMap
OpenMapTiles: Vector tiles from OpenStreetMapOpenMapTiles: Vector tiles from OpenStreetMap
OpenMapTiles: Vector tiles from OpenStreetMap
 
Geographica: A Benchmark for Geospatial RDF Stores - ISWC 2013
Geographica: A Benchmark for Geospatial RDF Stores - ISWC 2013Geographica: A Benchmark for Geospatial RDF Stores - ISWC 2013
Geographica: A Benchmark for Geospatial RDF Stores - ISWC 2013
 
GeoNetwork workshop introduction mapwindow conference 2012 Velp
GeoNetwork workshop introduction mapwindow conference 2012 VelpGeoNetwork workshop introduction mapwindow conference 2012 Velp
GeoNetwork workshop introduction mapwindow conference 2012 Velp
 
Cloud conf-varna-2014-mihail mateev-spatial-data-and-microsoft-azure-sql-data...
Cloud conf-varna-2014-mihail mateev-spatial-data-and-microsoft-azure-sql-data...Cloud conf-varna-2014-mihail mateev-spatial-data-and-microsoft-azure-sql-data...
Cloud conf-varna-2014-mihail mateev-spatial-data-and-microsoft-azure-sql-data...
 
Comprehensive Overview of the Geoweb
Comprehensive Overview of the GeowebComprehensive Overview of the Geoweb
Comprehensive Overview of the Geoweb
 
Spatial Data in SQL Server
Spatial Data in SQL ServerSpatial Data in SQL Server
Spatial Data in SQL Server
 
Drupal mapping modules
Drupal mapping modulesDrupal mapping modules
Drupal mapping modules
 

Último

FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 

Último (20)

FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 

GeoDjango in a nutshell

  • 1. GeoDjango in a nutshell Vasyl Dizhak http://djangostars.com/ Friday, August 26, 2011
  • 2. • Into • Standards • Django/GeoDjango • Demo app • Open source Friday, August 26, 2011
  • 4. “80% of projects and services include spatial data” Cliché Friday, August 26, 2011
  • 5. “nere things are more related than distant things” W.R.Tobler (1970) Friday, August 26, 2011
  • 6. Geographic information systems(GIS) • Standards, spatial data, coordinate systems • Maps are flat, world is not Friday, August 26, 2011
  • 7. Coordinate systems Geodetic (coordinates are in angels latitude/ longitude) Projected (represents world surface in a flat way, using linear units and play with various distortions) Friday, August 26, 2011
  • 8. Standards • OGC: Open Geospatial Consortium. Inc. • Promulgates standards for geospatial and location based services • SFS: Simple Feature Access for SQL • OGC standard for spatial databases • The most popular • WKT: Well Known Text • Geometries • Coordinate systems Friday, August 26, 2011
  • 9. WKB: Well Known Binary • Binary representation of geometries • HEX: Binary • EWKT • EWKB, HEXEWKB • GML: Geometry Markup Language (XML based) • KML: Keyhole Markup Language • Google Earth/Maps Format • WMS: Web Mapping Service(serves up images) • WFS: Web Feature Service (serves up vector data) Friday, August 26, 2011
  • 10. Near things • GeoJSON: Geometry JSON (not in OGC standard) • SRS: Spatial Reference System • CRS: Coordinate Reference System (same as SRS) • EPSG: European Petroleum Survey Group • SRID: Spatial Reference Indenifier (corresponds to EPSG number) Friday, August 26, 2011
  • 11. Geometry objects • Point • LineString • LinearRing • Polygon • MultiPoint • MultiString • MultiPolygon • GeometryCollection Friday, August 26, 2011
  • 12. Django • Python based framework • Powerful ORM • MTV concepts • Support unix and windows platforms Friday, August 26, 2011
  • 13. GeoDjango • Based on the top of django, so include all benefits :) • Include python interfaces for GEOS, GDAL, GeoIP thanks to ctypes support in python Friday, August 26, 2011
  • 16. History • Initially created by Justin Bronn • Started in 2006 • 2008 - 1.0 release • 2009 - 1.1 release • 2010 - 1.2 release • 2011 - 1.3 release Friday, August 26, 2011
  • 17. Real using http://www.everyblock.com/ Friday, August 26, 2011
  • 18. • http://www.nytimes.com/ • http://projects.latimes.com/mapping-la/ neiborhoods/ • http://marinemap.org/ • http://earth.burningman.com/ • http://about.nsw.gov.au/ • and others ... Friday, August 26, 2011
  • 19. GEOS • Geometry Engine Open Source In [3] from django.contrib.gis.geos import * In [4]: point = GEOSGeometry('Point(0 10)') In [5]: point.coords Out[5]: (0.0, 10.0) Friday, August 26, 2011
  • 20. In [7]: coords = ((0, 0), (0, 10), (10, 13), (0, 0)) In [8]: polygon = Polygon(coords) In [9]: mpolygon = MultiPolygon(polygon) Friday, August 26, 2011
  • 21. In [33]: polygon.wkt Out[33]: 'POLYGON ((0.0000000000000000 0.0000000000000000, 0.0000000000000000 10.0000000000000000, 10.0000000000000000 13.0000000000000000, 0.0000000000000000 0.0000000000000000))' In [34]: polygon.contains(Point(11, 12)) Out[34]: False In [35]: polygon.json Out[35]: '{ "type": "Polygon", "coordinates": [ [ [ 0.000000, 0.000000 ], [ 0.000000, 10.000000 ], [ 10.000000, 13.000000 ], [ 0.000000, 0.000000 ] ] ] }' In [36]: polygon.kml Out[36]: '<Polygon><outerBoundaryIs><LinearRing> <coordinates>0.0,0.0,0 0.0,10.0,0 10.0,13.0,0 0.0,0.0,0</coordinates> </LinearRing></outerBoundaryIs></Polygon>' Friday, August 26, 2011
  • 22. GDAL Geospatial Data Abstraction Library In [2]: from django.contrib.gis.gdal import * ... In [28]: k = DataSource('data/ukraine_administrative.shp') In [29]: layer = k[0] In [30]: layer Out[30]: <django.contrib.gis.gdal.layer.Layer object at 0x10325f990> In [31]: len(layer) Out[31]: 9976 In [32]: layer.fields Out[32]: ['NAME', 'ADMIN_LEVE'] Friday, August 26, 2011
  • 23. You can transform coordinates from one projection to another In [37]: s = SpatialReference(4326) In [39]: k = GEOSGeometry('Point(10 10)', s) In [40]: k.transform(900913) Friday, August 26, 2011
  • 24. GeoIP IP-based Geolocation binding to MaxMind In [1]: from django.contrib.gis.utils import GeoIP In [2]: g = GeoIP() In [6]: g.country('it-jam.ciklum.net') Out[6]: {'country_name': 'Ukraine', 'country_code': 'UA'} In [7]: g.city('it-jam.ciklum.net') Out[7]: {'city': None, 'region': None, 'area_code': 0, 'longitude': 32.0, 'country_code3': 'UKR', 'latitude': 49.0, 'postal_code': None, 'dma_code': 0, 'country_code': 'UA', 'country_name': 'Ukraine'} In [8]: g.geos('it-jam.ciklum.net') Out[8]: <Point object at 0x103482fd0> In [9]: g.geos('it-jam.ciklum.net').coords Out[9]: (32.0, 49.0) Friday, August 26, 2011
  • 25. Geometry Fields • GeometryField • PointField • LineStringField • PolygonField • MultiPointField • MultiLineStringField • MultiPolygonField • GeometryCollectionField Friday, August 26, 2011
  • 26. Models example from django.contrib.gis.db import models class Checkin(models.Model): type = models.CharField(max_length=1, choices=CHECKIN_TYPE) title = models.CharField(max_length=255, blank=True, null=True) geodata = models.PointField() updated = models.DateTimeField(auto_now=True) objects = models.GeoManager() Friday, August 26, 2011
  • 28. Geometry Field Options • srid (Spatial Reference System Identity, corresponding to spatial_ref_sys db table, default is 4326) • spatial_index (Spatial indexes are created by default) • dim (Set dimension if backend supports this, default is 2, postgis only) • geography Friday, August 26, 2011
  • 30. Lookup types PostGIS is a rock star :) As parameters lookups can be any data that can be converted into GEOS geometry like GeoJSON, WKT etc. https://docs.djangoproject.com/en/dev/ref/contrib/gis/db-api/#spatial-lookup-compatibility Friday, August 26, 2011
  • 31. Example In[8]: pnt = Point(40.187953, 49.9658546) In[9]: Administrative.objects.get (geodata__contains=pnt) Out[10]: <Administrative: 9976> Friday, August 26, 2011
  • 32. Measurement objects Conversation between measurement units Friday, August 26, 2011
  • 33. Distance, D In [1]: from django.contrib.gis.measure import D In [2]: dist = D(km=500) In [3]: dist.mi Out[3]: 310.68559611866698 In [4]: dist.rod Out[4]: 99419.390757973422 Friday, August 26, 2011
  • 34. Area, A In [1]: from django.contrib.gis.measure import A In [2]: a = A(sq_m = 10) In [3]: a.sq_km Out[3]: 1.0000000000000001e-05 In [4]: a.sq_rod Out[4]: 0.39536861034746451 Friday, August 26, 2011
  • 35. Distance queries* In [10]: Checkin.objects.filter(geodata__distance_gte=(pnt, 7000)) Out[10]: [<Checkin: Ресторан «Домашня Кухня»>, <Checkin: Великий Вiз>, <Checkin: Ресторан «Домашня Кухня»>, <Checkin: Станція швидкісного трамвая "Польова">, <Checkin: НТУУ "КПИ", корпус 7>] Friday, August 26, 2011
  • 36. GeoQuerySet Methods MySQL does not support any of these more ... Friday, August 26, 2011
  • 37. Aggregate Methods • collect • extend • extend3d • make_line • unionagg Friday, August 26, 2011
  • 38. Output methods Done more on db level • kml() • gml() • svg() • geojson() • geohash() Friday, August 26, 2011
  • 39. Measurement methods • area()(attachs the area to each geometry field in the queryset as Area object ) • distance(geom) • length() • perimeter() Friday, August 26, 2011
  • 40. Geometry operations • difference(geom) • intersection(geom) • union(geom) • sym_difference(geom) Friday, August 26, 2011
  • 41. Geometry methods • centroid() • envelope() • point_on_surface() • scale(x, y, z=0) • translate(x, y, z=0) • transform(srid) Friday, August 26, 2011
  • 42. In [10]: k = Administrative.objects.kml().svg().perimeter ().point_on_surface().get(id=10) In [11]: k.point_on_surface.coords Out[11]: (22.153155999999999, 48.512821000000002) In [12]: k.kml Out[12]: u'<LineString><coordinates>22.166018,48.5771299 Friday, August 26, 2011
  • 44. Related projects • FeatureServer http://featureserver.org • TileCache http://tilecache.org • TileStache http://tilestache.org/ • Mapproxy http://mapproxy.org/ Friday, August 26, 2011
  • 45. Cartography • Mapnik http://mapnik.org • MapServer http://mapserver.org Friday, August 26, 2011
  • 46. Frontend interaction • OpenLayers http://openlayer.org • Google maps js api • Polymaps http://polymaps.org/ • Wax http://mapbox.github.com/wax/ manual/ • TileMill http://tilemill.com/pages/index.html Friday, August 26, 2011
  • 47. Many thanks Vasyl Dizhak http://twitter.com/rootart http://twitter.com/djangostars http://geojam.djangostars.com http://github.com/rootart/geojam Questions? Friday, August 26, 2011