Directus comes with numerous types of geospatial data presentation. In this episode, Carmen will walk you through the different fields and how to use them.
Speaker 0: This is my Directus project for tracking all of my hiking activity. And as you can see, I've got a collection called hikes, which is currently empty. Let's take a look at its structure by going to settings, data model, and hikes. Now here we can see we've got two fields in our hikes collection, but I'd love to show on a map where my hike took place. So what we're going to do is create a new field, make it of type map, and call it location.
And we can see right now that the type is set to point. But as it turns out, there's lots of types of map data. And in this episode, we're gonna cover each and every one of them. So let's start with point. I'm gonna save this field and then go and create a hike.
Gonna click Gonna click on create item. Date set to today. And I'll set my location to be in this part of Vienna. So that's what the point type is. It lets us set a single point on a map.
If we take a look at our collection, we'll see we have our type set to point and our coordinates set to these coordinates. Of course, this doesn't look as nice, but we'll cover the layout thereof in another episode. But a point is nice, but a hike is more of a, you know, a journey along a line. What I'm gonna do is create that map type location again, but this time set the type to line string. Go ahead and save that.
And let's try again. Set the date to today and go for a hike somewhere in France. And what I can do is by setting a certain number of points, create this line that indicates my hiking journey. So now we can see that we have a series of coordinates, which is good. But what about the other types?
Let's once again create that location field and this time set the type to be a polygon. Let's go to Slovakia. So what I can do here is once again, by clicking around, I can now set a polygon to denote which area I've covered with my hike. Go ahead and save that. And we can see once again, the coordinates are set accordingly.
Now let's try the multi point type. Go ahead and create a new hike. Now with multi point, I can set a variety of points. Next, let's try the multiline string. Let's go to The United States.
Now with a multiline string similar to the line string itself I can now have several strings. The multi polygon location allows us to create multiple polygons on a map. Let's give that a try. Let's go to Argentina. And as you can see, I can create multiple polygons in a map.
Let's try the geometry all option. I'm going to save this and create a new hike. Now what the geography all option lets you do is mark all kinds of points. So we can have points, we can have polygons, and we can have lines. Let's cover what the rest of the types look like.
First, there's json. And json looks exactly like a geometry all object, but stored as json. A string is also a geometry all object stored as a string of characters, a text. You guessed it. Also a geometry all object, but stored as text.
And CSV is a geometry object but stored as CSV or comma separated values. How can I best store my hike? Now, as we said towards the beginning of this, the line string is really going to be my best bet because it's a series of points that I follow during my hike. So these are the different types in which we can store that GeoJSON mapping data in DirectUs.