[gdal-dev] faster way to display shapeFile

pcreso at pcreso.com pcreso at pcreso.com
Fri Mar 5 16:14:34 EST 2010

Hi Pawell,

A shapefile is not usually spatially indexed, and ogr cannot use the ESRI index anyway, so the entire dataset is read every time to plot it. For a large shapefile this is considerable overhead, especially when you are zoomed in & only want to render a small region. 

See the info here on how to create a spatial index for your shapefile:
http://www.gdal.org/ogr/drv_shapefile.html either with a sql via ogr or using the shptree command.

Essentially you have a data management issue - as an alternative approach, I suggest you look at a spatially enabled database (Postgis) if you want better performance & more effective indexes when rendering a large dataset, but zoomed in to a small area. You can use ogr2ogr or shp2pgsql to load shapefiles into a database, & the data management capabilities of a "proper" database are generally far better than managing shapefiles.


  Brent Wood

--- On Sat, 3/6/10, Paweł Byszewski <pawell.b at gmail.com> wrote:

> From: Paweł Byszewski <pawell.b at gmail.com>
> Subject: [gdal-dev] faster way to display shapeFile
> To: gdal-dev at lists.osgeo.org
> Date: Saturday, March 6, 2010, 9:16 AM
> Hello,I have some map in ShapeFile and
> I am using OGR to display it. I folow the example od OGR
> website: OGR C++ API
> Read/Write Tutorial(http://gdal.org/ogr/ogr_apitut.html).
> Unfortunately that way is very slow. I have map of whole
> country(only roads) and even when I try to display onlu one
> big city and I set spatial filter it takes very much times.
> Could you tell me if gdal/ogr has oportunity to read big
> files in faster way?
> Regards,
> Paweł
> -----Inline Attachment Follows-----
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev

More information about the gdal-dev mailing list