 You can add GEO to your Django. And first off, I want to apologize if my slides are slightly askew. I originally created my PowerPoint on an Ubuntu. I transferred it to a PC and I don't have a computer, so I'm using Anna's MacBook. So it's Touch 3 OSs. You can follow along on the PDF version. You just have to go to bit.ly slash GEO Django 15. So I'll give you a little information about myself. I will introduce you guys to what GIS may be if you're not familiar with it, how GIS and Python interact with each other, and then what GEO Django is all about and what you can do with it. So my overall objective is to introduce you guys to what GEO Django is, and hopefully you guys can make your own project with it. So a little bit about myself. I attended the University of North Georgia from 2011 to 2014. I was originally a computer science major. I took two classes, intro to Jython and Java. I wasn't really feeling it. I went to a GIS day and they told me how you can make maps, analyze maps, and even use information technology to do more with your maps. So I changed my major to environmental and spatial analysis where I did my toes in remote sensing, GIS, environmental studies, Python, Django. Right now I currently live in Flagstaff, Arizona, pursuing my masters in geography. I'm not really doing anything with Django, but I do plan on maybe making a project using Django, and I definitely want to spend more time, free time using Django. So I keep saying this. What is GIS? Well, GIS stands for Geographical Information Systems. Some people may tell you it stands for science. Some people may say it stands for Geographic Information Studies. Pretty much what a GIS is. It's a program that allows you to create, manipulate, analyze your geographic data. So pretty much if you have a point on Earth, you can represent that point on a GIS. So just some applications of GIS, Starbucks may be the best or the worst at GIS. Every time I want to go to Starbucks, I cannot find one. But if there is a Starbucks, I guarantee you there are three and a half mile radius. Zip codes when you go to the department store, you can create a map of trails or bikes or urban trail systems in your city. If anyone uses Waze on their smartphone, that uses GIS. So pretty much if you have spatial data, you can display it on a map and people love visuals. Here's one example, just urban development over a five-year span in Gainesville, Georgia. A simple tracking map to track textbooks, or you can make a map of your campus. So why GIS in Python? Well, there's this one popular program called ArcMap, that's by Esri, that a lot of people in the GIS field use. Python is installed in ArcMap, and you can go into the Python in ArcMap and write, you can use it to automate your tools. So you can write a script here that runs like five tools, and you can have all of your stuff that you want to do on a project done really fast. Instead of manually clicking, going through each tool on each shape file or whatnot, they use ArcPy library to do that. So what about GIS and Django? Well together, they can make GeoJango. So first, before you start your GeoJango project, you need to have a spatial database. I highly recommend using Postgres, because you can create the extension post-GIS to get all the spatial reference stuff you need to help store your GIS data. So when you create your project, you want to go into your settings folder. And under your installed app, you want to make sure that you have Django.contrib.GIS. That's pretty much the only difference. So now you want to have your GeoJango project, right? Well, you need spatial data to have a GeoJango project. I highly recommend going to the GeoJango tutorial. They have the world border shape file there for your convenience. If you don't like world borders for some reason, you can go off in the fancy internet and find other shape files. For you non-GIS people, shape files normally are zipped and contain seven other files. Sometimes they have four, but it's four to seven files. I can't tell you what they all stand for, but .prj means projection. The DBF is the database. And you just want to have everything zipped. You can't just pull out the .shp or it won't work. If you have your own GIS on your computer, like ArcMap or QGIS or Grass, you can create your own shape file there. GIS people. So your models should pretty much duplicate what's in your shape file. The shape file is pretty much a model. You have all your different fields like the, I have an example here, like the name of the school, how many students, field for your longitude, field for your latitude. You want your model to pretty much be what's in your shape file. The image on the left is from the GeoJango tutorial. The image on the right is my Georgia example here. So as you can notice on the top of the world border example, it has jango.contrib.gis.db. So you want to make sure you have that .gis. So the GeoJango tutorial is really great. But I think if you're new to GeoJango, it can be very intimidating. It goes through a lot of spatial queries that you can run. And it's kind of fatty. So what I'm going to go over is I'm cutting the fat for you guys. So now that you have your spatial database and you have spatial data in a shape file form, you can now load your spatial data. So this is what I did, and I'm pretty sure the GeoJango tutorial does the same way. I made a data folder in my app and I just pasted everything that was in my zip file. So you can see all seven files are in there. And then this low.py is directly off the GeoJango tutorial. I just changed the ga mapping fields to match my model and shape file. And just changed some of the names like ga shapes, set of worlds underscore border, underscore shape, underscore string of numbers. So then you want to open up your Python shell and import the load and then run the load.py. And as you can see, it saved, I believe there's ten schools that was in my Georgia shape file. So now let's go into our Django admin and you can see that the schools has successfully loaded into my Django project. You want to also go into your admin and make sure that it's geo friendly by adding the.gis to your Django.contrm. And then with your admin.site.register I have this admin.geomodel admin. So this is a very fancy thing that will add a map to your admin. And then you want to do the same thing with your main URLs.py, not your app project, just make sure that it has the.gis, of course. So let's say that I forgot to add a school and instead of going into my gis, my computer, creating that second or my last school, reloading it, I can go straight into the admin and go to add Georgia, kind of like what you can do with the normal Django project. But this time we have this fancy map in our admin. So I have the name of the school, I use test state college university, there's one student. And then I placed a point in the middle of Lake Lanier because there's no school there. This is kind of tricky the way that it's set up. So you have to put a latitude and longitude number a string in your admin or else it'll be like, can't do it, gotta fill me in. So you put the point on the map, you hit, you have to put mumble jumble in the Latin long, hit save. And it will override the strings that you put up there with the correct coordinates of the point that you put on the map. Now, you can also do this the other way. You can rig it where you can copy and paste your real Latin long and place a point in the ocean, save it, reload it, and then it'll go to the point that you've had set your Latin long to. But those are, I think, two or three other strings you gotta put in the admin. But for the, keeping it simple, we're just gonna do it this way. So as I mentioned, the point on the map overrides the Latin long. It automatically finds that point on the earth and geocodes that location. Same thing, if you had a polygon, you can just draw your polygon. And it'll find the geometry for that shape file, or that file. So I guess you can do this without having a shape file to begin with. You can just create a model and keep adding and adding and adding. But you really should have a shape file to begin with if you wanted to share that with GIS folk or if you wanted to bring your shape file into ArcMap or QGIS to do further analysts on it. So I highly suggest having a shape file first. But if for some reason you forgot to add something, you can always add it in. So you wanna display your spatial data, right? I highly suggest you create an API so you can call your API's spatial data to your project. So I'm not gonna get into really big details. It's simply setting up a normal API that you do with regular data. You just wanna make sure that you have rest underscore framework underscore GIS. And then import serializers as geocerializers. And you'll have this geofield that's equal to Mpoly. And then the fields that you want shown on your API, such as name and number of students. Same thing, it uses JSON data, but it's called GeoJSON data. And same thing, you just wanna have it GIS. Actually, the way I'm looking at it, it looks like a regular JSON setup. So I don't even think you need to add GIS anywhere. And then you just wanna make sure you have it on your API URLs. And then voila, I pulled up my API. And you can see that under the geometry, it has the point coordinates. And it has my latitude and longitude of the schools that are called for my spatial data. And then here's that test point that I made. You can see that it's not 1, 2, 3, 4, 5, 6, 7, 8. It's actually negative 83 and 34. So once you create an API, you can use third party websites. So there's Mapbox to display your data onto your website. Mapbox is free to use. There is a paying option. You can limit the size of your map and put constraints. So if you want your user to only look at a certain area, they can't scroll all the way to France or something. Like I said, it's free and you just create the project. You pretty much zoom into an area of interest. So if you're interested in Cuba, you just zoom into Cuba and it saves it there for you. So when you open up your Django project, it's saved on that one map tile. So once you save your project in Mapbox, you just need to get the map ID that's underneath the project tab. So that's really the only thing you need. So now it's time to use the Mapbox API. You just need to open up your template page that you're going to be using to display your spatial data. And you just need these two lines right here. One's the Mapbox JavaScript and one's the Mapbox CSS. And I'm pretty sure the line of code is on the Mapbox website. And then, of course, you just want to have your map CSS there. And then more map CSS. I'm going to point out that the variable, our icon, is going to be the icon that displays my spatial data on my map, such as the school points. So you can just mess around with that. And then underneath your CSS for your icon, this is where you want to put in your Mapbox.map with your username dot ID of that Mapbox tile. Underneath that, this is where we get into the API that we created. So it's the JSON. And then we have our API name, which was mine was saved as the API colon Georgia. And you want the GeoJSON pointing to your Georgia API. So it knows what data to look for and display on the map. If you're really into JavaScript, I highly recommend looking at leaflet. A lot of companies use leaflet to display their spatial data with their fancy movements or icons. You click on the point and it shows you, my example would be the name of the school of the students. You can have that hyperlinked to another profile. So if you're really into JavaScript, I highly recommend looking at leaflet. So this is the finished project. This is what happens after I've loaded the data. I added a point on the map because I forgot something. I created my API. And then I went on Mapbox and created a map tile and then put that into my template. You can now see that there are schools on my Georgia Mapbox tile. And if you look close enough, there is the imaginary school that's on an island in Lake Lanier. And what I was mentioning before with the JavaScript, you can tell that when you point or click on the point on the map, it has the name of the school and it found its students. So let's get fancy. You want to create something interactive, right? So last semester in my webmaster class, I teamed up with Crystal Lilliston and Wilcox. And we kind of messed around and created an interactive campus map for the University of North Georgia Gainesville campus. Feel free to go to this website. It's a warning you. It's still in the works. We only worked on it for one semester. It's ungmap.com. So if you're going to the website, I recommend going to the Gainesville campus. When you go to the Gainesville campus, it will display you our Mapbox tile of the Gainesville campus school. We have a restriction on it. Like I mentioned earlier, you can't go no more than two miles northwest, east and south. Just looking at this, I don't know how well you guys can see it. But the parking lots are grayed out. The buildings have red shape file. And then the emergency call boxes are blue points on the map. You can use the HTML5 geolocation to hit Find Me. And it works very well on the cell phones. We tested it out in the science building. And it had me right on the corner of the science building where I was standing on the second level. Here's some zoomed in detail of our shape file. I hand digitized all the parking lot spaces. Yeah, there are a lot of them. And you can keep zooming in. So that's just an example of some shape files you can make. So like I said, my objective of this talk was to introduce you guys to what GeoJango is, how you can use it, and hopefully we can promote some more ideas. Maps are great. I mean, people love visuals. If you have data that can be placed on a map, put it on a map. So if you have a figure out a problem and solve it with a map, like I said, maps are used everywhere. I'd like to give a special thanks to my professor, Zach Miller, from the University of North Georgia. Obviously, I couldn't be here without him. We had him for three semesters. And he does a lot with GIS and Django and GeoJango. I want to thank Brandon Neumizer for setting up the Linux machine for me to make this PowerPoint presentation. Crystal and Will for teaming up with me to make our interactive web map. And then Django and Kanye West, the Django Software Foundation, for letting me be here today. Because I literally moved across country from Atlanta to Flagstaff, Arizona, last or three weeks ago. And I wouldn't have been here without them. And of course, Anna, for letting me use her laptop for today's talk. I will now take questions. We have 10 minutes left. Neumizer, first setting up the Linux machine. I wonder if there might be some time during the conference to just kind of sit down and do a little mini install-a-thon or something like that, if there's a time that people want to just try it. Unfortunately, no. I have class on Wednesday, so I'm leaving tomorrow night. We can maybe meet up some time tomorrow. And I can go over some of the stuff that you will need to install to get your Django up and running. And I can point you to great references that I've used in the past. Do you want to pick a time and a place? Maybe more people can do it. If you follow me on Twitter, I'm sure I can pick up my busy schedule. And I'm sorry, my what? I should doodle? Oh, is it? I haven't heard of that. OK. Yeah, I was actually wondering, maybe you'll go over this if you do the install-a-thon. But I was wondering how difficult it is to integrate this into an existing Django app or just to have a Django app. Maybe that's a little bit separate, because I know this one. Or when I was looking at it, I haven't used it at all. But when I was looking at it, you have to use a specific database engine for it. So is there a way to just integrate it in without making that the default engine? You will need a special database to have this Django working. Are you using Postgres right now? Yeah. I'm not positive, but maybe you can try doing the create extension post-GIS. I'm not positive on how that's going to work on your existing project. I mean, you can try it. It may or may not work. It shouldn't affect the project. OK, so there you go. All right, yeah, like I mentioned, there's some points in the project that where you will need to add the .GIS. But it shouldn't hurt your current project. Are there any handy references or resources online to be able to find data for particular problems? OK, where we can find spatial data. All right, the GIS Clearinghouse website has some data that we can use. If you're into roads, I highly recommend Tiger. If you're into census data, you want to go to NHNHGIS, the National Historic GIS. They have all sorts of census data, I think, all the way into the 1800s. Trying to think of what other places we can get spatial data. I mean, if you just Google something and put shape file, you might be lucky. Some companies have their GIS data open to the public. If you can get data in an Excel sheet, you can put that into a CSV. You can put that into your GIS, such as ArcMap, and create a shape file there, and then put that onto your GeoJango web app. So it's a multi-step process. But if you have the data, you can definitely put it on a map. Hello. Hey. Two questions. One, that admin weirdness? I'm from a developer point of perspective. That just seems like it's screaming for a pull request. Is it just something that needs to be done, where you enter gibberish and lat long and click the map? I think it's how the shape file is set up, because you have to have the lat and long on your model for it to pull in your shape file. OK. It seems like something in the admin could be fixed. Yeah, I agree with you. And I probably need to do more research to see if there is a way we can get that taken care of. Because like I mentioned earlier, I did another project where I had switched it. I put in the coordinates, and then put a gibberish join on the map. Related, I guess, about the shape file. So you've got the loader for the shape file to put all the stuff in the GIS database. Is there any way to with GeoJango or some other extensions to write a shape file out? Because if you're adding more data into that database, can you? Yeah, I guess the way that you can pull the GeoJason information. And you can, I guess, then write a program for it to maybe using ArcPy to make a shape file using the GeoJason data with that. OK, thanks. You're welcome, thank you. Thank you.