There are plenty of ways to get spatial data from a PostGIS database into a Processing sketch.
You can export to CSV or SVG and load it from there; you can query the database directly; or, depending on context, you might choose to generate Processing commands directly, which is the route I went to display a background map of the UK in a recent visualization project.
Need to protect something with a passcode in an iPhone app you’re developing?
Then you may find my MIT-licensed passcode view controller — as seen in the mappiness app and in the short screencast below — of use.
See Github for the code and (scant) documentation.
Imagine you want compare various locations in terms of the availability of a certain type of environment, such as fresh water.
You might want to use a measure of the proximity of that environment — such as the nearest neighbour distance.
You might want to use a measure of the quantity of that environment in the vicinity — such as the proportion of land within a specific radius that is of that type.
Or you might ideally like a measure that combines both of these: one that incorporates the quantity of that environment, but gives greater weight to areas that are nearer, and lesser weight to those that are further away.
In that third case, what you probably want is a kernel-weighted proportion.
Updated May 2012 for Lion
The secret to getting the MySQL gem to install and function with Ruby 1.9.x on Snow Leopard or Lion is:
- Install MySQL using the 64-bit .DMG package installer from dev.mysql.com
- Install Ruby using RVM or (preferably) rbenv
- Add these to lines to
export PATH="/usr/local/mysql/bin:$PATH" export DYLD_LIBRARY_PATH="/usr/local/mysql/lib:$DYLD_LIBRARY_PATH"
- In a new shell (Terminal window), type
gem install mysqlas normal.
I’m posting this mainly as a record for myself, having wasted a lot of time in the past trying strange incantations from comments on various other blogs posts.
Ever noticed how, in Google Earth, marker pins that overlap each other spring apart gracefully when you click them, so you can pick the one you meant?
And ever noticed how, when using the Google Maps API, the exact same thing doesn’t happen?
This code makes Google Maps API version 3 map markers behave in that Google Earth way. Small numbers of markers (up to 8, configurable) spiderfy into a circle. Larger numbers fan out into a (more space-efficient) spiral.
This post from June 2011 was updated in November 2011 and January 2012.
This recipe makes wonderful bread: crusty, open-textured, moist, and beautiful.
It needs no kneading, but this doesn’t imply any sort of trade-off. It’s a recipe for a perfect loaf which happens to be effortless, and an effortless recipe which happens to make a perfect loaf.
It’s based on Jim Lahey’s recipe from the New York Times in 2006 (also the subject of an article and accompanying video, and now a full-length book). But it’s even easier, as there’s no awkward middle stage with linen cloths.
In the eight months since we started using it, we’ve made virtually all our own bread.
Here’s a less generic and slightly different nearest-neighbour function based on Regina’s generic nearest-neighbour function at Boston GIS.
It follows the same basic idea of using series of enlarging search radii to restrict distance calculations to a manageable subset of things-that-might-be-near. The difference is that it uses a geometric progression of sizes (
x, x * y, x * y^2, x * y^3, ...) instead of an arithmetic one (
x, x + y, x + 2y, x + 3y, ...).
For some distributions of things-that-might-be-near, and tuned with the right parameters (
x, y), this turns out substantially faster (I’ve used it to locate the nearest UK postcode to each mappiness response).
We decided it would be nice to allow respondents to interact with this CDF after providing some key values, and implemented this in the web browser with
<canvas> (falling back on FlashCanvas for IE).
You can play with some examples below: click-and-drag the round handles, or double-click to enter values directly. Feel free to borrow the code (ideally with attribution) if it’s of use to you.
The recent Gawker passwords leak once again highlights the widespread use of passwords that offer essentially no security.
Some years ago, when working on a secure web app for a large organisation — let’s call them Secret Testing Ltd — I was keen that people shouldn’t choose hopelessly weak passwords. I was particularly concerned by my sysadmin colleague’s fondness for passwords of the form ‘p/\55w0rd’ or ‘S3cr3t-T35t|ng’.
PostGIS has an
st_askml function. This turns geometries into fragments of KML, and thus takes you most of the way to easy visualisation of spatial queries using Google Earth. But not all the way: these fragments have then to be assembled into a complete document.
I’ve written some wrapper and aggregate functions to automate this. They’re probably deeply inefficient — I wouldn’t advocate building your next web service on them — but for one-off eyeballing of query results I find them really useful.
The key functions are called
as_kmldoc; you could see them as the missing aggregate versions of