Interactive Mapmaking with Python
Veeraraghavan, Sangarshanan
GeoDataframes are awesome for working with GIS data in Python as it provides the goodness of pandas for geographic data but So let's use them to create some cool interactive maps This talk introduces Geopatra, an open-source mapping library that can be used to quickly map geodataframes with libraries like folium, kepler.gl, plotly, etc. Currently interactive mapping with geodataframes is not very straighforward for beginners and requires you to understand the interfaces exposed by different mapping libraries. geopatra attempts to abstract all the complexities and tries to provide a unified framework for mapping geodataframes 1. Introduction (2 mins) * Who am I? * Setting the expectations 2. Working with Geodataframes (5 mins) * Reading Spatial data as a GeoDataframe * The awesomeness of GeoDataframes (An overview of some of the amazing things you can do with a single line of code eg: Spatial joins, Manipulations, and transformations) * Now that we have established our love for geopandas lets map geodataframes 3. Let the Mapmaking begin (10 mins) * Basic Non Interactive maps with Geopandas and Matplotlib * Creating basic interactive maps with Folium, Plotly & Kepler (GeoJSONPlots, Clustermaps, Heatmaps, H3gridmaps) * The number of steps vs the number of necessary steps 4. Enter Geopatra (10 mins) * The need for Geopatra (Could it be any Easier and Faster) * Wrapping up popular mapmaking libraries for GeoDataframes * Create interactive maps with just a single line * Future work and Discussion :)
 So for our next talk, we have someone special joining us. So this person who I'm going to introduce is like one of the funniest people I know. And you know, I sometimes secretly wish I was him. So let's welcome that person now. Okay. Hello everyone. It's my talk right now. Thank you for that humbling introduction. My name is Sangarshan. I work at Grofus and it's pronounced grofus. So I like building imaginary projects in my head, talking about those imaginary projects in my head. And you know, I also love all those imaginary projects. So I'm going to be talking about one such case where that imaginary project actually got executed and which was amazing. So that is the story of this is the story of how I did that. So I'm going to begin by proclaiming my love for pandas. You know, whenever we want to work out whenever almost all of us want to work with data. We know we move to pandas and rightly so pandas is amazing. It's like the top hanks of Python libraries. And of course, it rests on top of all these amazing, you know, packages, which are present in the open source environment. These include, you know, matplotlib. We have NumPy, we have pandas, and then we have scikit-learn, you know, all these amazing open source packages from the scientific Python community makes Python the code to language when anyone wants to do anything with data. So we're going to talk about a special type of data, which is location data. Location data has location component linked with it. For example, I'm reading a CSV file over here, which has latitude and longitude. So this is essentially a location component. So a data with a location component can be represented as a geometry. And there are, so geometries are basically just X and Y coordinates and the various ways you can arrange them. So these geometries can be a pair of lat longs or they can be a list of lat longs, just a polygon. And also I'm grossly over simplifying what geometries are and Euclid would be really angry with me right now. But we also have line strings, which are like line strings, and we have multi polygons, which is a fancy plural word for polygons. And we also have circles. Now, to work with these geometries, we have this amazing package in the open source community called GeoPandas. So with GeoPandas, we can work with data frame. And in this case, a GeoDataFrame, and we can stay with a familiar interface. And GeoPandas will let us read and write commonly used geospatial formats like KML files, shape files and geotransmit files using the other library called FIANA. And then we also can perform different spatial operations like merge, overlay and joints with the help of another amazing package called Shapy. And also of course, the crux of the talk, we can plot them on a map with Matbotlet. And also I'm leaving a whole lot of things which we can do with GeoPandas like handling projections and recently added stuff like vectorized operations with PyGeos and also indexing your data with R trees or any other data structure. And if you are interested in knowing more, this is a tutorial link which I have attached here. I will share these slides on the on the break room. And this tutorial has been made by the maintainer. So it's like pretty comprehensive and it's pretty amazing. All right, so moving on to data frame. So we have this data frame which I read before. And we have lat and ln. So now we convert it into a geodata frame. So how we do that is we import GeoPandas and also we convert this lat and ln column into a point. A point is a geometry. So we set geometry equals combination of these two columns. So it creates a column called geometry and it creates a point geometry object using shape. So this is that point. And also on the second line, we are setting something called CRS. So CRS is the coordinate reference system. So this is how we project our earth in a way that we can understand and interpret. So in these cases, so in this case, we have used EPSC for 326, which is like the most commonly used coordinate reference system, which is also used by GPS systems and all the navigation systems. So this is the reason why latitudes and longitudes have spatial meaning in them. If not, if you don't have coordinate reference system, they are just arbitrary x and y coordinates. They are not latitudes and longitudes. So how do I plot up? So with Geopandas, everything becomes really simple. It's just a dot plot. So you just do import map plotlet and then you just, you know, to the frame dot plot, and then you have this map. But this does not look like a map, right? It's, it's missing something. So to do interactive maps with Geopandas, we actually have to move away from Geopandas and into other amazing open source libraries, which are there for creating interactive maps. So how do we do that? Do that we employ the most powerful weapon a developer has, which is Googling. So that's what I did. Google for a while. And, you know, I actually got to know that fully and we've actually one such package that actually lets me do this. So I take in the geodata frame, and then I import fully. And then now I create an a fully and dot map. So this fully dot map is just an empty canvas, kind of like a canvas where you can draw on top of. So this just creates a dummy map for me where I pass in the location, the zoom start the tiles and also we have various other parameters you can pass to the map. So after creating that dummy canvas. Now we want to plot our data on top of this canvas. So to do that, we create a feature called points. So these points feature is made up of a geodata frame, which we created before. And also we had a parameter called tooltip tooltip is also a feature in which the field is named. So when I hover over this map, I can actually see the name of each and every point that I just plotted. Now after creating this feature, I take the canvas and I add this feature to the canvas, a very iconic API, very simple and incredibly effective to create, you know, beautiful looking maps. Now onward to polygons. So we again read geodata frame, which is made up of polygons instead of points as you can see it's made up of multi polygons and also polygons. And these are all different, you know, countries and continents. So we create a map out of them with your pandas. We just again do just dot plot pretty easy. And we now choose the column which we want to plot on top of, for example, here I've chosen GDP. So that means this map is colored based on the GDP. And also, we pass the color map so that you know it goes from this color to that color. I have also attached a link for the color maps, you know, the different color maps for matrot which I present. And also I give legend equals true so that I actually see this. So now onward to the interactive maps to do that first, we actually create this color map to do that I'm using another package called Brankar dot color map, using which I'm actually importing this color map. And then I'm passing the number of steps I have to split it out of. So after creating the color map, I define my empty folium canvas. And also I define a style function. So this style function contains the various parameters that I'm going to be passing to my map, which I'm going to create right now. So it's made up of a fill color, which denotes the color which I have to fill in that particular polygon, and also the color of that polygon itself, and also the weight of that border, which is the polygon color, and also how much is the opacity of the color I have to fill it into. So these are the parameters. And then we again we create a geojson feature, we pass a geodata frame, we create the tooltip and this time I'm passing the name and also the GDP. So when I hover over it, I see both of them. Amazing. So I also pass in the style function, and then just add it to the canvas and also notice that I add the color map to the canvas. So I see this incredibly distorted legend, but I still see. So folium also has several special maps that you can actually create with it essentially. So these are called plugins that you actually create with these. So one such plugin is called market cluster. So with market cluster, you just, you know, import a market cluster from folium dot plugin. And now I think it a little weird where you're bearing you need to take a geodata frame and convert it into a list of latitudes and nonitudes. So we do that over here. Now we have a list of lat lungs. And now we create an empty canvas. And you know, we again do the, do the drill at child market cluster locations, we pass the list. And, you know, we get it is it cluster. So, so the, these two, the number two here means that this cluster is made up of two points. So the number eight means that this cluster is made up of eight points. And the cluster 76 means that this cluster is made up of 76 points. So I can click on it, it splits into several clusters again, I click on it, it splits into clusters, still I'm able to see each and every individual point, which is pretty awesome. And now heat map. So heat map is something which you know, given the current situation we actually see on a daily basis. So we know how important they are to convey the message, you know, so this is the heat map we're creating. So this does not represent anything, this is just arbitrary heat map to do this we you know take the location. And you know just create a heat map out of it with a radius of this particular map. So heat maps actually are pretty interesting because you just have to take one look at it to you know, get all the information out of it essentially. So these are pretty cool. So now more data and more problems. So one issue which I started to notice, you know, when going down the folium path is when the number of points in your map start to increase folium starts to get a little bit ineffective. Folium cannot handle a lot of points so one such also one solution, which you can deploy to make folium actually handle a lot of points is to actually, you know, create clusters like this, you know, create clusters so that you can actually plot out of points. But in some cases, the number of points you have you know, you know, it's like a lot. So your DOM will just crash like your browser crashes and we will not be able to plot all these spots. So that's where things get a little hard. But no fret not we have a new kid in town, and that's Kepler GL. So this is the textbook definition of Kepler GL. So, essentially it's this amazing project, which was developed at Uber. So they have built Kepler on top of DEC GL and webGL. So you know, they actually can render, you know, millions of points and perform spatial aggregations on the fly, which is pretty amazing. You know, and you can create, you know, amazing cool looking maps with Kepler when you want to scale out your points or scale out your data. So to install Kepler, it's when you are on a Jupyter notebook that's greater than, you know, the version 5.3, you can just do a pip install Kepler GL, it installs it, and when you are in JupyterLab, you just do, you know, JupyterLab extension, you can install the Kepler extension and you know you enable it after installing and then you are good to go. You just be able to import Kepler GL, you know, create a map out of it and you see this amazing interface. So, another amazing thing about Kepler is that it uses configs to customize the maps. So, config looks like this. It has version, it has, you know, states, filters, you know, I'm not going to go deep into the config because it is, you know, amazingly customizable. So I'm not going to go really deep into that. But I'm going to actually give you an overlay of, you know, all the things that you can control with the config. So, Kepler's UX flow is actually made up of five layers. So initially, you have your base map, right? So the base map is made up of tiles that you can acquire from various sources. For example, you have, you can acquire tiles from OpenStreetMaps, you can acquire map tiles from Google, you can acquire map tiles from Mapbox, you know, several styles, and you know, that makes up your tiles. And on top of these tiles, you, you know, overlay your data. And also, on this data, you can perform filters, aggregations, and, you know, all the lot. And, you know, to perform filters and aggregations, you can actually represent your data layer as, you know, five different types with Kepler. So we have hexagonal layers, we have arc layers, we have point layers, we have path layers, and we have grid layers. And the amazing thing about it is that these layers, like some of these layers are actually, you know, interchangeable. Like for example, you can have a point layer that you can represent as a grid. And you have, you know, H3 grids, which are actually a spatial indexing system, which is also developed courtesy of Uber, which can, you know, help you plot a lot of points without having to actually show those points on a map. Rather, index them and aggregate them as grids, so that, you know, the number of points in your map significantly decreases. And also, you have interactions you can perform on the data that has been brought on a map. And these interactions include stuff like tooltip. For example, these tooltips are the ones which I showed before, where you hover over a component in a map and, you know, you see the name or something, a little bit of that particular geometry. And also Kepler has these interactions, like, for example, you can geocode a particular location by just, you know, using an interaction, you have brushes, and you know, you have also the coordinate, you know, interaction. So given the customizability of Kepler, and, you know, given the amount of layers it can process, you can actually see one in action right now, where, you know, with an aggregation of points is getting performed on the fly. So we're just choosing a color and we're choosing to color those grids based on a particular field, which is actually getting done pretty fast. And also, this is one of the things I absolutely love about Kepler is how amazingly beautiful spatiotemporal maps you can create. So a quick definition of spatiotemporal maps, a spatiotemporal data is when you have both space and time linked with a particular data, which is pretty cool. So an example of this can be a trip or a practical example would be a drone data. Right. So you have a drone that you're flying around. And at, you know, when you get the data out of that drone, you actually have two components of where it was and when wasn't there. So you can use this information to create a timeline chart using Kepler, and it looks as beautiful as this. So this is actually a trip data. So you can see trips over time. It looks, you know, pretty beautiful if you can create. But as always, you know, these are not the only libraries that are there. And given the amazing community that is present in the open source world, you can actually, you know, we have like tons of libraries that you can depend on. You don't have to just, you know, you have countless libraries that what I'm trying to say. So I'm going to just explore them. So one such library is to book it. So with okay you can actually do something similar. So here I'm just, you know, importing the figure, the output file and I'm importing the tiles. I'm using carto TV styles, which is which is going to be my base map provider. And you know, I'm just creating an empty map here. I'm actually choosing my coordinate reference system, which is marketer. And also I'm providing the range of the X and Y, which is, you know, pretty interesting and is not a feature that you have in the other libraries. But everything you you you get something new out of it, you know, it's not all the same. And, you know, it, it's good to actually explore this, it's actually fun to explore these libraries, you know, and how people are doing the same thing, but in really different and really amazing and also we have a plot, a plot least a plot lead bouquet are not just for maps, but but for you know, just basic interactive plots. And also we have all there. So over here with partly I'm actually using partly express so that this code is a little smaller with partly it gets a little bigger. So with partly express I'm importing the car share data set, and I'm creating a scatter map box plot by just passing the data frame, the latitude longitude, the color and the size. So here actually, this is pretty cool because I'm able to represent more than I would be able to represent normally. So I'm using color to represent a feature, and I'm using the size to represent another feature. So I have these two features complementing each other on the same map. So this is really useful in cases where you want to, you know, spot correlation between two events happening, link to the same spatial component at the same time. So it's cool that you can do this with plotting. This talks about Geopatra, which is something I worked on on my free time, which is kind of like a hack function of all the scripts that I wrote to quickly create interactive maps, but without going to other libraries by staying in the realm of georadiary essentially. So it's something like so. So if you have not cringed yet, a Geopatra is named Geopatra because it rhymes with Cleopatra and you know, a Cleo and Geo, you know, kind of rhyme and you know, I thought I was being clever at the time. So to create a folium plot, you just import your pattern and you do the data frame dot folium dot plot and you just plot it. So it's just a single line to, you know, plot your Geo. Oh, but you know, one thing which you know even I thought myself while just writing this is, why can't they just be these scripts which I keep for myself and why does it have to be another library, it can just be a gist of, you know, functions that can you know plot digital frames, not a library, right. So again, it's not a library. It's a wrapper essentially a gigantic graph. And it's an interface and interface to interact with the existing libraries without leaving the Geopandas ecosystem. And also I have Netflix syndrome. So if you don't know what that means, Netflix gives you a lot of choices when you open the app and you know people get really overwhelmed at that choice and it's really hard for you to choose something. It's the same thing for me, you know, there are these amazing libraries, you know, which complement each other. And also they are different in their own way and I don't want to choose one of them. I want all of them. So I actually want to spend more time plotting and you know spend less time googling for APIs because I have a very bad memory and I tend to forget, you know, how do I create a chloropath map, it's fully how do I create a heat map. I just keep googling and you know, for different packages and you know that sometimes gets tiring. So, oh, all right, so let me move to the documentation of Geopandas essentially. So with Geopandas, you can I'm actually just taking these two data frames out and I'm creating these interactive maps. These are the geochason maps. So this documentation is at geopatra.readthetalks.io and the GitHub repository is GitHub slash Sangashnan slash Geopatra. So since my name is really weird, like, I actually get my name to be the user name in every platform that I go to. So on Twitter, on, you know, on GitHub, on every platform, I just my name. So I created geochason map with just one line. I create a circle map with just one line. I pass the parameters of the tooltip, which is named so that I hover over it actually see the name. And also I have the radius which is the radius. And you know, I fill it with the color and the fill color is red. And, you know, the zoom is, you know, 100 so that I can zoom out. So these are the chloropeth maps, which is again one line. You color by the population, instead of the GDP, but they're obviously correlated. And the tooltip is the name. So I hover over it. I see the name. I, you know, set the color. I said the zoom and I said this time. So the map clusters are again one line. I create the marker clusters. And I also have weighted model clusters, which are kind of in the experimental phase essentially. So these are the ways where you can cluster with not just points, but with value. So these two means there are two points right. So these clusters mean that when you go here, the sum of the values here, you know, account to 986. It's not essentially the number of points. And you know, they look really weird because it's not completely ready yet. I'm just playing around with things. So, and also, of course, we have the heat maps that are always there. And, you know, this is what I'm actually excited about, which is Kepler. I also have a way to create an interactive map, which is a single line, which is, you know, again, the data frame dot Kepler dot plot. And you know, it creates this map for me. So I'm actually controlling the config of Kepler with, you know, a ginger template essentially. So the parameters you pass here just replace those prebuilt templates which are there. You know, it's pretty easy to plot them actually. And also, to create a simple polygon. I pass the color, I pass the stroke, which are now a list of RBG, but they will not be really soon. I have a PR ready to, you know, make them into actual colors rather than passing a list of RGBs. But for now, they are. And also, I passed the stroke thickness, which is a parameter I passed the opacity. And, you know, to create this plot again. So now they are all the same color, right. I can also pass a new parameter called color field, which is the population estimate and I also pass the color scheme, which is blues. So right now, because of this, it is actually colored based on the population estimate rather than being colored arbitrarily. So, yeah, that's it for Geopatra. Thank you for coming. Okay, I'm just going to look at the questions. Okay, I have two questions. Can you talk about how Kepler is better than Mapbox since it's built on top of it. Okay. So Kepler and Mapbox are actually complementing like one is not better than the other essentially. So actually Kepler uses Mapbox internally, to be honest. Mapbox is the tile provider for Kepler. So the base maps which you see when you want to create plots on Kepler, they are all Mapbox tiles. So it's not kind of a competition but kind of complementing each other essentially. So yeah, that's that. Also, another question. Do either Folium or Kepler support non geographic map. For example, mapping a star map. I'm not, I'm not sure about Folium, but with Kepler, you can actually provide your own custom base map. So if you actually Google for it, you can actually find a map where people have plotted a baseball stadium and where they have actually modeled the whole stadium on the base map and plotted how different shots have flown, you know, the shots which were hit and the different trajectories they had gone into. So like, that was pretty cool. So, so I guess it is possible, you know, where you can pass your own custom map, you know, custom tiles and you know, create maps out of it. But it is actually pretty hard to do. But it is possible. But they are mainly present for geographic maps. That's the main use case, but it is possible to extend them and customize them. And of course the code is all open source. So all the projects I talked about are open source. Are there any map packages that also integrate AR functionality. So I assume you mean augmented reality. And to be honest, I don't know I have not worked with AR maps. I just have done stuff with your unity and euphoria, which is a pretty basic. So I'm not really sure I can actually maybe Google for it and you know, get back to you or we can discuss about it. So, okay, I think that is it. We are out of questions. Thank you very much, everyone. Thank you for joining. I hope you liked my introduction. That was something I was planning for. Thank you for being here. Thank you.
 So for our next talk, we have someone special joining us.  So this person who I'm going to introduce is like one of the funniest people I know.  And you know, I sometimes secretly wish I was him.  So let's welcome that person now.  Okay.  Hello everyone.  It's my talk right now.  Thank you for that humbling introduction.  My name is Sangarshan.  I work at Grofus and it's pronounced grofus.  So I like building imaginary projects in my head, talking about those imaginary projects in my head.  And you know, I also love all those imaginary projects.  So I'm going to be talking about one such case where that imaginary project actually got executed and which was amazing.  So that is the story of this is the story of how I did that.  So I'm going to begin by proclaiming my love for pandas.  You know, whenever we want to work out whenever almost all of us want to work with data.  We know we move to pandas and rightly so pandas is amazing.  It's like the top hanks of Python libraries.  And of course, it rests on top of all these amazing, you know, packages, which are present in the open source environment.  These include, you know, matplotlib.  We have NumPy, we have pandas, and then we have scikit-learn, you know, all these amazing open source packages from the scientific Python community makes Python the code to language when anyone wants to do anything with data.  So we're going to talk about a special type of data, which is location data.  Location data has location component linked with it. For example, I'm reading a CSV file over here, which has latitude and longitude.  So this is essentially a location component.  So a data with a location component can be represented as a geometry.  And there are, so geometries are basically just X and Y coordinates and the various ways you can arrange them.  So these geometries can be a pair of lat longs or they can be a list of lat longs, just a polygon.  And also I'm grossly over simplifying what geometries are and Euclid would be really angry with me right now.  But we also have line strings, which are like line strings, and we have multi polygons, which is a fancy plural word for polygons.  And we also have circles.  Now, to work with these geometries, we have this amazing package in the open source community called GeoPandas.  So with GeoPandas, we can work with data frame.  And in this case, a GeoDataFrame, and we can stay with a familiar interface.  And GeoPandas will let us read and write commonly used geospatial formats like KML files, shape files and geotransmit files using the other library called FIANA.  And then we also can perform different spatial operations like merge, overlay and joints with the help of another amazing package called Shapy.  And also of course, the crux of the talk, we can plot them on a map with Matbotlet.  And also I'm leaving a whole lot of things which we can do with GeoPandas like handling projections and recently added stuff like vectorized operations with PyGeos and also indexing your data with R trees or any other data structure.  And if you are interested in knowing more, this is a tutorial link which I have attached here. I will share these slides on the on the break room.  And this tutorial has been made by the maintainer. So it's like pretty comprehensive and it's pretty amazing.  All right, so moving on to data frame. So we have this data frame which I read before.  And we have lat and ln. So now we convert it into a geodata frame. So how we do that is we import GeoPandas and also we convert this lat and ln column into a point.  A point is a geometry. So we set geometry equals combination of these two columns.  So it creates a column called geometry and it creates a point geometry object using shape.  So this is that point. And also on the second line, we are setting something called CRS. So CRS is the coordinate reference system.  So this is how we project our earth in a way that we can understand and interpret.  So in these cases, so in this case, we have used EPSC for 326, which is like the most commonly used coordinate reference system, which is also used by GPS systems and all the navigation systems.  So this is the reason why latitudes and longitudes have spatial meaning in them.  If not, if you don't have coordinate reference system, they are just arbitrary x and y coordinates. They are not latitudes and longitudes.  So how do I plot up? So with Geopandas, everything becomes really simple. It's just a dot plot.  So you just do import map plotlet and then you just, you know, to the frame dot plot, and then you have this map.  But this does not look like a map, right? It's, it's missing something.  So to do interactive maps with Geopandas, we actually have to move away from Geopandas and into other amazing open source libraries, which are there for creating interactive maps.  So how do we do that? Do that we employ the most powerful weapon a developer has, which is Googling. So that's what I did.  Google for a while. And, you know, I actually got to know that fully and we've actually one such package that actually lets me do this.  So I take in the geodata frame, and then I import fully.  And then now I create an a fully and dot map. So this fully dot map is just an empty canvas, kind of like a canvas where you can draw on top of.  So this just creates a dummy map for me where I pass in the location, the zoom start the tiles and also we have various other parameters you can pass to the map.  So after creating that dummy canvas. Now we want to plot our data on top of this canvas. So to do that, we create a feature called points.  So these points feature is made up of a geodata frame, which we created before. And also we had a parameter called tooltip tooltip is also a feature in which the field is named.  So when I hover over this map, I can actually see the name of each and every point that I just plotted. Now after creating this feature, I take the canvas and I add this feature to the canvas, a very  iconic API, very simple and incredibly effective to create, you know, beautiful looking maps.  Now onward to polygons.  So we again read geodata frame, which is made up of polygons instead of points as you can see it's made up of multi polygons and also polygons. And these are all different, you know, countries and continents.  So we create a map out of them with your pandas. We just again do just dot plot pretty easy. And we now choose the column which we want to plot on top of, for example, here I've chosen GDP.  So that means this map is colored based on the GDP. And also, we pass the color map so that you know it goes from this color to that color.  I have also attached a link for the color maps, you know, the different color maps for matrot which I present. And also I give legend equals true so that I actually see this.  So now onward to the interactive maps to do that first, we actually create this color map to do that I'm using another package called Brankar dot color map, using which I'm actually importing this color map.  And then I'm passing the number of steps I have to split it out of. So after creating the color map, I define my empty folium canvas.  And also I define a style function. So this style function contains the various parameters that I'm going to be passing to my map, which I'm going to create right now.  So it's made up of a fill color, which denotes the color which I have to fill in that particular polygon, and also the color of that polygon itself, and also the weight of that border, which is the polygon color, and also how much is the  opacity of the color I have to fill it into. So these are the parameters. And then we again we create a geojson feature, we pass a geodata frame, we create the tooltip and this time I'm passing the name and also the GDP.  So when I hover over it, I see both of them. Amazing. So I also pass in the style function, and then just add it to the canvas and also notice that I add the color map to the canvas.  So I see this incredibly distorted legend, but I still see.  So folium also has several special maps that you can actually create with it essentially. So these are called plugins that you actually create with these.  So one such plugin is called market cluster. So with market cluster, you just, you know, import a market cluster from folium dot plugin.  And now I think it a little weird where you're bearing you need to take a geodata frame and convert it into a list of latitudes and nonitudes.  So we do that over here. Now we have a list of lat lungs. And now we create an empty canvas. And you know, we again do the, do the drill at child market cluster locations, we pass the list.  And, you know, we get it is it cluster. So, so the, these two, the number two here means that this cluster is made up of two points.  So the number eight means that this cluster is made up of eight points. And the cluster 76 means that this cluster is made up of 76 points.  So I can click on it, it splits into several clusters again, I click on it, it splits into clusters, still I'm able to see each and every individual point, which is pretty awesome.  And now heat map. So heat map is something which you know, given the current situation we actually see on a daily basis. So we know how important they are to convey the message, you know, so this is the heat map we're creating.  So this does not represent anything, this is just arbitrary heat map to do this we you know take the location.  And you know just create a heat map out of it with a radius of this particular map. So heat maps actually are pretty interesting because  you just have to take one look at it to you know, get all the information out of it essentially. So these are pretty cool. So now more data and more problems. So one issue which I started to notice, you know, when going down the folium path is when the number  of points in your map start to increase folium starts to get a little bit ineffective. Folium cannot handle a lot of points so one such also one solution, which you can deploy to make folium actually handle a lot of points is to actually,  you know, create clusters like this, you know, create clusters so that you can actually plot out of points. But in some cases, the number of points you have you know, you know, it's like a lot.  So your DOM will just crash like your browser crashes and we will not be able to plot all these spots. So that's where things get a little hard. But no fret not we have a new kid in town, and that's Kepler GL.  So this is the textbook definition of Kepler GL. So, essentially it's this amazing project, which was developed at Uber. So they have built Kepler on top of DEC GL and webGL. So you know, they actually can render, you know, millions of points and perform spatial  aggregations on the fly, which is pretty amazing. You know, and you can create, you know, amazing cool looking maps with Kepler when you want to scale out your points or scale out your data.  So to install Kepler, it's when you are on a Jupyter notebook that's greater than, you know, the version 5.3, you can just do a pip install Kepler GL, it installs it, and when you are in JupyterLab, you just do, you know, JupyterLab extension,  you can install the Kepler extension and you know you enable it after installing and then you are good to go. You just be able to import Kepler GL, you know, create a map out of it and you see this amazing interface.  So, another amazing thing about Kepler is that it uses configs to customize the maps.  So, config looks like this. It has version, it has, you know, states, filters, you know, I'm not going to go deep into the config because it is, you know, amazingly customizable.  So I'm not going to go really deep into that. But I'm going to actually give you an overlay of, you know, all the things that you can control with the config.  So, Kepler's UX flow is actually made up of five layers. So initially, you have your base map, right? So the base map is made up of tiles that you can acquire from various sources.  For example, you have, you can acquire tiles from OpenStreetMaps, you can acquire map tiles from Google, you can acquire map tiles from Mapbox, you know, several styles, and you know, that makes up your tiles.  And on top of these tiles, you, you know, overlay your data. And also, on this data, you can perform filters, aggregations, and, you know, all the lot.  And, you know, to perform filters and aggregations, you can actually represent your data layer as, you know, five different types with Kepler.  So we have hexagonal layers, we have arc layers, we have point layers, we have path layers, and we have grid layers. And the amazing thing about it is that these layers, like some of these layers are actually, you know, interchangeable.  Like for example, you can have a point layer that you can represent as a grid. And you have, you know, H3 grids, which are actually a spatial indexing system, which is also developed courtesy of Uber, which can, you know, help you plot a lot of points without having to actually show those points on a map.  Rather, index them and aggregate them as grids, so that, you know, the number of points in your map significantly decreases.  And also, you have interactions you can perform on the data that has been brought on a map. And these interactions include stuff like tooltip.  For example, these tooltips are the ones which I showed before, where you hover over a component in a map and, you know, you see the name or something, a little bit of that particular geometry.  And also Kepler has these interactions, like, for example, you can geocode a particular location by just, you know, using an interaction, you have brushes, and you know, you have also the coordinate, you know, interaction.  So given the customizability of Kepler, and, you know, given the amount of layers it can process, you can actually see one in action right now, where, you know,  with an aggregation of points is getting performed on the fly. So we're just choosing a color and we're choosing to color those grids based on a particular field, which is actually getting done pretty fast.  And also, this is one of the things I absolutely love about Kepler is how amazingly beautiful spatiotemporal maps you can create.  So a quick definition of spatiotemporal maps, a spatiotemporal data is when you have both space and time linked with a particular data, which is pretty cool.  So an example of this can be a trip or a practical example would be a drone data.  Right. So you have a drone that you're flying around. And at, you know, when you get the data out of that drone, you actually have two components of where it was and when wasn't there.  So you can use this information to create a timeline chart using Kepler, and it looks as beautiful as this. So this is actually a trip data. So you can see trips over time. It looks, you know, pretty beautiful if you can create.  But as always, you know, these are not the only libraries that are there. And given the amazing community that is present in the open source world, you can actually, you know, we have like tons of libraries that you can depend on.  You don't have to just, you know, you have countless libraries that what I'm trying to say. So I'm going to just explore them. So one such library is to book it.  So with okay you can actually do something similar. So here I'm just, you know, importing the figure, the output file and I'm importing the tiles. I'm using carto TV styles, which is which is going to be my base map provider.  And you know, I'm just creating an empty map here. I'm actually choosing my coordinate reference system, which is marketer. And also I'm providing the range of the X and Y, which is, you know, pretty interesting and is not a feature that you have in the other libraries.  But everything you you you get something new out of it, you know, it's not all the same. And, you know, it, it's good to actually explore this, it's actually fun to explore these libraries, you know, and how people are doing the same thing, but in really different and really amazing  and also we have a plot, a plot least a plot lead bouquet are not just for maps, but but for you know, just basic interactive plots. And also we have all there.  So over here with partly I'm actually using partly express so that this code is a little smaller with partly it gets a little bigger.  So with partly express I'm importing the car share data set, and I'm creating a scatter map box plot by just passing the data frame, the latitude longitude, the color and the size.  So here actually, this is pretty cool because I'm able to represent more than I would be able to represent normally. So I'm using color to represent a feature, and I'm using the size to represent another feature.  So I have these two features complementing each other on the same map. So this is really useful in cases where you want to, you know, spot correlation between two events happening, link to the same spatial component at the same time.  So it's cool that you can do this with plotting.  This talks about Geopatra, which is something I worked on on my free time, which is kind of like a hack function of all the scripts that I wrote to quickly create interactive maps, but without going to other libraries by staying in the realm of georadiary essentially.  So it's something like so. So if you have not cringed yet, a Geopatra is named Geopatra because it rhymes with Cleopatra and you know, a Cleo and Geo, you know, kind of rhyme and you know, I thought I was being clever at the time.  So to create a folium plot, you just import your pattern and you do the data frame dot folium dot plot and you just plot it. So it's just a single line to, you know, plot your Geo.  Oh, but you know, one thing which you know even I thought myself while just writing this is, why can't they just be these scripts which I keep for myself and why does it have to be another library, it can just be a gist of, you know, functions that can you know plot digital  frames, not a library, right. So again, it's not a library. It's a wrapper essentially a gigantic graph. And it's an interface and interface to interact with the existing libraries without leaving the Geopandas ecosystem.  And also I have Netflix syndrome. So if you don't know what that means, Netflix gives you a lot of choices when you open the app and you know people get really overwhelmed at that choice and it's really hard for you to choose something.  It's the same thing for me, you know, there are these amazing libraries, you know, which complement each other. And also they are different in their own way and I don't want to choose one of them. I want all of them.  So I actually want to spend more time plotting and you know spend less time googling for APIs because I have a very bad memory and I tend to forget, you know, how do I create a chloropath map, it's fully how do I create a heat map.  I just keep googling and you know, for different packages and you know that sometimes gets tiring.  So, oh, all right, so let me move to the documentation of Geopandas essentially.  So with Geopandas, you can I'm actually just taking these two data frames out and I'm creating these interactive maps. These are the geochason maps.  So this documentation is at geopatra.readthetalks.io and the GitHub repository is GitHub slash Sangashnan slash Geopatra.  So since my name is really weird, like, I actually get my name to be the user name in every platform that I go to. So on Twitter, on, you know, on GitHub, on every platform, I just my name.  So I created geochason map with just one line. I create a circle map with just one line.  I pass the parameters of the tooltip, which is named so that I hover over it actually see the name. And also I have the radius which is the radius.  And you know, I fill it with the color and the fill color is red. And, you know, the zoom is, you know, 100 so that I can zoom out.  So these are the chloropeth maps, which is again one line. You color by the population, instead of the GDP, but they're obviously correlated.  And the tooltip is the name. So I hover over it. I see the name. I, you know, set the color. I said the zoom and I said this time.  So the map clusters are again one line. I create the marker clusters. And I also have weighted model clusters, which are kind of in the experimental phase essentially.  So these are the ways where you can cluster with not just points, but with value. So these two means there are two points right.  So these clusters mean that when you go here, the sum of the values here, you know, account to 986. It's not essentially the number of points. And you know, they look really weird because it's not completely ready yet.  I'm just playing around with things.  So, and also, of course, we have the heat maps that are always there. And, you know, this is what I'm actually excited about, which is Kepler.  I also have a way to create an interactive map, which is a single line, which is, you know, again, the data frame dot Kepler dot plot. And you know, it creates this map for me.  So I'm actually controlling the config of Kepler with, you know, a ginger template essentially. So the parameters you pass here just replace those prebuilt templates which are there.  You know, it's pretty easy to plot them actually. And also, to create a simple polygon. I pass the color, I pass the stroke, which are now a list of RBG, but they will not be really soon.  I have a PR ready to, you know, make them into actual colors rather than passing a list of RGBs. But for now, they are.  And also, I passed the stroke thickness, which is a parameter I passed the opacity. And, you know, to create this plot again. So now they are all the same color, right.  I can also pass a new parameter called color field, which is the population estimate and I also pass the color scheme, which is blues.  So right now, because of this, it is actually colored based on the population estimate rather than being colored arbitrarily.  So, yeah, that's it for Geopatra.  Thank you for coming.  Okay, I'm just going to look at the questions.  Okay, I have two questions. Can you talk about how Kepler is better than Mapbox since it's built on top of it.  Okay.  So Kepler and Mapbox are actually complementing like one is not better than the other essentially. So actually Kepler uses Mapbox internally, to be honest.  Mapbox is the tile provider for Kepler. So the base maps which you see when you want to create plots on Kepler, they are all Mapbox tiles. So it's not kind of a competition but kind of complementing each other essentially.  So yeah, that's that. Also, another question. Do either Folium or Kepler support non geographic map. For example, mapping a star map.  I'm not, I'm not sure about Folium, but with Kepler, you can actually provide your own custom base map. So if you actually Google for it, you can actually find a map where people have plotted a baseball stadium and where they have actually  modeled the whole stadium on the base map and plotted how different shots have flown, you know, the shots which were hit and the different trajectories they had gone into.  So like, that was pretty cool. So, so I guess it is possible, you know, where you can pass your own custom map, you know, custom tiles and you know, create maps out of it.  But it is actually pretty hard to do.  But it is possible. But they are mainly present for geographic maps. That's the main use case, but it is possible to extend them and customize them. And of course the code is all open source.  So all the projects I talked about are open source.  Are there any map packages that also integrate AR functionality. So I assume you mean augmented reality.  And to be honest, I don't know I have not worked with AR maps.  I just have done stuff with your unity and euphoria, which is a pretty basic. So I'm not really sure I can actually maybe Google for it and you know, get back to you or we can discuss about it.  So, okay, I think that is it. We are out of questions.  Thank you very much, everyone. Thank you for joining. I hope you liked my introduction. That was something I was planning for.  Thank you for being here. Thank you.
Sangarshanan_Veeraraghavan_-_Interactive_Mapmaking_cWVKGz4gvwE_0_179.png Sangarshanan_Veeraraghavan_-_Interactive_Mapmaking_cWVKGz4gvwE_180_263.png Sangarshanan_Veeraraghavan_-_Interactive_Mapmaking_cWVKGz4gvwE_264_359.png Sangarshanan_Veeraraghavan_-_Interactive_Mapmaking_cWVKGz4gvwE_360_467.png Sangarshanan_Veeraraghavan_-_Interactive_Mapmaking_cWVKGz4gvwE_468_515.png Sangarshanan_Veeraraghavan_-_Interactive_Mapmaking_cWVKGz4gvwE_516_851.png Sangarshanan_Veeraraghavan_-_Interactive_Mapmaking_cWVKGz4gvwE_852_923.png Sangarshanan_Veeraraghavan_-_Interactive_Mapmaking_cWVKGz4gvwE_924_1007.png Sangarshanan_Veeraraghavan_-_Interactive_Mapmaking_cWVKGz4gvwE_1008_1787.png Sangarshanan_Veeraraghavan_-_Interactive_Mapmaking_cWVKGz4gvwE_1788_2279.png Sangarshanan_Veeraraghavan_-_Interactive_Mapmaking_cWVKGz4gvwE_2280_9743.png Sangarshanan_Veeraraghavan_-_Interactive_Mapmaking_cWVKGz4gvwE_9744_13679.png Sangarshanan_Veeraraghavan_-_Interactive_Mapmaking_cWVKGz4gvwE_13680_13727.png Sangarshanan_Veeraraghavan_-_Interactive_Mapmaking_cWVKGz4gvwE_13728_17567.png Sangarshanan_Veeraraghavan_-_Interactive_Mapmaking_cWVKGz4gvwE_17568_18671.png Sangarshanan_Veeraraghavan_-_Interactive_Mapmaking_cWVKGz4gvwE_18672_19367.png Sangarshanan_Veeraraghavan_-_Interactive_Mapmaking_cWVKGz4gvwE_19368_19439.png Sangarshanan_Veeraraghavan_-_Interactive_Mapmaking_cWVKGz4gvwE_19440_26207.png Sangarshanan_Veeraraghavan_-_Interactive_Mapmaking_cWVKGz4gvwE_26208_26987.png Sangarshanan_Veeraraghavan_-_Interactive_Mapmaking_cWVKGz4gvwE_26988_33503.png Sangarshanan_Veeraraghavan_-_Interactive_Mapmaking_cWVKGz4gvwE_33504_38675.png Sangarshanan_Veeraraghavan_-_Interactive_Mapmaking_cWVKGz4gvwE_38676_38723.png Sangarshanan_Veeraraghavan_-_Interactive_Mapmaking_cWVKGz4gvwE_38724_38891.png Sangarshanan_Veeraraghavan_-_Interactive_Mapmaking_cWVKGz4gvwE_38892_40355.png Sangarshanan_Veeraraghavan_-_Interactive_Mapmaking_cWVKGz4gvwE_40356_41183.png Sangarshanan_Veeraraghavan_-_Interactive_Mapmaking_cWVKGz4gvwE_41184_41423.png Sangarshanan_Veeraraghavan_-_Interactive_Mapmaking_cWVKGz4gvwE_41424_41579.png Sangarshanan_Veeraraghavan_-_Interactive_Mapmaking_cWVKGz4gvwE_41580_41795.png Sangarshanan_Veeraraghavan_-_Interactive_Mapmaking_cWVKGz4gvwE_41796_41855.png Sangarshanan_Veeraraghavan_-_Interactive_Mapmaking_cWVKGz4gvwE_41856_42359.png Sangarshanan_Veeraraghavan_-_Interactive_Mapmaking_cWVKGz4gvwE_42360_44543.png Sangarshanan_Veeraraghavan_-_Interactive_Mapmaking_cWVKGz4gvwE_44544_45083.png Sangarshanan_Veeraraghavan_-_Interactive_Mapmaking_cWVKGz4gvwE_45084_45131.png Sangarshanan_Veeraraghavan_-_Interactive_Mapmaking_cWVKGz4gvwE_45132_46019.png Sangarshanan_Veeraraghavan_-_Interactive_Mapmaking_cWVKGz4gvwE_46020_46660.png
So for our next talk, we have someone special joining us. So this person who I'm going to introduce is like one of the funniest people I know. And you know, I sometimes secretly wish I was him. So let's welcome that person now. Okay. Hello everyone. It's my talk right now. Thank you for that humbling introduction. My name is Sangarshan. I work at Grofus and it's pronounced grofus. So I like building imaginary projects in my head, talking about those imaginary projects in my head. And you know, I also love all those imaginary projects. So I'm going to be talking about one such case where that imaginary project actually got executed and which was amazing. So that is the story of this is the story of how I did that. So I'm going to begin by proclaiming my love for pandas. You know, whenever we want to work out whenever almost all of us want to work with data. We know we move to pandas and rightly so pandas is amazing. It's like the top hanks of Python libraries. And of course, it rests on top of all these amazing, you know, packages, which are present in the open source environment. These include, you know, matplotlib. We have NumPy, we have pandas, and then we have scikit-learn, you know, all these amazing open source packages from the scientific Python community makes Python the code to language when anyone wants to do anything with data. So we're going to talk about a special type of data, which is location data. Location data has location component linked with it. For example, I'm reading a CSV file over here, which has latitude and longitude. So this is essentially a location component. So a data with a location component can be represented as a geometry. And there are, so geometries are basically just X and Y coordinates and the various ways you can arrange them. So these geometries can be a pair of lat longs or they can be a list of lat longs, just a polygon. And also I'm grossly over simplifying what geometries are and Euclid would be really angry with me right now. But we also have line strings, which are like line strings, and we have multi polygons, which is a fancy plural word for polygons. And we also have circles. Now, to work with these geometries, we have this amazing package in the open source community called GeoPandas. So with GeoPandas, we can work with data frame. And in this case, a GeoDataFrame, and we can stay with a familiar interface. And GeoPandas will let us read and write commonly used geospatial formats like KML files, shape files and geotransmit files using the other library called FIANA. And then we also can perform different spatial operations like merge, overlay and joints with the help of another amazing package called Shapy. And also of course, the crux of the talk, we can plot them on a map with Matbotlet. And also I'm leaving a whole lot of things which we can do with GeoPandas like handling projections and recently added stuff like vectorized operations with PyGeos and also indexing your data with R trees or any other data structure. And if you are interested in knowing more, this is a tutorial link which I have attached here. I will share these slides on the on the break room. And this tutorial has been made by the maintainer. So it's like pretty comprehensive and it's pretty amazing. All right, so moving on to data frame. So we have this data frame which I read before. And we have lat and ln. So now we convert it into a geodata frame. So how we do that is we import GeoPandas and also we convert this lat and ln column into a point. A point is a geometry. So we set geometry equals combination of these two columns. So it creates a column called geometry and it creates a point geometry object using shape. So this is that point. And also on the second line, we are setting something called CRS. So CRS is the coordinate reference system. So this is how we project our earth in a way that we can understand and interpret. So in these cases, so in this case, we have used EPSC for 326, which is like the most commonly used coordinate reference system, which is also used by GPS systems and all the navigation systems. So this is the reason why latitudes and longitudes have spatial meaning in them. If not, if you don't have coordinate reference system, they are just arbitrary x and y coordinates. They are not latitudes and longitudes. So how do I plot up? So with Geopandas, everything becomes really simple. It's just a dot plot. So you just do import map plotlet and then you just, you know, to the frame dot plot, and then you have this map. But this does not look like a map, right? It's, it's missing something. So to do interactive maps with Geopandas, we actually have to move away from Geopandas and into other amazing open source libraries, which are there for creating interactive maps. So how do we do that? Do that we employ the most powerful weapon a developer has, which is Googling. So that's what I did. Google for a while. And, you know, I actually got to know that fully and we've actually one such package that actually lets me do this. So I take in the geodata frame, and then I import fully. And then now I create an a fully and dot map. So this fully dot map is just an empty canvas, kind of like a canvas where you can draw on top of. So this just creates a dummy map for me where I pass in the location, the zoom start the tiles and also we have various other parameters you can pass to the map. So after creating that dummy canvas. Now we want to plot our data on top of this canvas. So to do that, we create a feature called points. So these points feature is made up of a geodata frame, which we created before. And also we had a parameter called tooltip tooltip is also a feature in which the field is named. So when I hover over this map, I can actually see the name of each and every point that I just plotted. Now after creating this feature, I take the canvas and I add this feature to the canvas, a very iconic API, very simple and incredibly effective to create, you know, beautiful looking maps. Now onward to polygons. So we again read geodata frame, which is made up of polygons instead of points as you can see it's made up of multi polygons and also polygons. And these are all different, you know, countries and continents. So we create a map out of them with your pandas. We just again do just dot plot pretty easy. And we now choose the column which we want to plot on top of, for example, here I've chosen GDP. So that means this map is colored based on the GDP. And also, we pass the color map so that you know it goes from this color to that color. I have also attached a link for the color maps, you know, the different color maps for matrot which I present. And also I give legend equals true so that I actually see this. So now onward to the interactive maps to do that first, we actually create this color map to do that I'm using another package called Brankar dot color map, using which I'm actually importing this color map. And then I'm passing the number of steps I have to split it out of. So after creating the color map, I define my empty folium canvas. And also I define a style function. So this style function contains the various parameters that I'm going to be passing to my map, which I'm going to create right now. So it's made up of a fill color, which denotes the color which I have to fill in that particular polygon, and also the color of that polygon itself, and also the weight of that border, which is the polygon color, and also how much is the opacity of the color I have to fill it into. So these are the parameters. And then we again we create a geojson feature, we pass a geodata frame, we create the tooltip and this time I'm passing the name and also the GDP. So when I hover over it, I see both of them. Amazing. So I also pass in the style function, and then just add it to the canvas and also notice that I add the color map to the canvas. So I see this incredibly distorted legend, but I still see. So folium also has several special maps that you can actually create with it essentially. So these are called plugins that you actually create with these. So one such plugin is called market cluster. So with market cluster, you just, you know, import a market cluster from folium dot plugin. And now I think it a little weird where you're bearing you need to take a geodata frame and convert it into a list of latitudes and nonitudes. So we do that over here. Now we have a list of lat lungs. And now we create an empty canvas. And you know, we again do the, do the drill at child market cluster locations, we pass the list. And, you know, we get it is it cluster. So, so the, these two, the number two here means that this cluster is made up of two points. So the number eight means that this cluster is made up of eight points. And the cluster 76 means that this cluster is made up of 76 points. So I can click on it, it splits into several clusters again, I click on it, it splits into clusters, still I'm able to see each and every individual point, which is pretty awesome. And now heat map. So heat map is something which you know, given the current situation we actually see on a daily basis. So we know how important they are to convey the message, you know, so this is the heat map we're creating. So this does not represent anything, this is just arbitrary heat map to do this we you know take the location. And you know just create a heat map out of it with a radius of this particular map. So heat maps actually are pretty interesting because you just have to take one look at it to you know, get all the information out of it essentially. So these are pretty cool. So now more data and more problems. So one issue which I started to notice, you know, when going down the folium path is when the number of points in your map start to increase folium starts to get a little bit ineffective. Folium cannot handle a lot of points so one such also one solution, which you can deploy to make folium actually handle a lot of points is to actually, you know, create clusters like this, you know, create clusters so that you can actually plot out of points. But in some cases, the number of points you have you know, you know, it's like a lot. So your DOM will just crash like your browser crashes and we will not be able to plot all these spots. So that's where things get a little hard. But no fret not we have a new kid in town, and that's Kepler GL. So this is the textbook definition of Kepler GL. So, essentially it's this amazing project, which was developed at Uber. So they have built Kepler on top of DEC GL and webGL. So you know, they actually can render, you know, millions of points and perform spatial aggregations on the fly, which is pretty amazing. You know, and you can create, you know, amazing cool looking maps with Kepler when you want to scale out your points or scale out your data. So to install Kepler, it's when you are on a Jupyter notebook that's greater than, you know, the version 5.3, you can just do a pip install Kepler GL, it installs it, and when you are in JupyterLab, you just do, you know, JupyterLab extension, you can install the Kepler extension and you know you enable it after installing and then you are good to go. You just be able to import Kepler GL, you know, create a map out of it and you see this amazing interface. So, another amazing thing about Kepler is that it uses configs to customize the maps. So, config looks like this. It has version, it has, you know, states, filters, you know, I'm not going to go deep into the config because it is, you know, amazingly customizable. So I'm not going to go really deep into that. But I'm going to actually give you an overlay of, you know, all the things that you can control with the config. So, Kepler's UX flow is actually made up of five layers. So initially, you have your base map, right? So the base map is made up of tiles that you can acquire from various sources. For example, you have, you can acquire tiles from OpenStreetMaps, you can acquire map tiles from Google, you can acquire map tiles from Mapbox, you know, several styles, and you know, that makes up your tiles. And on top of these tiles, you, you know, overlay your data. And also, on this data, you can perform filters, aggregations, and, you know, all the lot. And, you know, to perform filters and aggregations, you can actually represent your data layer as, you know, five different types with Kepler. So we have hexagonal layers, we have arc layers, we have point layers, we have path layers, and we have grid layers. And the amazing thing about it is that these layers, like some of these layers are actually, you know, interchangeable. Like for example, you can have a point layer that you can represent as a grid. And you have, you know, H3 grids, which are actually a spatial indexing system, which is also developed courtesy of Uber, which can, you know, help you plot a lot of points without having to actually show those points on a map. Rather, index them and aggregate them as grids, so that, you know, the number of points in your map significantly decreases. And also, you have interactions you can perform on the data that has been brought on a map. And these interactions include stuff like tooltip. For example, these tooltips are the ones which I showed before, where you hover over a component in a map and, you know, you see the name or something, a little bit of that particular geometry. And also Kepler has these interactions, like, for example, you can geocode a particular location by just, you know, using an interaction, you have brushes, and you know, you have also the coordinate, you know, interaction. So given the customizability of Kepler, and, you know, given the amount of layers it can process, you can actually see one in action right now, where, you know, with an aggregation of points is getting performed on the fly. So we're just choosing a color and we're choosing to color those grids based on a particular field, which is actually getting done pretty fast. And also, this is one of the things I absolutely love about Kepler is how amazingly beautiful spatiotemporal maps you can create. So a quick definition of spatiotemporal maps, a spatiotemporal data is when you have both space and time linked with a particular data, which is pretty cool. So an example of this can be a trip or a practical example would be a drone data. Right. So you have a drone that you're flying around. And at, you know, when you get the data out of that drone, you actually have two components of where it was and when wasn't there. So you can use this information to create a timeline chart using Kepler, and it looks as beautiful as this. So this is actually a trip data. So you can see trips over time. It looks, you know, pretty beautiful if you can create. But as always, you know, these are not the only libraries that are there. And given the amazing community that is present in the open source world, you can actually, you know, we have like tons of libraries that you can depend on. You don't have to just, you know, you have countless libraries that what I'm trying to say. So I'm going to just explore them. So one such library is to book it. So with okay you can actually do something similar. So here I'm just, you know, importing the figure, the output file and I'm importing the tiles. I'm using carto TV styles, which is which is going to be my base map provider. And you know, I'm just creating an empty map here. I'm actually choosing my coordinate reference system, which is marketer. And also I'm providing the range of the X and Y, which is, you know, pretty interesting and is not a feature that you have in the other libraries. But everything you you you get something new out of it, you know, it's not all the same. And, you know, it, it's good to actually explore this, it's actually fun to explore these libraries, you know, and how people are doing the same thing, but in really different and really amazing and also we have a plot, a plot least a plot lead bouquet are not just for maps, but but for you know, just basic interactive plots. And also we have all there. So over here with partly I'm actually using partly express so that this code is a little smaller with partly it gets a little bigger. So with partly express I'm importing the car share data set, and I'm creating a scatter map box plot by just passing the data frame, the latitude longitude, the color and the size. So here actually, this is pretty cool because I'm able to represent more than I would be able to represent normally. So I'm using color to represent a feature, and I'm using the size to represent another feature. So I have these two features complementing each other on the same map. So this is really useful in cases where you want to, you know, spot correlation between two events happening, link to the same spatial component at the same time. So it's cool that you can do this with plotting. This talks about Geopatra, which is something I worked on on my free time, which is kind of like a hack function of all the scripts that I wrote to quickly create interactive maps, but without going to other libraries by staying in the realm of georadiary essentially. So it's something like so. So if you have not cringed yet, a Geopatra is named Geopatra because it rhymes with Cleopatra and you know, a Cleo and Geo, you know, kind of rhyme and you know, I thought I was being clever at the time. So to create a folium plot, you just import your pattern and you do the data frame dot folium dot plot and you just plot it. So it's just a single line to, you know, plot your Geo. Oh, but you know, one thing which you know even I thought myself while just writing this is, why can't they just be these scripts which I keep for myself and why does it have to be another library, it can just be a gist of, you know, functions that can you know plot digital frames, not a library, right. So again, it's not a library. It's a wrapper essentially a gigantic graph. And it's an interface and interface to interact with the existing libraries without leaving the Geopandas ecosystem. And also I have Netflix syndrome. So if you don't know what that means, Netflix gives you a lot of choices when you open the app and you know people get really overwhelmed at that choice and it's really hard for you to choose something. It's the same thing for me, you know, there are these amazing libraries, you know, which complement each other. And also they are different in their own way and I don't want to choose one of them. I want all of them. So I actually want to spend more time plotting and you know spend less time googling for APIs because I have a very bad memory and I tend to forget, you know, how do I create a chloropath map, it's fully how do I create a heat map. I just keep googling and you know, for different packages and you know that sometimes gets tiring. So, oh, all right, so let me move to the documentation of Geopandas essentially. So with Geopandas, you can I'm actually just taking these two data frames out and I'm creating these interactive maps. These are the geochason maps. So this documentation is at geopatra.readthetalks.io and the GitHub repository is GitHub slash Sangashnan slash Geopatra. So since my name is really weird, like, I actually get my name to be the user name in every platform that I go to. So on Twitter, on, you know, on GitHub, on every platform, I just my name. So I created geochason map with just one line. I create a circle map with just one line. I pass the parameters of the tooltip, which is named so that I hover over it actually see the name. And also I have the radius which is the radius. And you know, I fill it with the color and the fill color is red. And, you know, the zoom is, you know, 100 so that I can zoom out. So these are the chloropeth maps, which is again one line. You color by the population, instead of the GDP, but they're obviously correlated. And the tooltip is the name. So I hover over it. I see the name. I, you know, set the color. I said the zoom and I said this time. So the map clusters are again one line. I create the marker clusters. And I also have weighted model clusters, which are kind of in the experimental phase essentially. So these are the ways where you can cluster with not just points, but with value. So these two means there are two points right. So these clusters mean that when you go here, the sum of the values here, you know, account to 986. It's not essentially the number of points. And you know, they look really weird because it's not completely ready yet. I'm just playing around with things. So, and also, of course, we have the heat maps that are always there. And, you know, this is what I'm actually excited about, which is Kepler. I also have a way to create an interactive map, which is a single line, which is, you know, again, the data frame dot Kepler dot plot. And you know, it creates this map for me. So I'm actually controlling the config of Kepler with, you know, a ginger template essentially. So the parameters you pass here just replace those prebuilt templates which are there. You know, it's pretty easy to plot them actually. And also, to create a simple polygon. I pass the color, I pass the stroke, which are now a list of RBG, but they will not be really soon. I have a PR ready to, you know, make them into actual colors rather than passing a list of RGBs. But for now, they are. And also, I passed the stroke thickness, which is a parameter I passed the opacity. And, you know, to create this plot again. So now they are all the same color, right. I can also pass a new parameter called color field, which is the population estimate and I also pass the color scheme, which is blues. So right now, because of this, it is actually colored based on the population estimate rather than being colored arbitrarily. So, yeah, that's it for Geopatra. Thank you for coming. Okay, I'm just going to look at the questions. Okay, I have two questions. Can you talk about how Kepler is better than Mapbox since it's built on top of it. Okay. So Kepler and Mapbox are actually complementing like one is not better than the other essentially. So actually Kepler uses Mapbox internally, to be honest. Mapbox is the tile provider for Kepler. So the base maps which you see when you want to create plots on Kepler, they are all Mapbox tiles. So it's not kind of a competition but kind of complementing each other essentially. So yeah, that's that. Also, another question. Do either Folium or Kepler support non geographic map. For example, mapping a star map. I'm not, I'm not sure about Folium, but with Kepler, you can actually provide your own custom base map. So if you actually Google for it, you can actually find a map where people have plotted a baseball stadium and where they have actually modeled the whole stadium on the base map and plotted how different shots have flown, you know, the shots which were hit and the different trajectories they had gone into. So like, that was pretty cool. So, so I guess it is possible, you know, where you can pass your own custom map, you know, custom tiles and you know, create maps out of it. But it is actually pretty hard to do. But it is possible. But they are mainly present for geographic maps. That's the main use case, but it is possible to extend them and customize them. And of course the code is all open source. So all the projects I talked about are open source. Are there any map packages that also integrate AR functionality. So I assume you mean augmented reality. And to be honest, I don't know I have not worked with AR maps. I just have done stuff with your unity and euphoria, which is a pretty basic. So I'm not really sure I can actually maybe Google for it and you know, get back to you or we can discuss about it. So, okay, I think that is it. We are out of questions. Thank you very much, everyone. Thank you for joining. I hope you liked my introduction. That was something I was planning for. Thank you for being here. Thank you.
So for our next talk, we have someone special love for pandas. You know, whenever we want to essentially a location component. So a data with a location component can be represented as a also have circles. Now, to work with these whole lot of things which we can do with can understand and interpret. So in these cases, reference system, which is also used by GPS missing something. So to do interactive maps with this canvas. So to do that, we create a feature called points. So these points feature is made up all different, you know, countries and folium actually handle a lot of points is to cool looking maps with Kepler when you want to and, you know, all the lot. And, you know, to that these layers, like some of these layers are them as grids, so that, you know, the number of and when wasn't there. So you can use this interesting and is not a feature that you have in maps, but but for you know, just basic scripts that I wrote to quickly create there are these amazing libraries, you know, Geopandas essentially. So with Geopandas, you can just one line. I create a circle map with just to create an interactive map, which is a single that's it for Geopatra. Thank you for coming. Folium, but with Kepler, you can actually provide mainly present for geographic maps. That's the Thank you very much, everyone. Thank you for