dr. erin n. bush

historian of u.s. crime & punishment. digital research methods.

Getting Ready to Map

I started the evening ready to tutorialize myself in Google APIs and mapping examples. I read two paragraphs and realized that I’d better do some prep work on my own data before I continue.

I also realized that I can organize myself better if I set some goals for my coding work. I have one goal this week: Successfully map all the executions in the database with fancy little popup boxes showing the details for each state. That’s it.

Once I get that to work, for my tutorial in two weeks, I’ll drill down into Virginia, Maryland and DC to show more detailed local information. But, don’t let me get ahead of myself.

On the prepping side, every tutorial I looked at pleaded with the reader NOT to geocode the latitude and longitude information on the server, but to do it in the source database whenever possible.  Since I only have 51 states to deal with and the information is static, adding in lat/long for each execution in the database wasn’t going to require that much brain damage. I created a new table of state lat/long information and populated the appropriate general state lat/long information. [Like everything I do in phpMyAdmin, I did one state by hand and looked at the SQL commands to replicate for the other 50 states. (After 8 weeks, I am beginning to realize that I learn by trial and error–useful, but incredibly frustrating.)] Per Google’s request, I created my lat and long fields in the new table as FLOATS with the size of (10,6), which will allow me to store 6 digits after the decimal, plus up to 4 digits before the decimal, e.g. -123.456789 degrees. I then joined this new table to my main executions table with a new foreign key between my original executions table and the id from the statelatlong table.

I then needed to make sure I actually understood how to JOIN these tables, so I walked through a tutorial (on Wikipedia nobles), replaced their fields with my own and TA DA! it worked. For reference, all the information in the results, save lat and long, are located in my original table. The lat long coordinates are stored in the new table. (The code I used is here on my github.)

Now I feel like I’m ready to actually start trying to get my maps to work… the results of which, I’ll describe in a new post. Once I get there.

Share:

Asking Questions of Your Data

Now that my data is normalized and I have a good idea of what is contained in my database, it’s time to start asking questions of my data. What do I want to know? Which queries are only for me? Which would I like to embed into a web page? While they don’t seem like tough questions, it is beginning to dawn on me that my issues with PHP may be more than just a learning curve. It isn’t so much the learning of the language (although, I am struggling with that), it’s also the fact that I don’t sit down and think about what I want it to do BEFORE I start coding.

I dive right in, copy examples and start changing variables and functions without even thinking about what I want it to do, let alone what this code snippet was programmed to do. The maddening part of PHP is that it’s so personal and subjective–each coder has written into the code their own logic and language. What is mine?

<crickets>

Honestly, I don’t know. I do know the questions I want to ask.

  1. How many women were executed in the United States?
  2. For what crimes? (Cluster the crimes)
  3. In what states? (Cluster both the state numbers AND the crimes by state)
  4. Are there any moments in time where there were an abnormally large group of women executed?
  5. Are there any states in which more women were executed over others?
  6. What of Virginia? What happened here?
  7. What overall trends can I see?
  8. What is missing?

Some of these questions are really specific and easy to both code and show. Others are not. All of this is to say that I’m still working on figuring this out. I admit that this “paralysis by analysis” affected my productivity this week. My output wasn’t what I had been hoping. Still, this is all part of the process, right? Right?

Share:

PHP Tango

Oh PHP. How you vex me.

Our assignment this week was to play with PHP, specifically to create a working data entry form using HTML, PHP and MySQL. I can report that, with very generous help from my Clio class, I did all of that.

My simple, but working form is here.
My simple, but functional PHP code is here.

I’m still not sure I totally understand WHY it works. I am told this is natural and to be expected. That with time and increased familiarity, my comprehension will improve. I look forward to that day. I will continue to plug away at it if you promise me you won’t judge or mock me for doing a happy dance every time I can actually make something work.

Deal?

Share: