Thursday, August 30, 2012

GIS 4930 Project 1 - Statistical Analysis with ArcGIS


For our first project of this new semester, we will be looking for information to help law enforcement determine potential hotspots for meth activities.

Or task this week was to create our Base Map of the Study Area, as well as generate outrIntroduction/Background information.   We also had to do a Process Summary and provide the results of that work. 

Here is my base map:


Here is Section 3 of my Process Summary:

Prepping the Census Data: Programming with Python
Include notes in this section about how and why to prepare your script in python.
1) Added the CensusTracts data to a new MXD
2) Opened the attribute table
3) Added field pcntPopGro as Float
4)  Used the field calculator to set this to (( [POP2010] - [POP2000]) / [POP2000]) * 100
5) Added field pcntWhite as float and used field calculator to set it to ( [WHITE] / ( [WHITE]+ [BLACK]+ [AMERI_ES]+ [ASIAN]+ [HAWN_PI] + [OTHER] + [MULT_RACE] + [HISPANIC])) * 100
6) Added field Roomates as float ans set to be( [HOUSEHOLDS] - [HSEHLD_1_M] - [HSEHLD_1_F] - [MARHH_CHD] - [MARHH_NO_C] - [MHH_CHILD] - [FHH_CHILD])
7) Next we opened up the AddCalcFieldsShell.py script in IDLE
8) Set my workspace to point to S:\GIS4930-GISSpecialTopics\Project1\Project1Data.gdb so the whole line is :   env.workspace = r'S:\GIS4930-GISSpecialTopics\Project1\Project1Data.gdb'
9) Prepared the last 5 lines as follows:
# pcnt40_49
arcpy.CalculateField_management(censusFC,"pcnt40_49","([AGE_40_49]/[POP2000])*100", "VB")
# pcnt50_64
arcpy.CalculateField_management(censusFC,"pcnt50_64","([AGE_50_64]/[POP2000])*100", "VB")
# pcnt65_UP
arcpy.CalculateField_management(censusFC,"pcnt65_UP","([AGE_65_UP]/[POP2000])*100", "VB")
# M_F_Ratio
arcpy.CalculateField_management(censusFC,"M_F_Ratio","([MALES]/[FEMALES])", "VB")
# pcntUnEdu
arcpy.CalculateField_management(censusFC,"pcntUnEdu","([NotHSGrad]/[EduPop]) * 100", "VB")
10) Saved the MXD, closed ArcGIS and ArcCatalog then ran the script.
11) I had one typo in my script so fixed that and reran it.
12) Opened up ArcCatalog to make sure it looked right.   I wasn’t sure if we needed to multiply by 100 on the male female ratio since it is a ratio rather than a percentage.    I decided I can always multiply by 100 down the road if the lab leads me that way.
13) Looks like all fields were created and populated


Part 2: Join Meth Labs to Census Blocks
Include notes in this section about how and why it was important to join the meth lab and census data. Explain any edits you had to make to the data.
1) Opened up my MXD Again
2) Opened the Spatial Join tool from the Analysis toolbox
3) Verified results
4) This created CensusTract_SpatialJoin layer which has the Join_Count field in it
5) Created a new field called LabDensity as type Float
6) Set this using Field Calculator to equal [Join_Count]/ [SqMile]
7) I found the properties page to be an easier way to toggle fields on and off:

Thursday, August 9, 2012

GIS 4048 Final Project Presentation

For my Final Project, I chose to use GIS to help decide where to place a new dog park in Leon County, Florida to best serve the population.

For this project we had to create a Process Summary, a PowerPoint Presentation (along with supporting maps) as well as a Slide by Slide summary in PDF form.

Link to Slide by Slide Summary

Link to PowerPoint Presentation

I experimented with ArcGIS Explorer Online for Extra Credit, but was unable to get the presentation to a point where I was happy enough with it to turn it in.   The Raster files especially were giving me trouble and I had too much extraneous things going on to dive into it any deeper.  


Friday, August 3, 2012

Module 8 - Cursors....

My Ever-Growing GIS/Programming Library
This module was an excellent view of cursors.   Cursors are essential to the toolbox of any programmer that works with data of any sort.   I was surprised to see the similarities in concept to the T-SQL environment of Microsoft SQL Server.

Notes to Future Self:
  • When debugging, remember not only to look at the line(s) of code where you THINK the problem is, but also at other lines that may execute.  I ran into a problem where I was convinced that the UpdateCursor just wasn’t working and then I went back a few lines and saw that my “query” was limiting the results that the operation was running.

  • When debugging, it is helpful to comment out lines and re-add them in smaller quantities to focus in like a laser on the area you are concerned with.
  • Also when debugging, remember to try various ways of running the program… PythonWin, IDLE, and by double clicking the script.   Insight might be gained from each one of these attemps.
  • Don’t reinvent the wheel…   The ArcGIS Online Help is GREAT on each command, including code snippets that might help as well.   Also, be sure to be competent at using your search engine of choice to look up both arcpy as well as general python fixes to get around any issues you are experiencing.

Saturday, July 28, 2012

Module 7 - Listing Tools

This week’s lesson taught us some skills that will prove to be essential to our success in the real world. We learned how to formulate our approach to creating a solution by asking some questions about the problem. 
We learned skills such as path manipulation, DESCRIBE methods, Listing tools, Usage methods, and even learned how to check and toggle license usage.
Notes to Future Self:

  • When struggling with one of the tools try it in different editors to get further hints.   I had problems with the ExtractByMask function in Python Win, and couldn’t figure out why it would work in the Interactive and even in IDLE.    Turns out I needed to have my Scratch workspace defined.   Once I match my code to have the same scratch as my ArcGIS environment variable had, it was much more reliable.
  • Use the Online Help.   When working on a tool it is great to use the online help to grab code from.   No need to reinvent the wheel if they already have a working version of it.
  • When you get frustrated, walk away for a bit…   You’ll be surprised when the idea comes to you (hint: it usually isn’t when you are conveniently near a computer….)
  • Break down tasks to their simplest elements.   When working with the ExtractByMask, I ended up having to create a separate Python script to try to use just the bare minimums to get the function to run to a hard coded file.    I took the lessons learned here back to my assignment.
  • I found this assignment to be great system for using the data that we learned in the exercises.   I struggled at points, but kept at it and was able to finally make the program work.   That is tough to find assignments that are tough, but not impossible and I think this week was a good example of the challenge level that the assignments should present.
  • One problem I had with the lab was on page 3 where it asked us to save a raster out to the GDB with a period in the file name.   I was unable to do this, so just left the .TIF of the file name.

Saturday, July 21, 2012

Urban Planning: Location Descriptions

This week's assignment helped us use criteria provided by a couple to determine the optimal choice of neighborhood to live in when moving to Alachua county, Florida.    We were tasked with providing 3 maps, a basemap, a map showing the 4 criteria (proximity to hospital, proximity to UF, percentage of population between age 40-49, and median house value), and a final map which took these multriple considerations into account.





Process Summary

From the “Step 4: Analysis” major section, include your process for Steps 7 and 8 (weighted analysis).
1) Saved my Location2 as Location3.mxd
2) Removed all data frames (Adding a new frame and importing the Projection information first)
3) Added the 3 feature classes that we created in the previous section to the MXD (hosp, school, rightage, and value)
4) Cleaned up the symbology for these layers
5) Started Model Builder
6) Added the 4 feature classes to Model Builder
7) Added the Weighted Overlay tool to the model
8) Connected the 4 feature classes to the Weighted Overlay box
9) Answered Q13
10) Answered Q14
11) Answered Q15
12) Answered Q16
13) Made sure the scale was set in the correct (reverse) order
14) Note: when reordering the scale you have to be sure that it doesn’t retain the last value rather than replacing it with the first value.
15) Gave each feature class a 25% weight
16) Gave the output the name WEIGHT1 and stored in the GeoDatabase
17) Ran the model
18) Added Weight 1 to the display and closed the model
19) Added Places to the mxd
20) Added Sel_tracts and made hollow
21) Added the school and hospital to the project and symbolized accordingly
22) Selected the three best areas that met the criteria and exported them out as Weight1Best3
23) Set up my model with the revised parameters making sure that my scales were set properly.
24) Set up the map layout
25) Answered Q17


Sunday, July 15, 2012

GIS Programming - Module 6 Assignment

I am still polishing some of the code required for this week's assignment, but wanted to go ahead an make my blog posting about some of the "Lessons Learned"

PART III: Module Summary
Write a summary of what you learned this Module. Try to come up with specifics from each exercise and assignment. List any problems (and fixes) you encountered, and any other notes you feel would be helpful to your ‘future-self’. Post this summary to your blog.

Lessons Learned:
Exercise 6a:
  • It is important to understand the pros and cons of relative and absolute paths (especially in terms of sharing your data with others)
  • Relative paths cannot span multiple drives
  • Absolute paths work best on static data
  • Relative pathnames work best when sharing data (remember you have to provide the data as well!)

Exercise 6b:
  • You can effectively share data with others by proper directory planning and relative paths.

Exercise 6c:
  • It is common to provide users with the tools and scripts in addition to the data
  • A recommended folder structure should have a data, scripts, scratch, and docs subdirectory
  • Getting messages out to the results window can be done with the arcpy.AddMessage() function
  • The ArcGIS tools have a section of their help documentation dedicated to sample code snippets
  • Password protection of embedded code is a great feature to help programmers maintain intellectual property (or keep the so called “power users” from messing up your code then entering a help desk ticket, but I digress….)

Exercise 6d:
  • Packaging data to deliver to clients is pretty straightforward in ArcGIS 10.x
  • You can use the Consolidate Map tool (which stores the references to data)
  • You can use the Package Map tool (which stores the data itself).   Think of the benefits of this when you are in the field with a laptop 20 miles from the nearest cell phone tower….

Assignment
The assignment felt like the real world kinds of things I need to do every day which is:
  • Understand the assignment
  • Research the tools
  • Struggle through a couple of false starts
  • Have that “a ha” moment where things start clicking

Saturday, July 14, 2012

Urban Planning - GIS for Local Government

This week's multipart exercise had a lot of interesting aspects to it.   Having been around offices that have dealings with parcel information, I can vouch for the usefulness of this type of knowledge.

Without further delay, here are some of my maps from this week's assignment:



Process Summary:
OBJECTIVE 2:
1) Created a new blank MXD and saved as Parcels.mxd
2) Added the Parcels Feature Class from the results.gdb
3) Looked at the attributes and noticed the owner names are missing.
4) Opened the CSV in Excel and deleted the last column since it is unsupported.
5) Saved and closed the CSV
6) Added the CSV to the map
7) I had some problems on my join until I renamed the PARCEL field in Excel to PARCELID.  Then my join seemed to work properly.
8) Exported my join out to the Results.gdb as Parcels_Join
9) Selected the key parcel by attribute and exported it as Zuko_Parcel to the Results.gdb
10) Did a select by location to choose all the parcels that intersected our parcel.  Answered Q10
11) Exported these out as ADJ_Parcels
12) Added the zoning feature class
13) Clipped the zoning feature class to the adjacent parcels
14) Created the Parcels_Zone feature class by using the Intersect tool
15) Anseered Q11
16) Added a MAPKEY Field to the table and set it to be the same value as the OBJECTID_1 field
17) Having a problem because when I intersect the Adjacent Parcels and the Zoning, I end up with 25 features instead of 9.   Most of the excess are small slivers where the polygons don’t quite match up.
18) I was able to get around this in an unusual way.   I created a JOIN on my Adjacent Parcels with the Parcels_Zone feature class using the MAPKEY field.   This gave me the ZONING info I needed.   Not sure if this was the best approach overall, but it worked in this case.
19) Update, it didn’t work in this case.   The zoning appears to be wrong
20) I finally had to move past this problem by setting a tolerance of 5 feet which returned 10 records (Two for parcel 9)    I deleted the smaller of these parcels to get down to my count of 9.    Still not sure why this was the case, but needed to move on.
21) Added all my required map elements to prepare for deliverable
OBJECTIVE 3:
1) Saved the MXD as Zoning_DDP to start next section
2) Ran the Grid Index Features from the Data Driven Pages part of the Cartography Tools and got my 24 results
3) Ran the Select by location to weed these indexes down to 12
4) Exported these records out to a Zoning_Index table
5) Added my zone descriptions to the table
6) Created a new Data Frame to separate the index from the content
7) Added the Data Driven Pages toolbar
8) Ran the Data Driven Pages Setup wizard
9) Added the Page number Dynamic Text
10) Added the locator map and set the properties to see which section we are currently working on.
11) Added dynamic text for a few fields
12) Added my Required Map Elements
13) Exported out to a PDF for all 24 pages.
14) I noticed that it changed the settings on my scale bare from .1 to .11 which I don’t like.   Not sure how to fix this problem unfortunately.   I look at my original document and it still shows .1