# Bivariate Choropleth Maps with Arcpy

In my previous post, I showed how to prepare the data for a bivariate choropleth map using PostGIS and QGIS. I also indicated that there is a website that shows an ArcGIS tool to do it. But, this actually turns into a good opportunity to illustrate some Python, and how to create the bivariate data using Arcpy.

Arcpy is certainly not as terse as SQL, but it does get the job done, and rather easily. We just have to think about the project a little differently. The code below is a Script tool that I created.

```import arcpy, math, numpy
fc = arcpy.GetParameterAsText(0)

numrecs = int(arcpy.GetCount_management(fc).getOutput(0))

fields = arcpy.ListFields(fc, "bimode")
if len(fields) != 1:

f1 = arcpy.GetParameterAsText(1)
f2 = arcpy.GetParameterAsText(2)
fields = ['bimode',f1,f2]

var1 = arcpy.UpdateCursor(fc, sort_fields=f1)

i=1
for row in var1:
row.setValue("bimode",str(int(math.ceil((float(i) / float(numrecs)) * 3.0))))
var1.updateRow(row)
i=i+1

var2 = arcpy.UpdateCursor(fc, sort_fields=f2)

i=1
for row in var2:
row.setValue("bimode",row.getValue("bimode") + "." + str(int(math.ceil((float(i) / float(numrecs)) * 3.0))))
var2.updateRow(row)
i=i+1
```

# Maryland State GIS Conference (TuGIS)

The TuGIS training workshop on March 20, 2017 is completed – you can see the workshop evaluations below:

## The workshop evaluations are in

(if you want to cut to the chase, the workshop results are here).

I had a great time teaching our two workshops at the TuGIS conference.  In the morning, my students and I presented Spatial SQL: A Language for Geographers, and in the afternoon we taught Python for Geospatial.

We knew expectations would be high: both courses sold-out in 2 days, and we even expanded the class size to 38 people for each workshop!!  I knew that teaching 38 people would be a challenge, but it would also be a great lesson to see if we could corral so many cats into a single, technical workshop.  The workshop evaluations would be crucial to determine if we met our objectives.

The workshop evaluations were overwhelmingly positive.  For example:

1. over 90% said they enjoyed the workshop.
2. over 83% said it was much better than other GIS training they have been to.
3. on a scale of 1-10, 95% of the attendees rated the course a 7 or above.
4. 93% said they learned something new in the workshop.
5. 89% said the workshops would help them in their careers.
6. 91% said they would apply these skills to their job.

I decided to throw one curve-ball on the evaluation sheet and asked:

This was a half-day workshop. Most one-day GIS training classes cost around \$600/day. If we developed other in-depth full-day workshops on topics like this for under \$250, how likely would you be to participate in it?

it turned out that 89% of the respondents rated a 7 or higher, indicating that almost 90% of the people valued the training enough to pay \$250 for a full day course (opposed to \$600 for most GIS courses).  This means it is possible to offer really good, low cost training to GIS professionals.  Keep an eye out on this, as I am very likely to take these training classes on the road.

The comments the participants provided were great – it confirmed our belief that this was an excellent training course, and that the course needed to be expanded to 8 hours, rather than 4 hours – most everyone felt like their was simply too much information to absorb.

If you would like to see the results of the workshop evaluation, click the link below:

Finally, if you can’t make it to a live workshop, all of my video training courses are \$30 or less, when you visit www.gisadvisor.com.  These courses can’t get into the level of depth that a live course gives, but you’ll see that after thousands of students taking the courses, close to 90% of them give the course 4 starts out of 5!

# How do I do that in Arcpy

In 2004, I created a little document with my students titled How do I do that in ArcGIS/Manifold.  To our surprise, the document really took off, and had tens of thousands of downloads from all over the world.  It was that document, and the response, that got me to realize how as a Professor, I could have a far reaching impact on people learning GIS.

As the years passed, I came out with a number of other documents in the series: How do I do that in Manifold SQL, How do I do that in QGIS, and How do I do that in PostGIS.  These documents have also been used by thousands of people (although, nowhere near the reach of the original document).

So  today I am posting my latest book in the series: How do I do that in Arcpy: Illustrating Classic GIS Tasks.  I love this book: it is short and to the point, and actually provides users with code to illustrate all the commands that the USGS’s 1988 document A Process for Evaluating Geographic Information Systems said should be in any GIS.  Between Manifold, PostGIS, QGIS, and Arcpy, I can’t keep all these languages straight (the effects of aging, I suppose).  So, I keep each of these books right next to my computer for a quick reference on how to do virtually any GIS task.

I welcome you to download the .pdf and make use of it yourself with the accompanying geodatabase..  You are free of course to send it to whomever you like, but I would appreciate it if you simply provided people with a link to my site so they can see more of what I’m doing here.

If you want to learn more about how to program geospatial tasks with Python, or how to use Free and Open Source GIS like QGIS and PostGIS, check out all my courses here.  And, in celebration of the book, you can get my course Python for Geospatial for \$20 here.