Re: [gdal-dev] Calculate footprints of shapefiles
Chaitanya I can understand how the UnionCascade works in PostDIS since it's an aggregate function. I just don't understand how I should use it in OGR. The documentation has a single line UnionCascaded(self) - Geometry So it returns a geometry from another geometry, but I would need a returned geometry from a *list* of input geometries, not from a single one. So I don't have a clue if this is possible in OGR. Another option could be the Collect function, but this seems to be only implemented in the C libraries, not in the Python bindings. Looks like geometry collections are not available in OGR for Python at all. Armin Original-Nachricht Datum: Thu, 17 Mar 2011 10:16:06 +0530 Von: Chaitanya kumar CH chaitanya...@gmail.com An: Armin Burger armin.bur...@gmx.net CC: gdal-dev@lists.osgeo.org, mariusjigm...@hotmail.com Betreff: Re: [gdal-dev] Calculate footprints of shapefiles Armin, Cascaded Union works pretty much like Union except that it is optimized to work on more than two geometries. Both OGR and PostGIS uses the GEOS library to perform this. Read this blog entry by Paul Ramsey: http://blog.cleverelephant.ca/2009/01/must-faster-unions-in-postgis-14.html On Wed, Mar 16, 2011 at 3:41 PM, Armin Burger armin.bur...@gmx.net wrote: Chaitanya thanks for the hints. So a sort of Union operation seems to be necessary. I need to check how fast that is with OGR on larger shapefiles (I want to store in PostGIS just the footprint, not the full geometry collection). The ConvexHull could be a good alternative to a simplified boundary. I understand how the normal Union() works, it merges 2 geometries into a new one. But I don't get it what UnionCascade() is doing. It applies a Union on a single geometry and returns the new geometry, what is it actually unioning/merging then? Regards, Armin -- GMX DSL Doppel-Flat ab 19,99 Euro/mtl.! Jetzt mit gratis Handy-Flat! http://portal.gmx.net/de/go/dsl ___ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev
Re: [gdal-dev] Calculate footprints of shapefiles
Armin, I don't know if it works on geometry collection but it certainly works on a MultiPolygon. In return, you will get either a Polygon or a MultiPolygon depending on the union being connected or not. On Thu, Mar 17, 2011 at 5:51 PM, Armin Burger armin.bur...@gmx.net wrote: Chaitanya I can understand how the UnionCascade works in PostDIS since it's an aggregate function. I just don't understand how I should use it in OGR. The documentation has a single line UnionCascaded(self) - Geometry So it returns a geometry from another geometry, but I would need a returned geometry from a *list* of input geometries, not from a single one. So I don't have a clue if this is possible in OGR. Another option could be the Collect function, but this seems to be only implemented in the C libraries, not in the Python bindings. Looks like geometry collections are not available in OGR for Python at all. Armin Original-Nachricht Datum: Thu, 17 Mar 2011 10:16:06 +0530 Von: Chaitanya kumar CH chaitanya...@gmail.com An: Armin Burger armin.bur...@gmx.net CC: gdal-dev@lists.osgeo.org, mariusjigm...@hotmail.com Betreff: Re: [gdal-dev] Calculate footprints of shapefiles Armin, Cascaded Union works pretty much like Union except that it is optimized to work on more than two geometries. Both OGR and PostGIS uses the GEOS library to perform this. Read this blog entry by Paul Ramsey: http://blog.cleverelephant.ca/2009/01/must-faster-unions-in-postgis-14.html On Wed, Mar 16, 2011 at 3:41 PM, Armin Burger armin.bur...@gmx.net wrote: Chaitanya thanks for the hints. So a sort of Union operation seems to be necessary. I need to check how fast that is with OGR on larger shapefiles (I want to store in PostGIS just the footprint, not the full geometry collection). The ConvexHull could be a good alternative to a simplified boundary. I understand how the normal Union() works, it merges 2 geometries into a new one. But I don't get it what UnionCascade() is doing. It applies a Union on a single geometry and returns the new geometry, what is it actually unioning/merging then? Regards, Armin -- GMX DSL Doppel-Flat ab 19,99 Euro/mtl.! Jetzt mit gratis Handy-Flat! http://portal.gmx.net/de/go/dsl -- Best regards, Chaitanya kumar CH. /tʃaɪθənjə/ /kʊmɑr/ +91-9494447584 17.2416N 80.1426E ___ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev
Re: [gdal-dev] Calculate footprints of shapefiles
Chaitanya thanks for the hints. So a sort of Union operation seems to be necessary. I need to check how fast that is with OGR on larger shapefiles (I want to store in PostGIS just the footprint, not the full geometry collection). The ConvexHull could be a good alternative to a simplified boundary. I understand how the normal Union() works, it merges 2 geometries into a new one. But I don't get it what UnionCascade() is doing. It applies a Union on a single geometry and returns the new geometry, what is it actually unioning/merging then? Regards, Armin Original-Nachricht Datum: Wed, 16 Mar 2011 10:06:57 +0530 Von: Chaitanya kumar CH chaitanya...@gmail.com An: armin.bur...@gmx.net CC: Marius Jigmond mariusjigm...@hotmail.com, gdal-dev@lists.osgeo.org Betreff: Re: [gdal-dev] Calculate footprints of shapefiles Armin, This can be done in either OGR or PostGIS. For OGR, refer to the OGRGeometry class reference, especially the ConvexHull(), Union() and UnionCascaded() functions. For PostGIS, ST_Boundary() and ST_Union(). -- GMX DSL Doppel-Flat ab 19,99 Euro/mtl.! Jetzt mit gratis Handy-Flat! http://portal.gmx.net/de/go/dsl ___ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev
Re: [gdal-dev] Calculate footprints of shapefiles
thanks for the hints. So a sort of Union operation seems to be necessary. I need to check how fast that is with OGR on larger shapefiles (I want to store in PostGIS just the footprint, not the full geometry collection). The Convex Hull could be a good alternative to a simplified boundary. it depends on your shapes -- if you have a very concave shape, a convex hull can be a poor representation. You might try simplifying before the Union - that would make the Union faster. -Chris -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/ORR(206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception chris.bar...@noaa.gov ___ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev
Re: [gdal-dev] Calculate footprints of shapefiles
Armin, Cascaded Union works pretty much like Union except that it is optimized to work on more than two geometries. Both OGR and PostGIS uses the GEOS library to perform this. Read this blog entry by Paul Ramsey: http://blog.cleverelephant.ca/2009/01/must-faster-unions-in-postgis-14.html On Wed, Mar 16, 2011 at 3:41 PM, Armin Burger armin.bur...@gmx.net wrote: Chaitanya thanks for the hints. So a sort of Union operation seems to be necessary. I need to check how fast that is with OGR on larger shapefiles (I want to store in PostGIS just the footprint, not the full geometry collection). The ConvexHull could be a good alternative to a simplified boundary. I understand how the normal Union() works, it merges 2 geometries into a new one. But I don't get it what UnionCascade() is doing. It applies a Union on a single geometry and returns the new geometry, what is it actually unioning/merging then? Regards, Armin Original-Nachricht Datum: Wed, 16 Mar 2011 10:06:57 +0530 Von: Chaitanya kumar CH chaitanya...@gmail.com An: armin.bur...@gmx.net CC: Marius Jigmond mariusjigm...@hotmail.com, gdal-dev@lists.osgeo.org Betreff: Re: [gdal-dev] Calculate footprints of shapefiles Armin, This can be done in either OGR or PostGIS. For OGR, refer to the OGRGeometry class reference, especially the ConvexHull(), Union() and UnionCascaded() functions. For PostGIS, ST_Boundary() and ST_Union(). -- GMX DSL Doppel-Flat ab 19,99 Euro/mtl.! Jetzt mit gratis Handy-Flat! http://portal.gmx.net/de/go/dsl -- Best regards, Chaitanya kumar CH. /tʃaɪθənjə/ /kʊmɑr/ +91-9494447584 17.2416N 80.1426E ___ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev
Re: [gdal-dev] Calculate footprints of shapefiles
Armin, Not sure if this would be straightforward in GDAL but you might want to consider a combination of GDAL + Shapely (http://gispython.org/shapely/docs/1.2/manual.html#cascading-unions). What you're trying to do is spatial analysis not directly implemented in GDAL. Shapely requires that you're working with Cartesian coordinates. The upside is that it has WKT/WKB support for direct loading into PostGIS. -marius On Wed, 2011-03-16 at 01:08 +0100, Armin Burger wrote: Hi all I would like to catalogue shapefiles scattered over lots of directories of the file system and store retrievable information of the shapefiles in a PostGIS layer. Extracting parameters like extent, projection, fields, etc works very fine with GDAL's Python bindings. But I would also like to store a sort of footprint of the whole shapefile as a geometry object since the extent is a bit coarse geographic representation of the shapefile. So far I have no better idea than eg. for polygon shapefiles looping through all features, applying a Union function on them. And at the end trying to use the Simplify method on the resulting polygon that will be used as the footprint. This is for sure not very efficient for larger shapefiles with lots of records. And for line and point shapefiles I still don't have a clue how their records could be represented by an enclosing polygon (maybe the Boundary functions does something like this...). Any ideas how this footprint generation could be achieved in a feasible way using GDAL/OGR Python? Cheers, Armin ___ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev ___ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev
Re: [gdal-dev] Calculate footprints of shapefiles
Marius, thanks for the suggestion. I don't know if shapely supports re-projection of geometries or has a simplify algorithm, which I will both need. There could be some other functions of GDAL/OGR that I might need in the future as well. So in principal I'd prefer to stick to GDAL. armin On 16/03/2011 01:35, Marius Jigmond wrote: Armin, Not sure if this would be straightforward in GDAL but you might want to consider a combination of GDAL + Shapely (http://gispython.org/shapely/docs/1.2/manual.html#cascading-unions). What you're trying to do is spatial analysis not directly implemented in GDAL. Shapely requires that you're working with Cartesian coordinates. The upside is that it has WKT/WKB support for direct loading into PostGIS. -marius On Wed, 2011-03-16 at 01:08 +0100, Armin Burger wrote: Hi all I would like to catalogue shapefiles scattered over lots of directories of the file system and store retrievable information of the shapefiles in a PostGIS layer. Extracting parameters like extent, projection, fields, etc works very fine with GDAL's Python bindings. But I would also like to store a sort of footprint of the whole shapefile as a geometry object since the extent is a bit coarse geographic representation of the shapefile. So far I have no better idea than eg. for polygon shapefiles looping through all features, applying a Union function on them. And at the end trying to use the Simplify method on the resulting polygon that will be used as the footprint. This is for sure not very efficient for larger shapefiles with lots of records. And for line and point shapefiles I still don't have a clue how their records could be represented by an enclosing polygon (maybe the Boundary functions does something like this...). Any ideas how this footprint generation could be achieved in a feasible way using GDAL/OGR Python? Cheers, Armin ___ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev ___ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev
Re: [gdal-dev] Calculate footprints of shapefiles
Armin, This can be done in either OGR or PostGIS. For OGR, refer to the OGRGeometry class reference, especially the ConvexHull(), Union() and UnionCascaded() functions. For PostGIS, ST_Boundary() and ST_Union(). On Wed, Mar 16, 2011 at 6:23 AM, Armin Burger armin.bur...@gmx.net wrote: Marius, thanks for the suggestion. I don't know if shapely supports re-projection of geometries or has a simplify algorithm, which I will both need. There could be some other functions of GDAL/OGR that I might need in the future as well. So in principal I'd prefer to stick to GDAL. armin On 16/03/2011 01:35, Marius Jigmond wrote: Armin, Not sure if this would be straightforward in GDAL but you might want to consider a combination of GDAL + Shapely (http://gispython.org/shapely/docs/1.2/manual.html#cascading-unions). What you're trying to do is spatial analysis not directly implemented in GDAL. Shapely requires that you're working with Cartesian coordinates. The upside is that it has WKT/WKB support for direct loading into PostGIS. -marius On Wed, 2011-03-16 at 01:08 +0100, Armin Burger wrote: Hi all I would like to catalogue shapefiles scattered over lots of directories of the file system and store retrievable information of the shapefiles in a PostGIS layer. Extracting parameters like extent, projection, fields, etc works very fine with GDAL's Python bindings. But I would also like to store a sort of footprint of the whole shapefile as a geometry object since the extent is a bit coarse geographic representation of the shapefile. So far I have no better idea than eg. for polygon shapefiles looping through all features, applying a Union function on them. And at the end trying to use the Simplify method on the resulting polygon that will be used as the footprint. This is for sure not very efficient for larger shapefiles with lots of records. And for line and point shapefiles I still don't have a clue how their records could be represented by an enclosing polygon (maybe the Boundary functions does something like this...). Any ideas how this footprint generation could be achieved in a feasible way using GDAL/OGR Python? Cheers, Armin ___ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev ___ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev -- Best regards, Chaitanya kumar CH. /tʃaɪθənjə/ /kʊmɑr/ +91-9494447584 17.2416N 80.1426E ___ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev