[OSM-dev] extract polygons from .osc

Steven Ottens steven at minst.net
Fri Apr 15 17:54:26 BST 2011


On Apr 15, 2011, at 6:32 PM, Andy Allan wrote:

> On Fri, Apr 15, 2011 at 5:08 PM, Steven M. Ottens <steven at minst.net> wrote:
>> Hi all,
>> 
>> Is there a way to extract polygons or bounding boxes with the areas that are
>> changed from an .osc file? I noticed that for any changeset [1] the
>> 'Changeset XML' [2] has a bounding box (but no changes) and the 'osmChange
>> XML' [3] doesn't have a boundingbox, but does have the changes.
>> I've got a tileserver with a osm2pgsql database which gets nicely updated.
>> Now I want to refresh those tiles from which the data is/might have changed.
>> I'm using MapProxy as tileserver and it allows for polygons and bounding
>> boxes as input for a reseed. So I figured if I can extract the changed areas
>> from the .osc file I can automatically reseed those areas with a simple
>> script.
> 
> osm2pgsql will calculate the areas that have expired for you - the
> advantage of this is that it can use other information to make better
> calculations. For example, an .osc file might only contain one node
> that has changed coordinates, and osm2pgsql can calculate the extent
> of the forest multipolygon that now needs expiring. The .osc itself
> doesn't contain enough information to tell you the ultimate impact of
> all the changes.
> 
> osm2pgsql -e will calculate the expired tiles during a diff update,
> and then converting tileids into polygons / bounding boxes for
> MapProxy should be straightforward.

The expired tiles are no doubt in spherical mercator, whereas my tiles are in dutch projection. But using tileids to create bboxes should be rather easy indeed. I'll whip up some script and once I'm satisfied it works I'll put it online somewhere.

Cheers,

Steven


More information about the dev mailing list