Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Import distance/time matrices from Qgis to Stata

    Hi every body,

    I would like to import a distance (or commuting time) matrix in stata which is already constructed on QGis.

    Do anybody if it is possible? If not, I have also the matrix in a csv (or txt) file and I am trying to import it using the spmat option but with no succes.

    I always have the following error message: "Error in line 1 of file ..."

    I do not understand the problem...

    Thank you very much for your help,

    Best regards,

    Carlos

  • #2


    Possible. In principle. If it is not too big.

    At this point I ask you to introduce the members of this forum to QGis, describe the capabilities of the system, supported file formats and kind of data stored in them, kind of data you hope to import to Stata, and kind of data that you can sacrifice in the process of a transfer, and other relevant information. Furthermore, supplement your question with example data files of the kind you are trying to read and experiences and solutions of transferring the data from QGis to other software packages.

    If "possible" means "Where is the import data from QGis menu item in Stata?" Then sorry, not possible.

    Best, Sergiy


    Comment


    • #3
      Carlos,

      Having used QGIS with Stata before, I'm not sure if importing the entire distance matrix is what you want.
      If you tell us a bit about what do you want to do with that matrix, we could probably avoid the usual xy problem and give you a better answer

      Best,
      Sergio

      Comment


      • #4
        On the alternative, if you have a CSV, Stata works with CSV and will import it happily. If it doesn't, it's likely you don't have a CSV, or you confused it by specifying incorrect options. See what you need to specify in the manual.

        I always have the following error message: "Error in line 1 of file ..."
        Also check if you quoted the message completely and verbatim. There is another error reported immediately above this line like in this post by Roger Newson , which suggests one of reasons (invalid variable names in that case).
        Importing data means you are limited to 32,000 variables (dataset limitation). GIS systems can easily produce ginormous files larger than that.
        Some file operations are limited to strings of ~32,000 chars/line (also easily overshot with automatic file generation).
        The list can go on.

        Perhaps also look at line #1 of your file.

        Best, Sergiy.

        Comment


        • #5
          Hello Sergiy Radyakin and Sergio Correia

          Thank you very much to have taken few minutes to try to help me.

          I will try to be clear

          I have build a good dataset for 5 years (1970-1980-1990-2000-2010) about the transport network (roads, highways and train networks) of a country. I have 231 "Urban Units" that are deserved by almost all the networks. I build these networks on Qgis and know I have "commuting times" between all the 231 3urban Units". So I have the O-D matrices for the five different years (networks have changed a lot and also the average speeds).

          Now I am working on a Spatial Econometric model (dynamic if possible using XSMLE command) and I want to use my O-D matrix for each year. So I use QGis program to construct the O-D matrices (and I use also another program, OrbisGis to made it). At the end, I have a 231x231 matrix. I have already this matrice (with commuting times between O-D) on CSV format. I am trying to import this commuting time matrix (231x231) done in Qgis to use it instead a contiguity matrix in order to make the spatial analysis not based on distances but on time.

          However, when I arrive to the step "spmat import SPWMat using SPWMat.txt, replace normalize(row)" I have as error message:
          "Error in line 1 of file D:\Olarte\Documents\Pour_OrbiGis\distanceW_e2.csv" . I thought it was because of the type of the variables but it seems it is not the cause.

          The first line is a header with no "alphanumeric" fields for the names but numerical data.

          I use these '"routine" in Stata:

          *** spwmatrix import using D:\Olarte\Documents\Pour_OrbiGis\distance_1.csv, wname(Mdist1)
          *** clear all
          *** insheet using D:\Olarte\Documents\Pour_OrbiGis\spmat.txt, delimiter (" ")
          *** list, table clean noheader
          *** save "D:\Olarte\Documents\Pour_OrbiGis\SPWmat.dta"
          *** outsheet using D:\Olarte\Documents\Pour_OrbiGis\SPWmat.txt, delimiter(" ") nonames nolabel replace
          *** drop in 1
          *** spmat import SPWMat using D:\Olarte\Documents\Pour_OrbiGis\spwmat.txt, replace normalize(row)

          And here is when I have the error message: "Error in line 1 of file D:\Olarte\Documents\Pour_OrbiGis\distanceW_e2.csv"

          Hope I was more clear and thank you so much for your help.

          All best,

          Carlos

          Comment


          • #6
            Did you add the number of colums to the first line? From the help file:

            "spmat import imports data from a space-delimited text file in which the first line contains the number of columns of the spatial-weighting matrix and, if applicable, the lower and upper band, followed by the matrix stored row by row with unique place identifiers recorded in the first column."

            I can't tell you more without seeing what's exactly on your first line (and I can't suggest you to -set trace on- either because spmat is just a wrapper to a mata routine that can't be easily traced)

            Best,
            Sergio

            PS: What are the use cases / advantages of Orbit GIS vs QGIS? I didn't knew about OrbitGIS until now..

            Comment


            • #7
              Hi Sergio.
              Yes, first line and first column has the number of "zones" or "columns". I will send you the matrix.
              I tried to send you the file but I don't know how to do...I tried to upload the file but there is an error message. "invalide file..."
              Where can I send it to you?

              Comment


              • #8
                Originally posted by Carlos Olarte View Post
                Hi Sergio.
                Yes, first line and first column has the number of "zones" or "columns". I will send you the matrix.
                I tried to send you the file but I don't know how to do...I tried to upload the file but there is an error message. "invalide file..."
                Where can I send it to you?

                [email protected] works if it's not extremely large

                Comment

                Working...
                X