0

I`m working in a project where I must display shapefiles. I'm using OGR to read the shapefile data and use QT to display it.

At this moment, I can display correctly shapefiles with around 2000 geometries but if I use bigger then my program performance is reduced.

I want reduce the number of geometries from my shapefile using the level of detail but I don't know is this is possible with OGR. For example, I have a shapefile with 12 million points and I want reduce it to 2000 point keeping the details.

I read about use ogr2ogr executable, but this is very slow and I need reduce the shape in execution time.

How can I proceed?

  • 2
    Shapefiles are sub-optimal for doing selections based on any other criteria than bounding box. Does your project allow to use some other format that supports indexing, like PostGIS or GeoPackage? Which 2000 points would you like to select? Random points within the region of interest or 2000 first sorted by some attribute? – user30184 Jun 29 '18 at 11:50
  • 2
    Your goal of filtering coordinates on the fly is not sound. The generalization should be performed so that neighboring geometries continue to share boundaries, which is actually quite challenging, and should therefore be done once, correctly, for each scale level. It's unlikey that you could change 12m vertices to 2k and keep all the details. – Vince Jun 29 '18 at 12:38
  • Have you considered the point cluster approach if points are what you have? Like here anitagraser.com/2017/06/13/…? – user30184 Jun 29 '18 at 13:20
2

You can use OGRGeometry methods Simplify or SimplifyPreserveTopology. But you need some own logic to store and read simplified geometries in/from additional geometry columns or blobs columns (or maybe separate OGRLayer).

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.