Code Monkey home page Code Monkey logo

Comments (3)

jratike80 avatar jratike80 commented on July 17, 2024

If you use ogr2ogr you are playing with vector data, not pixels. You can check the extent of the PDF with ogrinfo

ogrinfo --config OGR_PDF_READ_NON_STRUCTURED YES  clipsrc-problem.pdf -al -so
Extent: (-51.548640, -14146.138422) - (54006.879028, 28800.419032)

I thought that this would return the same output than without clipsrc
-clipsrc -51.548640 -14146.138422 54006.879028 28800.419032

However, it does not. There is something in the extents that I do not understand. Ogrinfo shows these extents:

For the pdf:

Feature Count: 63161
Extent: (-51.548640, -14146.138422) - (54006.879028, 28800.419032)

For the without-clipsrc

Feature Count: 63161
Extent: (-90.717000, -24895.827000) - (95042.892000, 50685.936000)

For the with-clipsrc

Feature Count: 16590
Extent: (2345.217000, 225.514000) - (54006.879000, 28800.419000)

Gdalinfo works in a rasterized world but it finds also different size for the document than what you calculated:

gdalinfo clipsrc-problem.pdf
Driver: PDF/Geospatial PDF
Files: clipsrc-problem.pdf
Size is 5392, 2878

from gdal.

rouault avatar rouault commented on July 17, 2024

I don't reproduce the issue using GDAL master. The geojson files generated with or without clipsrc are of similar size (the clipped one is slightly smaller due to some invalid geometries, like lines reduced to one single point, being omitted), and they look identical (except the "frame" line of the unclipped file being removed, as expected) when opened in QGIS

$ ls -al without-clipsrc.geojson with-clipsrc.geojson
-rw-rw-r-- 1 even even 15017544 juin  29 17:53 with-clipsrc.geojson
-rw-rw-r-- 1 even even 16653048 juin  29 17:52 without-clipsrc.geojson

$ ogrinfo -al -so without-clipsrc.geojson
INFO: Open of `without-clipsrc.geojson'
      using driver `GeoJSON' successful.

Layer name: content
Geometry: Unknown (any)
Feature Count: 63161
Extent: (-9.072000, -2489.583000) - (9504.289000, 5068.594000)

$ ogrinfo -al -so with-clipsrc.geojson
INFO: Open of `with-clipsrc.geojson'
      using driver `GeoJSON' successful.

Layer name: content
Geometry: Unknown (any)
Feature Count: 53658
Extent: (234.522000, 21.891000) - (9482.474000, 5032.952000)

I believe that the fixes for the PDF driver that went in 3.9.1 to solve #9870, in particular 53895c7, were the key to fix the issue.

With 3.8, you can workaround the issue (for that particular file) by multiplying by 10 your -clipsrc values

from gdal.

tiffanywei avatar tiffanywei commented on July 17, 2024

@rouault Upgrading gdal fixed it, thank you!

from gdal.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.