aggregate polygons to multipolygons based on an attribute column (shapefile)

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

aggregate polygons to multipolygons based on an attribute column (shapefile)

Bart van den Eijnden-4
Hi list,

is there a tool in the OGR library to aggregate polygons to multipolygons based on an attribute column for shapefiles? Does anybody know how to go about this if it can't be done with OGR?

Eg:

LOCATION_ID    SHAPE
1                         a polygon geometry
1                         a polygon geometry
1                         a polygon geometry
2                         a polygon geometry
2                         a polygon geometry
...

should become

LOCATION_ID    SHAPE
1                         a multipolygon geometry
2                         a multipolygon geometry
...

Thanks in advance.

Best regards,
Bart

Bart van den Eijnden
Syncera IT Solutions
Postbus 270
2600 AG  DELFT

tel.nr.: 015-7512436
email: [hidden email]

_______________________________________________
Gdal-dev mailing list
[hidden email]
http://xserve.flids.com/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: aggregate polygons to multipolygons based on an attribute column (shapefile)

Frank Warmerdam-2
On 6/15/05, Bart van den Eijnden <[hidden email]> wrote:
> Hi list,
>
> is there a tool in the OGR library to aggregate polygons to multipolygons based on an attribute column for shapefiles? Does anybody know how to go about this if it can't be done with OGR?

Bart,

You could write a python script (or C++ program) to accomplish
this with OGR but there is no built-in capability for this in OGR
command line utilities.

If I were to do it in Python I would read all the features, and maintain
an associative array of geometries in memory to accumulate the
multipolygons, with the attribute value being the key into the array.
This approach assumes that your dataset is small enough that all
the geometry could be held in memory.

Best regards,
--
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, [hidden email]
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent
_______________________________________________
Gdal-dev mailing list
[hidden email]
http://xserve.flids.com/mailman/listinfo/gdal-dev