SlideShare une entreprise Scribd logo
1  sur  37
Télécharger pour lire hors ligne
TeamupDjangoand
Webmapping
DjangoConEurope2014
MathieuLeplatre
@leplatrem
www.makina-corpus.com
Maingoals...
●
Webmappingshouldbesimple
●
GoogleMapsshouldbecomeunusual
●
Demystifycartography!
Mainfocus...
●
Fundamentalsofcartography(projections,PostGIS)
●
Webmapping(GeoJSON,Leaflet)
●
Djangotoolbox(a.k.a.GeoDjango)
Fundamentalsofcartography
Coordinates :positiononEarth
●
Longitude(x) – Latitude (y)
●
Decimaldegrees(-180 +180, -90 +90)→ →
●
GPS
Geodesy :shapeoftheEarth
Ellipsoid (GPS,WGS84)
Illustration:http://mapschool.io
Projections
●
Equations (lat/lng pixels)↔
●
Representationonaplane ( compromises)→
●
Spatialreferencetransformation
Illustration:http://mapschool.io
SpatialReferences
●
Coordinatesystem(cartesian)
●
Units(degrees,meters)
●
Mainaxis(equator,Greenwich)
●
Ellipsoid,geoid (WGS84)
●
Conical, cylindrical,conformal,...
●
…
Store  WGS84→ (GPS,srid=4326)
Display →Mercator(GoogleMaps,srid=3857)
Vectordata
●
Point(x,y,z)
●
Line(orderedlistofpoints)
●
Polygon(enveloppe+holes)
Illustration:http://mapschool.io
Rasterdata
●
~Images
●
Mapbackgrounds(satellite,plan,…)
●
Atimetrydata(DEM)
Illustration:http://mapschool.io
APostGISdatabase
●
Columntypes(Point,LineString,Polygon,…Raster...)
●
Geographicfunctions(distance,area,extents...)
●
SpatialIndexes(rectanglestrees...)
$ sudo apt-get install postgis
$ psql -d mydatabase
> CREATE EXTENSION postgis;
Examples (1/2)
CREATE TABLE island (
label VARCHAR(128),
code INTEGER,
geom geometry(Polygon, 4326)
)
Examples (1/2)
CREATE TABLE island (
label VARCHAR(128),
code INTEGER,
geom geometry(Polygon, 4326)
)
Usual table
Usual
columnsVector
geometry
column
Geometry type Spatial
Reference
Examples (2/2)
SELECT room.id
FROM room, island
WHERE ST_Intersects(room.geom,
island.geom)
Spatial join
INSERT INTO room (geom) VALUES (
'SRID=4326;POINT(3.12, 43.1)'::geometry
)
EWKT format
PostgreSQL cast
Webmapping
Webmapanatomy...
●
JavaScript+DOM
●
Initializationofa<div>
●
« Layers »
Webmapanatomy...
●
JavaScript+DOM
●
Initializationofa<div>
●
« Layers »
●
<img> (Backgrounds)
●
Vector SVG→
●
Lat/Long pixels→ (CSS)
●
DOMEvents (interactions)
Leafletexample
<script src="leaflet.js"></script>
<link rel="stylesheet" href="leaflet.css" />
<div id="simplemap"></div>
<script>
var map = L.map('simplemap')
.fitWorld();
L.tileLayer('http://tile.osm.org/{z}/{x}/{y}.png')
.addTo(map);
L.marker([43.07, -5.78])
.addTo(map);
</script>
http://leafletjs.com
Seealso...
D3
●
SVG
●
Cooldataviz
●
Exoticmapprojections
OpenLayers3
●
Canvas
●
GIS-oriented(advanceduse-cases)
Formats(1/2)
●
Rasterimages(PNGouJPG)
●
z/x/y.png
●
Projection3857(Mercator,GoogleMaps)
→Colddata
(tileprovider)
…→ orwarm
(renderingengine)
Formats(2/2)
●
GeoJSONforvectordata
●
Projection4326(GPS,WGS84)
●
Interactive ?
●
Volume ?
●
Frequency ?
→Dynamic
(fromdatabase)
SELECT
ST_AsGeoJSON(geom)
FROM ...
Nothingnew...
WebServer Browser
PostGIS Django
Rendering
Engine
Vector
overlay
Raster
overlay
Raster
background
Images
z/x/y.png
GeoJSON
z/x/y.png, UTFGrid, ...
GeoDjango
DjangoEcosystemforCartography
fromdjango.contrib.gisimport...
●
Modelsfields(syncdb)
●
GeoQuerySet(spatialqueries)
●
Formfields(Django1.6)
●
Systemlibrariesdeps(GEOS,GDAL)
●
Widgets&AdminSite(OpenLayers2)
Examples(1/2)
from django.contrib.gis.db import (
models as gismodels
)
class Island(gismodels.Model):
label = models.CharField(max_length=128),
code = models.IntegerField(),
geom = gismodels.PolygonField(srid=4326)
objects = gismodels.GeoManager()
Examples(2/2)
from django.contrib.gis.geos import Polygon
embiez = Island(label='Embiez',
geom=Polygon(((0.34, 0.44),
(0.36, 0.42), …)))
~
from django.contrib.gis.geos import fromstr
myroom = fromstr('SRID=4326;POINT(3.12, 43.1)')
Island.objects.filter(geom__intersects=myroom)
●
Views (Class-based)
●
Generalization&approximation (lessdetailsanddecimals)
●
Serialization (dumpdata, loaddata)
●
Modelfields(text,noGIS!)
●
Vectortiles(hugedatasets)
django-geojson
from djgeojson.views import GeoJSONLayerView
urlpatterns = patterns('',
url(r'^buildings.geojson$',
GeoJSONLayerView.as_view(model=Building))
)
django-leaflet
●
Quick-startkit {% leafletmap "djangocon" %}
●
Assets(collecstatic)
●
Easypluginsintegration
●
Globalconfiguration (settings.py,plugins,...)
●
Leafletprojectionsmachinery (reprojection)
django-leaflet(view)
{% load leaflet_tags %}
...
{% leaflet_js %}
{% leaflet_css %}
</head>
<body>
{% leafletmap "buildingmaps" callback="initMap" %}
<script type="text/javascript">
function initMap(map) {
// Ajax Load
$.getJSON("{% url app:layer %}", function (data) {
// Add GeoJSON to the map
L.geoJSON(data).addTo(map);
});
}
GeoJSON
view
LAYER
django-leaflet(edit)
Forms
●
Fields(Django1.6+API)
●
Widgets (hidden<textarea>+Leaflet.draw)
class BuildingForm(forms.ModelForm):
class Meta:
model = Building
widgets = {'geom': LeafletWidget()}
fields = ('code', 'geom')
●
LeafletAdminSite
admin.site.register(Building, LeafletGeoAdmin)
SCREENSHOTFORM
Conclusion
AnyonecandoWebmapping...
Cartographyissimple.
●
Justsomespecialdatatypes
●
FollowsDjangoconventions
●
Fewlinesofcode
Illustration:ChefGusteau,PixarInc.
…withappropriatetoolsandstrategies!
Cartographyishard.
●
Performance(Web)
●
Volume(precision)
●
Datarefreshrate(caching)
●
Userstoriestoofarfromdata (modeling)
Illustration:AntonEgo,PixarInc.
MakinaCorpus -FreeSoftware|Cartography|Mobile
Questions ?
...andanswers !
PostGIS -Leaflet–JavaScript
http://makina-corpus.com

Contenu connexe

Similaire à Team up Django and Web mapping - DjangoCon Europe 2014

Ioannis Doxaras on GIS and Gmaps at 1st GTUG meetup Greece
Ioannis Doxaras on GIS and Gmaps at 1st GTUG meetup Greece Ioannis Doxaras on GIS and Gmaps at 1st GTUG meetup Greece
Ioannis Doxaras on GIS and Gmaps at 1st GTUG meetup Greece
CoLab Athens
 

Similaire à Team up Django and Web mapping - DjangoCon Europe 2014 (7)

Geolocation and Mapping
Geolocation and MappingGeolocation and Mapping
Geolocation and Mapping
 
Geo search introduction
Geo search introductionGeo search introduction
Geo search introduction
 
PyDX Presentation about Python, GeoData and Maps
PyDX Presentation about Python, GeoData and MapsPyDX Presentation about Python, GeoData and Maps
PyDX Presentation about Python, GeoData and Maps
 
HTML5勉強会#23_GeoHex
HTML5勉強会#23_GeoHexHTML5勉強会#23_GeoHex
HTML5勉強会#23_GeoHex
 
GeoDjango & HTML5 Geolocation
GeoDjango & HTML5 GeolocationGeoDjango & HTML5 Geolocation
GeoDjango & HTML5 Geolocation
 
Ioannis Doxaras on GIS and Gmaps at 1st GTUG meetup Greece
Ioannis Doxaras on GIS and Gmaps at 1st GTUG meetup Greece Ioannis Doxaras on GIS and Gmaps at 1st GTUG meetup Greece
Ioannis Doxaras on GIS and Gmaps at 1st GTUG meetup Greece
 
Large Scale Geo Processing on Hadoop
Large Scale Geo Processing on HadoopLarge Scale Geo Processing on Hadoop
Large Scale Geo Processing on Hadoop
 

Plus de Makina Corpus

Créez votre propre fond de plan à partir de données OSM en utilisant TileMill
Créez votre propre fond de plan à partir de données OSM en utilisant TileMillCréez votre propre fond de plan à partir de données OSM en utilisant TileMill
Créez votre propre fond de plan à partir de données OSM en utilisant TileMill
Makina Corpus
 

Plus de Makina Corpus (19)

Happy hacking with Plone
Happy hacking with PloneHappy hacking with Plone
Happy hacking with Plone
 
Développer des applications mobiles avec phonegap
Développer des applications mobiles avec phonegapDévelopper des applications mobiles avec phonegap
Développer des applications mobiles avec phonegap
 
Running a Plone product on Substance D
Running a Plone product on Substance DRunning a Plone product on Substance D
Running a Plone product on Substance D
 
Why CMS will not die
Why CMS will not dieWhy CMS will not die
Why CMS will not die
 
Publier vos données sur le Web - Forum TIC de l'ATEN 2014
Publier vos données sur le Web -  Forum TIC de l'ATEN 2014Publier vos données sur le Web -  Forum TIC de l'ATEN 2014
Publier vos données sur le Web - Forum TIC de l'ATEN 2014
 
Créez votre propre fond de plan à partir de données OSM en utilisant TileMill
Créez votre propre fond de plan à partir de données OSM en utilisant TileMillCréez votre propre fond de plan à partir de données OSM en utilisant TileMill
Créez votre propre fond de plan à partir de données OSM en utilisant TileMill
 
Petit déjeuner "Les bases de la cartographie sur le Web"
Petit déjeuner "Les bases de la cartographie sur le Web"Petit déjeuner "Les bases de la cartographie sur le Web"
Petit déjeuner "Les bases de la cartographie sur le Web"
 
Petit déjeuner "Développer sur le cloud, ou comment tout construire à partir ...
Petit déjeuner "Développer sur le cloud, ou comment tout construire à partir ...Petit déjeuner "Développer sur le cloud, ou comment tout construire à partir ...
Petit déjeuner "Développer sur le cloud, ou comment tout construire à partir ...
 
CoDe, le programme de développement d'applications mobiles de Makina Corpus
CoDe, le programme de développement d'applications mobiles de Makina Corpus CoDe, le programme de développement d'applications mobiles de Makina Corpus
CoDe, le programme de développement d'applications mobiles de Makina Corpus
 
Petit déjeuner "Alternatives libres à GoogleMaps" du 11 février 2014 - Nantes...
Petit déjeuner "Alternatives libres à GoogleMaps" du 11 février 2014 - Nantes...Petit déjeuner "Alternatives libres à GoogleMaps" du 11 février 2014 - Nantes...
Petit déjeuner "Alternatives libres à GoogleMaps" du 11 février 2014 - Nantes...
 
Petit déjeuner "Les nouveautés de la cartographie en ligne" du 12 décembre
Petit déjeuner "Les nouveautés de la cartographie en ligne" du 12 décembrePetit déjeuner "Les nouveautés de la cartographie en ligne" du 12 décembre
Petit déjeuner "Les nouveautés de la cartographie en ligne" du 12 décembre
 
Alternatives libres à Google Maps
Alternatives libres à Google MapsAlternatives libres à Google Maps
Alternatives libres à Google Maps
 
Atelier "Les nouveautés de la cartographie en ligne"
Atelier "Les nouveautés de la cartographie en ligne"Atelier "Les nouveautés de la cartographie en ligne"
Atelier "Les nouveautés de la cartographie en ligne"
 
Importing Wikipedia in Plone
Importing Wikipedia in PloneImporting Wikipedia in Plone
Importing Wikipedia in Plone
 
Petit Déjeuner : HTML5 et CSS3, les interfaces de demain.
Petit Déjeuner : HTML5 et CSS3, les interfaces de demain.Petit Déjeuner : HTML5 et CSS3, les interfaces de demain.
Petit Déjeuner : HTML5 et CSS3, les interfaces de demain.
 
Geotrek
GeotrekGeotrek
Geotrek
 
Plomino
Plomino Plomino
Plomino
 
Des cartes d'un autre monde - DjangoCong 2012
Des cartes d'un autre monde - DjangoCong 2012Des cartes d'un autre monde - DjangoCong 2012
Des cartes d'un autre monde - DjangoCong 2012
 
Solutions libres alternatives à Google Maps
Solutions libres alternatives à Google MapsSolutions libres alternatives à Google Maps
Solutions libres alternatives à Google Maps
 

Dernier

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Dernier (20)

Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 

Team up Django and Web mapping - DjangoCon Europe 2014