Archive for December, 2008

PostGIS: Bounding Box Indexing

Friday, December 19th, 2008

You may have seen from my previous post, that I’ve been playing around with PostGIS. I had some more time to dig deeper into it, and I found that, although functions like distance_sphere/ST_distance_sphere aren’t indexable, bounding-box lookups are. Bounding box indexing can be used in conjunction with those functions, to improve the performance of queries, fairly easily.

This only works for GiST indexes, which can be confusing if you’re not familiar with indexes in PostgreSQL. Say the GEOMETRY column you want to index is geom on the table zip. Basically, you just do:

CREATE INDEX zip_geom_idx ON zip USING GIST (geom);

For searching for points that are within a certain radius of another, PostGIS provides a function called expand/ST_expand, which expands a single point to a box, which can then be used in an index lookup.


The queries essentially break down to:

SELECT ... FROM ... WHERE
geom && expand('some point', 1)
AND distance_sphere('some point', geom) <= (15 * 1609.344);

The first part of the WHERE clause, geom && expand(’some point’, 1), expands “some point” 1 degree in all directions to create a box, and finds points that are inside or on the border of the expanded box. This is the part that indexing is used on.

The second part of the WHERE clause, distance_sphere(’some point’, geom) <= (15 * 1609.344), refines the selection (the rows that were found in the index scan), down to points that are within 15 miles of 'some point'.

I usually just use subqueries and a join, rather than doing multiple fetches, so in my case it looks more like:

SELECT t.* FROM mytable t
JOIN zip z ON (z.zip = t.zip)
WHERE z.geom && expand(
    (SELECT geom FROM zip WHERE zip = '10001'), 1)
AND distance_sphere(geom,
    (SELECT geom FROM zip WHERE zip = '10001')) <= (15 * 1609.344);

Versus / Golf Split, And Comcast Phasing Out Analog

Monday, December 8th, 2008

The Versus / Golf split is complete. For Comcast, in Seattle / Tacoma, the new channels are:

  • 625 Golf HD
  • 626 Versus HD 

The former hybrid channel Versus/Golf, is pending removal.

Also I read an interesting article about Comcast shutting off analog in Seattle / Tacoma (link). Basically, it says channels 2-29 will remain broadcasting in analog for the time being, but everything over 29 will be phased out over the next year. They could start the transition as soon as sometime this month, around the time they roll out their new Wideband Internet service. They are also lowering the price of their Digital Cable service, to the price of the current Extended-Basic service (the analog package, which is being phased out).

Comcast Channel Shuffling

Saturday, December 6th, 2008

If you’re wondering why there’s nothing on MOJO HD, it’s because MOJO HD has been cancelled (iN DEMAND confirms). Now the question is, what will it be replaced with.

In the Seattle/Tacoma area, Comcast has been shuffling channels around.

  • MHD has been renamed to Palladia.
  • ESPN HD is now being mapped to both 173 (old) and 623 (new), the old channel presumably pending removal.
  • ESPN2 HD is now being mapped to both 174 (old) and 624 (new), the old channel presumably pending removal.
  • FSN HD has been rolled out (using the space freed by MOJO???). It’s channel 627.
  • The hybrid channel, VS/Golf, is going to be split into two separate channels (VS and Golf). Whether or not both (or which, if any) will be carried in this area, is unconfirmed at this point.
  • King-5 Weather Plus (channel 115) is pending removal, scheduled to be removed on 12-31-2008. The reason is, the parent company has decided to pull the plug on it.