Creating GIS Rest APIS using Geodjango under 30 minutes
This is a modal window.
The media could not be loaded, either because the server or network failed or because the format is not supported.
Formal Metadata
Title |
| |
Title of Series | ||
Number of Parts | 156 | |
Author | ||
License | CC Attribution 3.0 Unported: You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal purpose as long as the work is attributed to the author in the manner specified by the author or licensor. | |
Identifiers | 10.5446/68448 (DOI) | |
Publisher | ||
Release Date | ||
Language |
Content Metadata
Subject Area | ||
Genre | ||
Abstract |
| |
Keywords |
FOSS4G Europe 2024 Tartu30 / 156
6
33
35
53
55
59
61
67
70
87
97
99
102
103
104
105
107
111
121
122
123
124
125
126
127
128
134
144
150
151
155
00:00
Process (computing)Streaming mediaOrder (biology)Maxima and minima
00:10
Representational state transferSoftware frameworkInformation securityScale (map)Field extensionBuildingTable (information)Content (media)Library (computing)Logic gateData modelTemplate (C++)Representational state transferComputer fileMobile appDatabaseSet (mathematics)Software frameworkProjective planeSoftware architectureLine (geometry)Point (geometry)Endliche ModelltheoriePolygonSystem administratorDebuggerInstallation artDialectComplete metric spaceLogicCartesian coordinate systemOrder (biology)CASE <Informatik>Extension (kinesiology)GeometryField (computer science)Generic programmingComputer animation
01:57
File formatComputer animation
02:04
BuildingInformation securitySoftware frameworkComa BerenicesLimit (category theory)Representational state transferSoftware frameworkEndliche ModelltheorieMobile appFile formatCASE <Informatik>Serial portView (database)Computer animationLecture/Conference
02:29
Computer iconRootView (database)AxiomOpticsDisk read-and-write headLocal ringRepresentational state transferSoftware frameworkCountingElectronic mailing listRepresentational state transferComputer animation
02:42
Field extensionSoftware frameworkSoftware frameworkRepresentational state transferComputer animation
02:49
Electronic mailing listDisk read-and-write headOpticsData typeGeometryFile formatComputer animation
02:58
Game theoryGeometryRepresentational state transferSoftware frameworkMobile appFile formatField (computer science)GeometryComputer animation
03:09
Electronic mailing listContent (media)Point (geometry)File formatMultiplication signComputer animationLecture/Conference
03:17
Price indexLogic gateInstallation artPolygonSoftware frameworkGeometryCuboidMultiplicationPoint (geometry)Buffer solutionDefault (computer science)Functional (mathematics)Representational state transfer
03:50
Default (computer science)File formatCuboidComputer animation
03:57
Level (video gaming)Default (computer science)CuboidComputer animation
04:04
Least squaresComputer-assisted translationComputer animation
Transcript: English(auto-generated)
00:00
So, this is originally a 30-minute stop, but we'll try to wrap it up under five minutes. So the aim over here is that what is the minimum setup that we need in order to create special REST APIs based on the data that we have. And the flavor of Python that we are going to use over here or the framework would be Django.
00:20
So, we are going to see what is Django, what is your Django, then Django REST framework, and finally we'll end by Django REST framework GIS. So, Django, it's quite a famous framework if you want to create the complete application, and it's very easy to get started. You just start the project and just like, so in Django, essentially you build each
00:44
of your business logic as an individual app. You can also connect your database. In this case, I have connected a PostGIS since I want to do geospatial stuff with it. And then that's all. Once you run the Django, you will get a nice UI and also you'll get an admin panel that
01:03
you can do a lot of things with. Next thing that we are adding to our stack is GeoDjango, which is an extension of Django which understands GIS. So it is built with GDAL, PostGIS, Proj, Geospatialite, and OSGO 4W. So the way we start using it is by simply mentioning that we want to use Django in
01:24
install apps in the settings.py file. And if you're on M architecture, you might have to add some more settings to it as well. And then that's all. Then you can start creating your models and you can specify what kind of geometry you want to store. It can be point, line, polygon, or it can be a generic geometry field as well.
01:46
And then you can just get your data in the front end and you can use things such as like city.geometry.x and ny to get lat and long. And if you want to get a WKT, you can also get a WKT back. And there you go. So by adding GeoDjango, we can actually store the data in GIS format and also use
02:03
the data from GIS format. Next thing we are looking at is a Django REST framework, which allows us to actually get the data from our model in a serialized format. So straightforward, you just do installation, again, visit back installed apps and add REST framework over there.
02:20
Then once you create a serializer, in our case for cities and then just mention it in the views, you have a running and working REST API for you, which will allow you to get the complete data or get a specific city by sending ID.
02:40
And you can also do things such as post, put, delete. And last, I would like to wind up with introducing Django REST framework. So the very important thing that it will bring to us is that over here, as you can see that the geometry is in a WKT format, but if we use, and also for me to post the data, I have to send it as a WKT. But by adding Django REST framework GIS into installed apps and just mentioning that what
03:06
is the field that is going to be geometry, I can get the data back in a GeoJSON format. There are multiple filters that we get in it. I'm not really sure if we have time. So we do get multiple filters by default with Django REST framework, such as we can
03:23
actually filter our data by passing bounding box or we can also create the geometry on the fly. So let's say if you don't have a special data but you have lat and long as a separate column, you can actually create the geometry on the fly. You can also use various functions available.
03:41
So for example over here, I had a geometry as a point but I wanted to show it as a buffer as a polygon. And yeah, you can do that. And there you go. So you can actually see the data in a GeoJSON format and then you can also filter the data. So as I said, you can do it with bounding box filter where you can just send the bounding box.
04:00
You can also do TMS style filter where you can actually send the Z, X and Y and then that's all. Thank you.