Results 1 to 5 of 5

Thread: Reading a shapeFile

  1. #1
    Join Date
    Jul 2017
    Posts
    7
    Qt products
    Qt5
    Platforms
    Windows

    Default Reading a shapeFile

    I am reading a shape file and collecting into a QString,but the string is in some binary format, but not getting geometric data(lat,lons).how to read a shape file.

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Reading a shapeFile

    what is a 'shape file'?
    How was it generated?
    You say it is in binary format, if so, string will not help you much.
    You need to know the serialization protocol, and serialized it back.
    This has nothing to do with Qt.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Jul 2017
    Posts
    7
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Reading a shapeFile

    I am using opengl in Qt


    here filestr is D:/cochin_vegitation.shp

    QFile mfile(filestr);

    if(!mfile.open(QFile::ReadOnly |QIODevice::Text))
    {
    return;
    }
    QTextStream in(&mfile);
    QString mText=in.readAll();
    qDebug()<<"textsize"<<mText.size();

    for(int i=0;i<mText.size();i++)
    {
    qDebug()<<"text"<<mText[i];
    }



    I am getting out put as

    text '00\u00a3'
    text '?'
    text '\x10'
    text 'S'
    text '@'
    text '00\u00af'
    text 'H'
    text '$'
    text '\x1b'
    text 'Y'
    text '00\u00e7'
    text '#'
    text '@'
    text '\x1'
    text '\x0'
    text '\x0'
    text '\x0'
    text '\x5'
    text '\x0'
    text '\x0'
    text '\x0'
    text '\x0'
    text '\x0'
    text '\x0'
    text '\x0'
    text '('
    text 'I'
    But i need Geometric data like Latitude,Longitude

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Reading a shapeFile

    nothing in what you added changes the issue.
    You need to know how the data is serialized in the shape file.
    Without it, there is nothing you can do.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  5. #5
    Join Date
    Dec 2009
    Location
    New Orleans, Louisiana
    Posts
    791
    Thanks
    13
    Thanked 153 Times in 150 Posts
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Re: Reading a shapeFile

    You need to open the file as a binary file, not text, because it contains binary data, not text data.

    The file format of a Shapefile is shown here: https://en.wikipedia.org/wiki/Shapefile. The wikipedia article show the layout of the 100 byte header file that is the first 100 bytes in a shapefile, followed by the various record types that it may contain. You'll have to understand the file layout described the article and then successfully read/parse the records that follow the 100 byte header.

    Good luck.
    I write the best type of code possible, code that I want to write, not code that someone tells me to write!

Similar Threads

  1. how can i draw shapefile, figures, images
    By printf in forum Qt Programming
    Replies: 2
    Last Post: 24th May 2017, 05:55
  2. Shapefile rendering,zooming,paning,editing using shaplib and qt opengl es2
    By swapan_gh in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 5th December 2013, 07:00
  3. Conversion from opengl to opengl es2 (Shapefile rendering)?
    By swapan_gh in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 5th December 2013, 06:59
  4. Reading xml through Qt
    By vikuseth in forum Newbie
    Replies: 3
    Last Post: 6th December 2012, 10:52
  5. Opening a shapefile
    By peace_comp in forum Qt Programming
    Replies: 1
    Last Post: 1st May 2008, 20:59

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.