Random bin

This is a place for me to dump some of my uncategorized work, links to other great content creators, and other neat resources I’ve found along my way.


Dev tools

GIS Resources

Next, a few R specific/centric resources:

These R enabled books are excellent resources:

Fun folks

Neat youtubes

  • 3Blue1Brown is absolutely amazing. I wish this was available when I was sitting through math, and consider this mandatory viewing.
  • The Surface Dynamics Modeling Lab out of the University of Alabama has an excellent archive of invited speaker talks and tutorials.
  • PBS Space Time puts together physics-centric videos that revolve around, well, space and time.
  • Numberphile covers interesting or otherwise unique aspects of math in a casual but informative way.
  • My inner film major loves the overly analyzed aspects film covered in Every Frame a Painting.
  • Capitan Disillusion does a phenomenal job explaining digital concepts and demonstrating how modern CGI can be used.
  • The CUAHSI channel features many of their recorded webinars.
  • Finally, Apetor can teach us all a little something about the wonder of life.

Thesis leftovers

  • A misguided attempt at a website for my masters. Placed here more to remind me to do something with it one of these days: https://sites.google.com/site/globalsnowobservatory/
  • A post about Mann Kendall and Sens slope in GEE from me. At some point I’ll get around to doing something with this too.

Need data?

Cartographic line data: http://www.projectlinework.org/
Base imagery: https://www.naturalearthdata.com/downloads/10m-raster-data/
Topo resources: http://www.earthpoint.us/TopoMap.aspx
Water resources: https://www.hydroshare.org/landingPage/
Earth as art: https://eros.usgs.gov/image-gallery/earth-as-art


Random education bits

Tutorials:


ClusteR

imcenter
See the github: https://github.com/JimColl/clusteR or it’s companion on my website: https://jimcoll.github.io/random/

About:

A tool to add points to a map from csv or shapefile, and interactively cluster them as you see fit, this GUI driven, geographic database display and clustering application built is built on R. Is also a nearly minimal example of how to tie map and database together, how reactive shiny elements work, and how to print dashboards. A project that grew out of a request to see a database from a geographic prospective, here is a FOSS implementation of GIS for people who don’t know or have the time to learn it.

Features

  • GUI driven interface to select csv or shapefile database.
  • Use drop downs how to cluster (currently broken), color, and label the points.
  • Edit the table view of the database and optionally save the database back out.
    • Click on a table entry to zoom to the location
  • Fully reactive map and editing
    imcenter

How to run:

The “installation” of this is program is trivially easy by design and requires no permissions. To start the process:

  1. Download and unzip this repository using the green “Clone or download” button.
  2. Select a csv or a shapefile, enter the LAT LON and EPSG fields as necessary. Replace spaces with.
  3. and hit run!

A test dataset is included in the data folder. To “uninstall”, just delete the folder. Pandoc and PhantomJS are also installed, and may be removed through the add or remove programs system dialog and the user/AppData/Roaming folder respectively.

Known bugs:

  • Selecting fields which are too long or numeric will currently kill the crab. To recover, close the window and re run the HTA.
  • Map and data don’t wrap smoothly.
    • Fly to (when you click on a row) will sometimes cause the server to lock up. To fix, zoom in a bit before attempting to fly.
  • Legends can be too large for the window.
  • Print button works but output is gross.
    • Map legends are also not printed.
    • Pandoc needs to restart after being installed, so attempting to print after the installation will break the server. This will only happen when you first run clusteR. To recover, close the window and re run the HTA.
  • Editing the table is not fully tested.
    • Shapefile editing broken.

The worst lines of code I’ve ever written:

A fun(?) section more for me than for anything else to showcase how grossly incompetent I am at actually getting a computer to do what I want.

R

mybbox <- raster::extent(sf::st_buffer(
	x=xx$mapindex.poly[subset(xx$address.point, eval(parse(text = names(xx$flood.grid)[timestep]))>0),][xx$mapindex.poly[subset(xx$address.point, eval(parse(text = names(xx$flood.grid)[timestep]))>0),]$`Index Label`==index,],
	dist=0.00005,
	nQuadSegs=1,
	endCapStyle="SQUARE",
	joinStyle="ROUND",
	mitreLimit=1,
	singleSide=FALSE))

The mapping side of FOSSFlood is a bit wild, but this line takes the lead. I needed a slightly larger bounding box from the index that a user wants to view so that I could fly to it. However, these indexes aren’t necessarily the same for each time step, so the subset got that eval(parse()) function, inside a buffer, and because it’s all temporary this made sense (at the time) to do in the single step you see here.

Python

for x in np.nditer(branch_GRIDCODES_lookup):
	for y in np.array([[x]])[0][0][0].split(","):
		if int(y)==mat_num:
			branch_num = np.array([[x]])[0][0][1]

This chuck, called iteratively in a for loop, looks at all the grid codes for a given fldpln library and, for a given mat file returns the branch code for that mat file, all so I can eventually stich them together in a numpy array. I have a hate-love-hate relationship with Python….

GEE (JavaScript)

if(SpaceSelectValue == "stdDev") {
      results = ee.ImageCollection(app.MODDef)
                  .select(stringSeperator,LCtoUse)
                  .map(function(image) {
        return image.reduceRegions({
          collection: AOI.geometry(),
          reducer: ee.Reducer.stdDev().group({
            groupField: 1,
            groupName: "code",
          }),
          scale: resultsScale
        }).map(function(f) {
          // Process the grouped results from list of dictionaries to dictionary.
          var dict = ee.List(f.get("groups")).map(function(group) {
            group = ee.Dictionary(group).combine(ee.Dictionary({code:99,stdDev:[null]}), false);
            var code = ee.Number(group.get("code")).format("code_%d");
            var stdDev = group.get("stdDev");
            return [code, stdDev];
          });
          dict = ee.Dictionary(dict.flatten());
          // Add a date property to each output feature.
          return f.set("date YYYY-MM-dd", image.date().format("YYYY-MM-dd"))
                  .set("system:time_start", image.date().millis())
                  .set(dict)
                  .set("groups", null);
        });
      });

A lot of my JavaScript is pretty repetitive as a result of my poor skills and a sub par understanding of client-server interactions. Although this isn’t the most egregious example, it is repeated in TEAM no less than 7 times with minor changes for each statistic of aggregation.