All right folks, this is Mr. Fugu; are you watching Mr. Fugu Data
Science. If you want the code, it will be provided on my Github
Mr. Fugu Data Science. If you want to show some support? Follow me on
Twitter: contact me "@MrfuguDatasci". Now, we are doing a follow up.
of our last video here. Where we have some mineral data, this is a three
series of pieces You are watching the second part; where we are converting this data into
adjacency lists and trend research. Now let's see where we left off
the last time we created a condensed or "consolidated"
mineral list. Okay, now we take this list and link it together
in our existing data frame. This is here. What we were doing was saying
Very well: we took this data. I shouldn't have got this right; but okay, we take
this data and we have to say if we have, say "uranium", this is happening somewhere
one more of these lines? Very well, then we say well: it happened in ten thousand and three
One hundred and sixty-six lines, well, that's perfect.
Well, I was having trouble figuring out if this is printing anything else
How fake? Which is why I had to do this to make sure I did it.
correctly. Now notice: we have many columns, we have a hundred and sixty
eight columns, those are some pretty broad data. But it is also quite long. Yours
three hundred four thousand six hundred and thirty-two lines
A small, decent-sized data set. We have to take this data and convert it.
frame in a JSON object now. We will do this by creating this DF function
- GeoJSON. Where we include our parameters as our parameters, the properties
we would like to add to this file, in addition to longitude and latitude. you
will go through your dictionary: your data frame as
THE?? that is why the dictionary has this as its key-value pairs. If you are
unfamiliar with the GeoJSON format, you can search Wikipedia and it will show
that you have a nested JavaScript dictionary. Where do you say well?
we have our type, we have a collection of characteristics, within our type. We have a key
resources that are creating a list where we have our geometry that stores our
Dice. Which, in our case, will be important, but they can be polygons that I will show you
later. And our latitude and longitude coordinates. So we say well, let's iterate
through the creation of a variable called "feature" where we say well, this goes through our
type; the kind where we go to properties and create our dictionary. Inside of
that we say well, let's take our geometry where we are taking our point
data and store our latitude and longitude. and we say well, great, now
take this and then we need to add it accordingly. From outside to
inside. So we start in geometry, then we enter and enter coordinates, we start
geometry comes in, make our coordinates. Perfect, so we have to iterate
It is. and say ok, this takes our little function variable and let's
a set of properties iterates and adds there. It's ok
we will understand this, so this is what is happening here.
THE?? this is what we are adding separately that you will see. So we said it all
At this moment, we have our characteristic as a key; and attach our list of features. So we
he said ok, here are our resources and now we are adding our list: where
everything else goes into it. Great and then we return our
GeoJSON object. We take a list of the columns that we decided we're going to
we covered that and put here what is the "site name", "state", "merchandise1",
'country', 'latitude' and 'longitude'. And I could expand that to any
required parameters and you can say it's okay, now let's create this and take our
data frame in our call names and we'll store it, perfect. So we print this out
take a look at our resources and say what is it really like? So
we could see that it really worked. and when you actually perform this function
and save that. It takes a minute or two. It takes a while to iterate
through that nested list, sorry, "nested dictionary". So, here are our properties.
there is the name of the site, there is the state, basic product, country, latitude, longitude
our point data and our coordinates. So he does this to the next one and continues
going, perfect! So now I say well, let me choose arbitrarily some kind of
item to do some benchmarking work and see how it works. So I say
Okay, let me take urine. Find all the other uranium available
store this, from our data board as urine. So I was just lazy and alone
Storing that said is my alias DF is to underline uranium (df_ = uranium). throw it to our
"GeoJSON DF function" and then print and say ok
I have now discovered that all good has uranium. If you see uranium and others
accompanying mineral elements, metals and
such. So I said that everything is fine, so we know that this is working. Now I have to take a look
we will call it "GeoJSON world spot", which is this file. and is a GeoJSON
format as well. and basically what this is about are all countries in the
world, where your point data is now a lot of points considered a polygon. y
This polygon is creating the outer perimeter of the appearance of countries
I like. So, it’s like joining several points and creating a
object there. and these are the points of these things in Afghanistan and
Angola and etc. So take this, it would be used for our plot later. y
We need to read this file. So we go inside the characteristics, and we are iterating
through this file. and what we’re doing is making a comparison of all
letter of the country name in the global GeoJSON file and compare it with the
Mineral deposit countries. Okay and then you're saying ok, there you go
an error generated if our files do not match. So we
he said ok, great. So we say well, if they really are
so that put them in our dictionary. Okay, and then I say
I need to open or apologize for "writing" a separate file now called "mineral
GeoSON countries "and dump this file. Now, we're just creating with everything
we did it here, so everything after the store and everything is fine. So
stores it as a file and then we’ll reread it so we can use
that. From the "mineral data file" compared to the "GeoJSON world". That is all
from countries that were not available for data that we can use to plot.
Mainly because most of the data we are receiving is from the United States
Geological Services (USGS). So we say well, now we could do a little
track with a "bokeh". and stay well, you see what's going on there
let's go here; and we were going to use uranium data. and we look great
little thing called a "scroll tool" and it's basically like a cursor that
hangs over everything. I’ll show you what’s going on and one thing you should know
that there are some errors in the data with the labeling.and if there were no
tag, as long as your exit is a question mark "?". and you will see in a second
say Open our geo JSON mineral or "save" a "geoJSON mineral file"
and basically we are pulling basically we are dumping this file that we are
rereading as a GeoJSON data source. So I have to call "Bokeh"
these tools: pan, wheel, zoom, box, zoom reset and lock. OK genius
so i create a title, for my figure, insert the tools we are using. I am
does not create a "Y" and "x" access location. I created the size of our
height and width for our frame and then i will not have any color and if
if you're creating a grid and the patches we're adding. > Your source is
it will be your geojson data source that you are calling. so this is what
Is the source of the word ok and then the "Geosource" is what we're going to
be using for our little dots everywhere. Here I will show you
These are like the names of places in the United States. See some of them working some of
They do not just depend on what has been marked. and you are adding here what
you want it to appear on the scroll tool. Could you expand more parameters
what you put inside your GeoJSON material, I don’t remember the order of it
but, one of them is what you are calling the GeoJSON file. The other is
what is your nickname as a name? I don’t remember the order and that’s what
happening here as you see, most of them are in the United States. then it is
Okay, it works. Oh, well, something is being processed and locked up mine
computer why is this happening ok, so let's stop the video here. y
Then, the video will cause the adjacency list to end with a few
more plot and then we’ll call it good. So, I want to say "thank you" for
Lurk! I hope you enjoyed this video. Please get my Github code and
As always, like it if you think this is a good comment. Please sign in"
and even the next video. Goodbye