Announcement

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

  • Finding State, District, City using Latitude and Longitude data

    I have a qualtrics survey data, where I have respective latitude and longitude for each observation. I want to find the respective city, district and state of all the observation. Store them as new variables in my dataset. How can this be done. It is relatively new to me. Thank You

  • #2
    Answers are likely to be specific to the country or countries you are studying.

    Comment


    • #3
      I think geoinpoly does this. You'll need shapefiles for the areas of interest.

      geocodio.io would work and is probably much simpler. upload your lat/lon data and it will spit out a spreadhseet of all sorts of useful information. it may cost you a few shekels, but you'll be done in seconds.

      Comment


      • #4
        Hello Nick, I am doing my analysis using data of India. Is there any specific code in Stata that can give me these variables, correspond to each latitude-longitude pair? Also I have the shp file for state, district and city.

        Comment


        • #5
          geoinpoly

          Comment


          • #6
            i doubt geocodio has data from India.

            Comment


            • #7
              https://geocode.xyz/batch

              can use lat/lon in a batch format.

              Comment


              • #8
                Thank You George. I was trying geoinpoly but shp files seem to have some problem with coordinates. Stata is showing error. I am looking into this.

                Comment


                • #9
                  I've used it a few times and recall it being tricky to set up. From what I remember, you have to alter the ID variable in one or the other, and have to make sure the lat/lon sign is correct. But once you get it, it works as intended.

                  Comment


                  • #10
                    I have changed the format to shp file. Now it is working but there is another issue coming up. The code is not seem to be returning right location corresponding to the coordinates. And this is happening after merging with the original dataset.

                    Comment


                    • #11
                      I'd take the lat/lon of an observation and one from the boundary of the incorrect city and the correct city figure out why. I suspect the lat/lon are not consistently defined.

                      Comment


                      • #12
                        and make sure you have lat/lon. some geo data uses a different measure of position (I don't recall the name of it). I've had to convert it to lat/lon in prior work, which I don't recall being fun.

                        Comment


                        • #13
                          Yeah George is right, it needs to be in the right format, cuz if it ain't, well, now you have yourself a Python problem.

                          But yeah, seriously, just get a shape file for Indian cities, use geoinpoly (which has always worked for me, even with very very massive jobs), and you'll be fine. Make sure it's in long/lat!! I think you can check this in one of the shapefile metadata files

                          Comment


                          • #14
                            Could be Geographic Coordinate System (GCS), which is a different than lat/lon, but looks the same.

                            Comment


                            • #15
                              Maybe shapefiles come in GCS. I think its WGS84 standard, but could be wrong.

                              Or this might work to convert your lat/lon: https://www.earthpoint.us/BatchConvert.aspx

                              Comment

                              Working...
                              X