Smathermather's Weblog

Remote Sensing, GIS, Ecology, and Oddball Techniques

Archive for June, 2011

GeoWebCache Configuration

Posted by smathermather on June 21, 2011

I’ve long delayed the configuration of GeoWebCache (GWC).  Automatic configuration within GeoServer’s deployment of it has been adequate until now.   Until now that I want to deploy tiles in something other than Google Mercator… .

I’ve developed a cache setup for Ohio State Plane North, Feet (epsg:3734).  At first it was a going to be a cache just for our service area, then I thought I’d include surrounding counties, and by the time I was done, I just decided that having a cache definition for the entire state plane ohio north coverage area made as much sense as anything else– it could make things easier to share and integrate as part of a regional standard for WMS-C, assuming I get buy-in from others… .  It could also be easily adapted for State Plane South.

The definition for a cache requires three things:  coordinate extent, resolutions (or equivalent), and tilesize (height and width).  For coordinate extent, I chose the extents of epsg:3734 as defined by, and snapped them to the nearest 5000 foot interval:





Then, choosing resolution based on a series of measurable scales (1:600 or 1″=50′, 1:1200 or 1″=100′, etc) we get the resolutions:
















Finally, we’ll use a predictable tilesize:



Now we have a portable tilecache recommendation that should work for all of Northern Ohio:
GWC Example

Posted in GeoServer, GeoWebCache | Tagged: , , | 3 Comments »

Multi-Ring Buffers in PostGIS– Prep for Landuse Analysis

Posted by smathermather on June 16, 2011

If we want to understand the factors affecting the quality of an ecological resource, adjacency is important. Adjacent land use and the fossil fuel inputs relative to keeping a land use in its current use seem to have strong correlation with, e.g. wetland quality.  I’ll have a deeper post on this with some citations, but this relatively simple process of analysis is called Landscape Development Index (LDI).  For now, just some PostGIS code with pretty little wetland buffer pictures… .  More complete code forthcoming… .

CREATE TABLE public.wetland_bufftest4

	SELECT wet.gid AS gid_wet, ST_Difference(
		ST_Union(ST_Buffer(wet.the_geom, 100)),
		ST_Union(ST_Buffer(wet.the_geom, 0))
	AS the_geom
	FROM public.wetland wet
	GROUP BY wet.gid


	SELECT wet.gid AS gid_wet, ST_Difference(
		ST_Union(ST_Buffer(wet.the_geom, 250)),
		ST_Union(ST_Buffer(wet.the_geom, 100))
	AS the_geom
	FROM public.wetland wet
	GROUP BY wet.gid


	SELECT wet.gid AS gid_wet, ST_Difference(
		ST_Union(ST_Buffer(wet.the_geom, 500)),
		ST_Union(ST_Buffer(wet.the_geom, 250))
	AS the_geom
	FROM public.wetland wet
	GROUP BY wet.gid


	SELECT wet.gid AS gid_wet, ST_Difference(
		ST_Union(ST_Buffer(wet.the_geom, 1000)),
		ST_Union(ST_Buffer(wet.the_geom, 500))
	AS the_geom
	FROM public.wetland wet
	GROUP BY wet.gid

ALTER TABLE public.wetland_bufftest4 ADD COLUMN gid serial;
ALTER TABLE public.wetland_bufftest4 ADD PRIMARY KEY (gid);

Posted in Database, PostGIS, SQL | Tagged: , , | 2 Comments »

Looping Trails– alternate routing for recreational use

Posted by smathermather on June 16, 2011

This post will be a conceptual one, rather than technology specific. Imagine a scenario where you want to provide a curated trail experience from a mobile device. You want people to be able to go to a park, pick a starting location (such as their current location) in their device, and query the system for all the possible 1-3 mile loops from that location. How do you rank the looping options, once you’ve calculated what all the possible loops are?

1 possible loop

All other things being equal, you might suggest that you want the experience to be as loopy as possible to avoid the Bilbo Baggins problem (There and Back Again):

A shape index, like Perimeter/Area could be a proxy for loopiness.

But once you’ve chosen your loopiest trail, the one with the smallest perimeter to area ratio, how do you choose your second best option?  You should choose the next least similar trail loop, so that the user can choose from the maximum diversity of possible choices:

Trail 1 is less similar (50%) to Trail 2 is to Trail 3...

Now we have a clear hierarchy of choices for our trail user, we return the best possible option first, then a list of the options which are least similar.  If you were to offer a 3rd option (three options is a nice place to start to avoid overwhelming the user), that 3rd option should be the second least similar option to the 1st.

The question is, how to do we calculate similarity between routes?  Fuzzy Hashes is the answer.  A fuzzy hash comparison of the pairwise geometries of all the possible loops would give us a matrix of similarity:

Which we can use to complete our trail loop ranking.




Posted in Recreation, Trail Curation, Trails | Tagged: | 3 Comments »

SQL nube discovery

Posted by smathermather on June 4, 2011

Not sure this is standard SQL, but something I wanted to do is be able to cast new columns as a defined type while creating them on the fly with a SELECT statement.  In this way, I might, for example, UNION or UNION ALL two dissimilar tables on the fly with a VIEW.  In PostgreSQL this can be done easily, e.g.:

SELECT 1::smallint as gid, 'aaaah!'::text as mytextfield, a.gid as gid1, a.the_geom
	FROM base.wetlands_06 AS a;

The “::” serves as the cast.  I’ll have an upcoming post restructuring our data for serving in GeoServer as a VIEW to maximize legend support for GeoExt.  John, one of my interns, will be the guest blogger.

Posted in SQL | Leave a Comment »