Skip to content

Instantly share code, notes, and snippets.

Keith Jenkins kgjenkins

  • Ithaca, NY
Block or report user

Report or block kgjenkins

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View readme.md

Resources for flow mapping

flowmap.blue offers a relatively easy way to create flow maps in a web browser. It's also possible to create the maps from data in a google sheet. https://flowmap.blue/in-browser

Tom Chadwin describes how he created pseudo-3d arched flow lines using QGIS https://medium.com/@tomchadwin/mapping-emotion-fighting-school-closures-with-qgis-28842661bf14

"Design principles for origin-destination flow maps", an article by Bernhard Jenny, et al. discusses all the things you'll want to think about for the cartography of a flow map.

@kgjenkins
kgjenkins / readme.md
Last active Oct 29, 2019
GeoCorr example
View readme.md

geocorr2014

Download the GeoCorr2014 table via http://mcdc.missouri.edu/applications/geocorr2014.html

  • Select a state.
  • Select the "source" and "target" geographies. (For example, if you have demographic data at the tract level, and want to map it to Voting Tabulation Districts (VTD), set VTD as the source and tract as the target. (Yes, this seems counterintuitive.)
  • Weight by population (2010 census)
  • Generate CSV file. (The report is unnecessary.)

NOTE: Unfortunately, the output doesn't include the full tract FIPS codes, so we'll need to deal with that. Here are some rows showing the geocorr columns we'll be using:

@kgjenkins
kgjenkins / readme.md
Last active Jul 23, 2019
Aggregate counts of multi-valued columns
View readme.md

Aggregate counts of multi-valued columns

Let's suppose we have a dataset of research studies conducted in various countries, and some studies are associated with multiple countries. Our studies table might have multiple comma-delimited values in the country column, and there might be spaces after some of those commas, looking something like this:

id title country
1 Study one Mauritania
2 Study two Mali
3 Study three Guinea
4 Study four Mali,Guinea
@kgjenkins
kgjenkins / readme.md
Last active May 13, 2019
Creating halftones in QGIS
View readme.md

Creating halftones in QGIS

A quick demo using a hexagon grid with a centroid fill of points sized using raster values from the image layer.

qgis-hex-halftones2

@kgjenkins
kgjenkins / readme.md
Last active May 19, 2019
Geocoding in Google Sheets
View readme.md

Geocoding in Google Sheets

The NYS GIS Program Office geocoding service can geocode structured addresses (with street number, city, zipcode, etc. in different fields) as well as freeform addresses (with everything in a single field).

This geocoder is available as an ArcGIS REST GeocodeServer, which is great if you are using Esri software, but what if you are not? Below, we'll see how to use the geocoder within Google Sheets, for an easy way to geocode addresses across New York State, without having to use any special software.

Understanding the GeocodeServer request URL

Calls to an ArcGIS GeocodeServer can be written in the form of a URL with parameters for the input address and output settings. Here is an example, broken into separate lines for readability:

@kgjenkins
kgjenkins / readme.md
Last active Apr 29, 2019
TIFF compression options
View readme.md

TIFF compression options

Summary

Realistically, especially when considering the inherent noise in the original image, I'd settle for lossy compression with COMPRESS=JPEG JPEG_QUALITY=90, which could reduce file size fairly quickly to 16% of the original.

But if lossless compression is a hard requirement, I'd probably go with COMPRESS=LZW PREDICTOR=2. However, I would want to verify that any downstream tools wolud support this sort of compression.

UPDATE: When saving with JPEG compression, further speed and size improvements are gained by adding PHOTOMETRIC=YCBCR, which uses a different color space that has even better compression. I've added new rows to the table for YCBCR, as well as .jp2 formats.

@kgjenkins
kgjenkins / gbl-dcat-alternative.md
Last active Feb 8, 2019
Alternative to using DCAT Distribution in GeoBlacklight records
View gbl-dcat-alternative.md

Alternative to using DCAT Distribution in GeoBlacklight records

DCAT is pretty complex, and I'm wondering if it perhaps is overkill for GeoBlacklight records. If we aren't planning to use the full DCAT standard (and, no, I'm not suggesting that we do), is it really that helpful to use just the DCAT distribution?

The following is an attempt to present metadata, webservices, and downloads as simply as possible, with a top-level property for each of those groupings. These groupings will make it easier to automatically render a list of metadata options, or download options, or webservices options, on the GeoBlacklight page.

Each grouping contains an array of objects which typically have just a type and a url. I've tried to keep the type values as simple as possible. The type value could be used as button or link labels in GeoBlacklight, but this could be overridden by the optional label value, which would be especially useful to distinguish multiple entries of the having the same basic `t

@kgjenkins
kgjenkins / readme.md
Last active Nov 17, 2019
Labels with callout lines in QGIS
View readme.md

Labels with callout lines in QGIS

Callouts, sometimes called leader lines, are lines between labels and features on a map. They are useful when constraints of space force a label to be moved away from the feature. The callout helps to reconnect the label to the feature it refers to.

image

There are probably multiple ways to do this, but here is one way using a geometry generator in QGIS 3.x:

@kgjenkins
kgjenkins / readme.md
Last active May 26, 2018
Interpolate points along lines using QGIS virtual layers
View readme.md

Interpolate points along lines using QGIS virtual layers

Suppose we want to interpolate a number of points along each line in a layer:

image

We have a column called stations that specifies how many points to interpolate on each line:

image

@kgjenkins
kgjenkins / readme.md
Last active Aug 6, 2018
Straighten lines in a layer using QGIS virtual layers
View readme.md

Straighten lines in a layer using QGIS virtual layers

Suppose we have a layer of wiggly lines (black), and we want to straighten the lines (blue):

image

We can use QGIS virtual layers to create a new layer of straightened lines:

select
  make_line(start_point(geometry), end_point(geometry)) as geometry,
You can’t perform that action at this time.