Announcement

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

  • _shp.dta not found - The translated shapefile must be in the current directory.

    Dear Statalist,
    I am currently working with spregress. I have been closely following Stata Spatial autoregressive model to prepare the data using shapefile, but I am stuck at the definition of weighiting matrix. When I type the command

    Code:
    spmatrix create contiguity W
    I get the following error

    Code:
     _shp.dta not found
    The translated shapefile must be in the current directory.
    r(601);
    I have repeatedly changed the work directory and ensured that the _shp.dta related file is in the same folder of any other file that I am using, but I still keep getting the same result. I have been searching on the forum but apart from the obvious suggestion about changing the directory I did not get many hints.
    I don't know if it could be related, but I recently uploaded my operating system to windows 11.
    Any suggestion on how to fix the issue?
    Best regards,

  • #2
    What shapefile are you using? Provide the link to it (if it is public) and I will look at it.

    Comment


    • #3
      Apparently this problem was resolved; a subsequent post seems to report some progress.

      https://www.statalist.org/forums/for...ighting-matrix

      Comment


      • #4
        Originally posted by Jared Greathouse View Post
        What shapefile are you using? Provide the link to it (if it is public) and I will look at it.
        Dear Jared, thank you for your reply. The shapefile is the one commonly used for European Regions (nuts 2 level). I am attaching here the post-extraction .dta and _shp.dta files.

        Originally posted by William Lisowski View Post
        Apparently this problem was resolved; a subsequent post seems to report some progress.

        https://www.statalist.org/forums/for...ighting-matrix
        Dear William, thank you for your reply. That one you are quoting is actually a workaround I am trying (but I got stuck there too), using what I understand to be an older command. Being able to follow the updated version as I am doing here might help in progressing with using spregress.

        Attached Files

        Comment


        • #5
          I don't want you to post the data, I want you to post the link to the data like this.

          I need to be able to work with the EXACT dataset you're working with to help you, so provide the actual link to the data, please.

          Comment


          • #6
            Originally posted by Jared Greathouse View Post
            I don't want you to post the data, I want you to post the link to the data like this.

            I need to be able to work with the EXACT dataset you're working with to help you, so provide the actual link to the data, please.
            Ok, sorry for the misunderstanding. I retrieved the shafile from this link, selecting from the drop down menus NUTS 2016, SHP format, RG, 20M scale, ESPG: 3035.

            Thank you for your help!

            Comment


            • #7
              Yeah I can't replicate this problem.
              Code:
              cd E:\Tests\TestDir
              
              cls
              python:
              import time, os
              from selenium import webdriver
              from webdriver_manager.chrome import ChromeDriverManager
              from selenium.webdriver.support.ui import WebDriverWait
              from selenium.webdriver.common.by import By
              from selenium.webdriver.support import expected_conditions as EC
              from selenium.webdriver.support.ui import Select
              
              options = webdriver.ChromeOptions()
              preferences= {"download.default_directory": os.getcwd(), "directory_upgrade": True}
              options.add_experimental_option("prefs", preferences)
              #options.headless = True
              options.add_experimental_option('excludeSwitches', ['enable-logging'])
              
              url = "https://tinyurl.com/y382ow7c"
              
              # Path of my WebDriver
              driver = webdriver.Chrome(ChromeDriverManager().install(), options=options)
              
              wait = WebDriverWait(driver, 10)
              
              
              # to maximize the browser window
              driver.maximize_window()
              
              #get method to launch the URL
              driver.get(url)
              
              path = "#yearSelect > option:nth-child(3)"
              
              wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, path))).click()
              
              download = "#nutsDownBtn"
              
              wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, download))).click()
              
              end
              global file_ready = 1
              
              while $file_ready {
              
              sleep 1
              
              local file : dir "`c(pwd)'" files "*.zip"
              
              cap conf f `file' // make sure the file is here
              
              if _rc ==7 {
              disp "File loading..."
              }
              
              else if _rc ~= 7 {
              
              global file_ready = 0
              
              local file : dir "`c(pwd)'" files "*.zip"
              
              disp `file'
              
              disp c(current_time)
              
              
              }
              
              }
              
              python:
              from selenium import webdriver
              
              driver.quit()
              end
              
              
              
              cls
              
              
              unzipfile NUTS_RG_20M_2013_3035.shp.zip, replace
              
              
              spshape2dta E:\Tests\TestDir\NUTS_RG_20M_2013_3035.shp, replace saving(regions)
              
              
              u regions, clear
              
              
              spmatrix create contiguity W
              This works for me without error. I could've included Python code to rip the zip file from the website but I was too lazy. Anyways,


              seriously, try this code in a new directory. A totally brand new one with nothing in it. If Stata is saying she can't find a file in the current folder, that's because it can't.
              Last edited by Jared Greathouse; 04 May 2022, 06:51. Reason: Just to humor myself, I included the Python code for full reproducibility.

              Comment


              • #8
                Dear Jared,
                thank you, this perfecly worked!
                All the best.

                Comment

                Working...
                X