Saturday, December 10, 2011

Thunderhead Explorer: Map Layer From Local Shapefile

Thunderhead Explorer: Map Layer From Local Shapefile: In this post, I will demo how to load a local shapefile from your hard drive, and overlay it on an map whose base layer is derived from a r...

Wednesday, November 16, 2011

Using ESRI arcpy GetParameter, instead of python sys.argv

There are two options for passing parameters to your python script in ArcMap.
1) Using the python sys library.
2) Using ESRI arcpy library.
grasslandSelect = sys.argv[1]
grasslandSelect = arcpy.GetParameter(0)

There are some obvious differences. Python uses the argv[0] to pass the argument of the actual python script, so the first argument entered in the command line is argv[1].
ESRI GetParameter(0) is the first parameter passed when calling the script from a Toolbox.

For the case of Boolean arguments, it is worth mentioning that sys.argv will return ,with a lower case, 'true' or 'false' while arcpy.GetParameter will return, with a capital, 'True' or 'False'. Though I had not problems complementing either(not True, not true), I did have some unidentified issues using the lower case 'true/false'

Display ArcMap Dialog Messages During Script

Easy to-do! You must, however, cast numbers with str().
arcpy.AddMessage("Total number of features: " + str(count))

Monday, November 14, 2011

Update: Arcmap Toolbox with Python Script

An initial step to publishing an ArcServer geoprocessing tool is adding the script to an ArcMap toolbox, setting the parameters for the script, and then publishing the tool.
The tool I'm developing allows for non-technical users to perform technical queries by the push of a button.
Currently, I have the tool added to a Toolbox in ArcMap. The tool takes 12 arguments from the user. 9 arguments are check-boxes, 2 arguments are values between 0 and 1, and the final argument is a feature-set(a polygon). The check-boxes allow the user to select attributes from the data-set, in a 'on/off' sort of way. To select a range of juniper density, the two arguments that take decimal numbers specify the low and high values of density. And the final argument,the feature set, allows the user to first draw a polygon around a specific area; from this specific area, all the other arguments are then used to refine the query.

For example, the screenshot below is building a query that will select: Low and High producing grassland and savanna, that are in private land, that have juniper tree density less than 25%--all within the specified polygon.

The resulting feature set selection for this query is below.


Another example, here is the result of the query (High and Low Producing Grassland, that is State Trust, with 0 to 25% juniper density--in the specified polygon).


The most unique and easily repeatable part of this tool is finding a 'range' of data. This tool could easily be applied to the whole state with respect to answering questions about slope, distance to water catchments, and possibly other density questions--like animal population density.

Wednesday, November 9, 2011

Rendering Feature Sets in ArcMap from Python

If your creating a python script that will run inside ArcMap, and the feature sets that are generated from the script must be then displayed, the basic script code is below.
Read further to see how to setup your script in an ArcToolbox.


import arcpy
from arcpy import env
import sys

#The set that I will query, it has two polygons. I will select one and then render it.
queryFset = r'C:\Development\2Test_QueryPolygon.shp'

arcpy.env.overwriteOutput = True # So the script can be repeated
arcpy.env.workspace = "in_memory" # Faster have your environment in_memory
result = "in_memory/featureSetOut" # Faster to have your result in_memory

try:
selectPoly = sys.argv[1] # Argument 1, not 0, 0 is the program itself
except:
print "\nNo arguments" # Incase your testing in the command line
selectPoly = 1

arcpy.MakeFeatureLayer_management(queryFset, "lyr") # Feature layer to do work on
queryStringAll = '\"Id\" =' + str(selectPoly) # Query String with dynamic variable
print queryStringAll
selectionOption = "NEW_SELECTION" # Select by attribute option
arcpy.SelectLayerByAttribute_management("lyr", selectionOption,queryStringAll) # The actual select by attribute method

arcpy.CopyFeatures_management("lyr", result) # Put the layer in memory (see above declaration)
featSet = arcpy.FeatureSet ("featureSet") # Geoprocessing record set object arcobject.Featureset
featSet.load(result) # Put whats it memory into the feature set

arcpy.SetParameter(1,featSet) # This is confusing, its works with '1'
# Even though 1 is the sys.argv[1]
print "exited"
print arcpy.GetMessages()



Monday, November 7, 2011

ArcGIS Viewer for Flex: Creating a Custom Widget

I tried to dive right in to making my own widget for ArcGIS Viewer for Flex, but I couldn't understand all the working parts of a larger pre-built widget--So I started with a basic tutorial.
http://resources.arcgis.com/gallery/video/arcgis-api-for-flex/details?entryID=870F152C-1422-2418-A010-7C82711FE22F

Saturday, October 29, 2011

Arizona Game and Fish, Game Unit 10: Juniper Density

Flex Viewer Widget: Juniper Density Thinning Decision System


This tool is is made to aid in the decision making process of habitat mangement.
As a way to bridge the gap between the technical manipulation of data and decision makers--this tool makes possible a graphic user interface for the application of user selections. This allows non-technical users to perform technical SQL queries by the push of a button.

Getting answers for questions about habitat improvement projects often invlove knowing geographically where a certain range of data is on a map.
Lower and upper thresholds is a common question when identifiying areas that meet environmental criteria.
This tool allows for combining layers of data and retieving only the data that satisfies a precise question.
Right now, this tool will focus on asking dynamic questions about Juniper Density, Ecotype and qualities of ecotypes, and Land Ownership.
Improvements in the tool will add the feature of performing other 'Range' specific queries.

Range specific queries include:
Where are slopes less than 20 percent?
Where is forest density greater than five percent and less than 25 percent?
Where is land that is greater than 2.5 miles from water and is owned privately?

Monday, August 8, 2011

Close of a Chapter

The cameras are back from the Arrastra Mountain Wilderness, part of Game and Fish Unit 16A. For this survey, we had no luck capturing photos of Big Horn Sheep; yet we did capture a number of burrows, javelina, skunk, squirrel, and a mountain lion--Check it out!

Saturday, August 6, 2011

Big Horn Sheep Workshop

As a way to get more understanding of the issues about Big Horn Sheep management out to the public, Arizona Game and Fish holds a Big Horn Sheep Workshop. The workshop includes a Friday education session and a Saturday boat tour from Willow Beach to the Hoover Dam. We saw around 60 sheep, 2 bald eagles, a few hot springs, waterfalls, the fish hatchery, and the Black Mountains.
Check out some of the pictures!
Big Horny, I mean Horned Sheep

We saw around 60 sheep!Look at Those Colors

Male Lamb (probably, due to blue/purple horns)
Blue Heron
Suckling
Last But Not Least
Bald Eagle

Thank you Zen Mocarski for all the awesome photos for me to share!

Friday, July 22, 2011

Why Use a Topo?

In an effort to make my own forest layers...
A topographic map is a map that depicts the features of a place ('Topo' greek for 'place') in a graphic way for the purpose of understanding more about that place. For ecological sciences, knowing where forests are is important information when trying to understand the ecology of a place.

Why use a pre-made Topo layer when you have access to many of the individual geographic features?
Have you seen a Topo map before. They are complex maps, with roads, names of places, natural features, and so on. It can be challenging to make Topo maps. Even if you have the all the data to to make a good Topo map, the companies that make Topos will still have information that I fail to have, I don't know where they get some of this stuff.

I've developed is forested regions. I was missing a crucial part of the landscape in Topo maps that I make--the Forest Layer.



'Pre-Made' Topo With Forest vs. My Topo Forest Layer:



I took satellite imagery, ran an Unsupervised classification (ISO cluster; Maximum Likelihood Classification), kept only the cells that were of a 'Forest' class. One thing I could do to improve this representation is to 'Generalize' the raster; to try to remove some of the 'Graininess/Pixelation'. Looks great on the map that I printed for our Black Footed Ferret Research Group. It makes a lot of sense when comparing it to the presence/absence layer of the Prairie Dog population too! Now to take this forest layer and compare it with of Pronghorn population data!

Grid: Data Frame Properties

One of the handiest techniques of making maps is placing a measured grid, in either lat/long or UTMs, on your map. Anyone with a GPS can figure out where they are on the map. Style preferences I follow include: Changing the 'Clip to Shape' as the current visible extent (while in layout mode), Change the label offset to 1 or 0, Change the size of the tic marks to 0 or 1, and place tic mark instead of lines inside the map.

Thursday, July 14, 2011

Sheep and Water Surveys in Game Management Unit 16A

I wouldn't wish my greatest enemy to do the surveys my partner Matt and I've been doing earlier this week. The purpose, however, is significant--determine the presence or absence of Big Horn Sheep in the Arrastra Mountain Wilderness, Game Management Unit 16A, by posting motion capturing cameras at developed and undeveloped springs.

The task was made more difficult due to the recent rains. Pools of water scattered through-out the wilderness and the weak flows in the springs made it impossible to determine a good location to post all but one camera--the terrain, too, potentially limited our ability to reach one of the springs.

Lessons were learned, with respect to understanding how to access difficult terrain in 'Wilderness'. Wilderness is a Department of Interior Statute with legal definition provided by the Wilderness Act of 1964. All mechanical forms of transportation are not allowed; therefore all roads since 1964 have been returning back to their natural state and are more difficult to find. So, to understand how to access this land it is best to research the designation and its borders from the either the National Park Service, Bureau of Land Management, Forest Service, Fish and Wild Life Service. Because I relied solely on my little understanding of the roads leading up to the wilderness boundary my partner and I started our hike straight through this rugged country--just a little more research would've made the quality of our work much easier and successful.

The hike was into Peoples Canyon. An interesting hiking designation, but can be extremely dangerous if not properly prepared. Bring topographic maps and a GPS unit--and know how to use them! This too was another lesson learned. We had the map and GPS; what we needed to do, before we left the truck, was to determine the coordinates of the trail head by referencing the maps UTM lines and using the GPS to position ourselves closer to that trail head. Thankfully, during this internship, I've learned how to place grids and graticules on a map for printing!

Wednesday, June 22, 2011

Where the Big Horn At?

We're doing some research on Big Horn Sheep this summer; and part of that work is to put up motion activated cameras at our water catchments. But before we jump into the wilderness we wanted to decide which locations would provide us with images we are looking for.

I present,
'Water Catchments, Cameras, Sheep!'

What I really like about this map is there is very few layers that are used. Layers needed include selected and and buffered slopes greater that 60% (sheep escape terrain), find the Federal 'Wilderness' data layer for the region, and waters for the survey area. Easy! Now were going to sit down and figure out the best place to put up our cameras. I wanted to get this map out quickly, so the legend does lack those finishing touches of a production grade map--but my layouts are getting cleaner!

Data Management via Maps

Government data can get pretty messy. I know, Its hard to believe; with all the projects, novice GIS users, and employment turn-over putting all the messy data to use can be hard. Yet, a good way to get my feet wet with the data is make maps--and do some cleaning house as I go.

First up,
'Juniper Tree Management on Ranch Lands'.

Alright, I'll admit it, this topographic map doesn't show juniper tree management; what happened was while I was cleaning house, improving our data collection of ranches and juniper thinning, I was asked to produce a map for a rancher (as a good gesture for him allowing us access to his property). At the very moment I was done being a good citizen and compiling 10+ layers of random ranch layer, I was asked to produce this map, my first for the department.

The key to quickly producing this topo was spending the time to clean up the data! For me, the most important part of this story is the journey.
'Ranch Topology'
In addition to spatially joining the ranch layers, and the consequent deleting of the unnecessary fields, I then performed a topological check to be sure their was no overlapping polygons nor any gaps. I do, however, have a lot to learn with topology--but a lot less after making this map.

Lets get cartographic

When people think of Geographic Information Systems (GIS) they think 'Maps'. Mostly, I think of geographic data management, development, and analysis. But 'what the people wants people gets'.

Now, working at Arizona Department of Game and Fish it is more important than ever to produce quality maps that our Game Wardens can bring with them in their trucks and our policy makers can use to make those all important connections from the data.

So, in the next few posts I will be bringing you the maps I've produced (well, at least the quality pieces).

Friday, June 10, 2011

Espee Ranch Prairie Dog Transects


With a GPS device, Prairie Dog Transects are performed by walking a line and taking waypoints on a GPS. Each waypoint is associated with a count of how many active and inactive prairie dog burrows where seen within 5' (i think it was 5 feet) of each side of the line you walk. You stay on the line by keeping an eye on your GPS device; I walked in a North and South direction at 500 meter intervals (this would be called your Easting?). So I would walk North at 12S 0365000 (Thats a UTM measurement for easting), then I would walk over 500 meters, and the walk south at 0365500--taking a waypoing every 250 meters and trying not to deviate from that line(not even by a meter). Walking a straight line in the Prairie is tough because there are very few things on the horizon to give you an idea of which direction you are walking (no i didnt have a compass--next time, but you do get good at it.)

I camped for 4 days, 3 nights, walked 40+ miles, saw 6 Prong Horn Antelope, took 210 waypoints, saw 2 Horned Lizard (one had a body as long a 6 inches), 1 1.5 foot Diamond Back rattle snake, 1,000,000 head of cattle (1,000,000,000 cow patties HA!), and met 9 new and interesting people.

The horny toad was awesome, he didn't run. And when I touched him he puffed up, pushing all of his scales out, and stood up tall. His horns on his head WERE sharp! but his ones on his sides weren't. He was really squishy like a toad.

The Pronghorn were'nt too bright...They saw me on the horizon and I saw them..Then they started running and made a great circle...which ended up less than 30 yard from me. So that was awesome.

I was really moving out there, we had a PVC pipe as a measure of whether to include a burrow or not--I also used it as a walking stick. As I was hiking along, at a quick pace, I got a thorn in my shoe, and because I was almost to the truck i didnt take the thorn out, but I did walk slower--and at that moment is when I saw the Rattler--right in front of me, slowly moving out of my way, not giving a damn as I came near...

Glad to be back at my bunkhouse, home for the summer.

First Entry 6/10/2011

I'm finishing my 3rd week with my internship at Arizona Game and Fish. My post is up here in Kingman, Arizona. Just a couple of hours from Las Vegas, and 45 minutes from the West Rim of the Grand Canyon--no I haven't gone to either. My positions is a Geographic Information System Tech.

So far my duties are:
1) The Big Horn Sheep habitat evaluation for the Game and Fish Region 3
2) Derive Polyline geometry from Pronghorn Antelope GPS waypoints
3) Perform transects in the Espee Ranch grasslands (need to determine what type of Biome this is) while counting active and inactive Prairie Dog Burrows.
4) Produce a couple of maps for recreation OHV use and Pinyon Juniper Tree management.

I surprised my supervisor by producing a GIS layer of all the land that has slopes that are greater than 60% in just a few hours--my schooling is finally paying off!

Though I am struggling at writing some Python programming scripts that derive the Polyline geometry. Most programmers know the feeling-- I feel like I'm on the cusp of getting it!