2

I have two layers in QGIS. One is a shapefile of states in the US. The other is a csv with lat/lon coordinate points, with data at each point.

I want to export a csv from QGIS that has a column that records what state each data point falls in.

For example, let's say I have 4 columns in my csv file. First is location ID, second is Latitude, third is Longitude, and fourth is count (just a number). One of the rows might look like this:

123456, 41.2, -97.3, 4

Since this point is in Nebraska (in real-life and according to my shapefile), I want to have a new column for state, so that the above row would now look like this:

123456, 41.2, -97.3, 4, Nebraska

Is this something I would use 'Join Attributes by Location' for? I'm trying that now, but its suspiciously slow.

  • 3
    Join Attributes by Location should do it. When processing time is an issue, reducing the file sizes by exporting a subset of features and re-trying is the first step in trouble shooting for me. For example, you could try only 4 states and see whether that helps. – ZrSiO4 Oct 27 '17 at 2:31
  • Ok, thank you for this idea. It is 80% of the way completed now, so I'll probably just wait it out this time. Thanks again. – Heliornis Oct 27 '17 at 2:32
  • If the state layer has many attributes, you could speed things up by eliminating the unnecessary attributes before joining. – csk Oct 30 '17 at 16:57
2

As mentioned in a comment from @ZrSiO4:
Join Attributes by Location worked, though time-consuming!

The Join Attributes tool can be found in the top menu Vector > Data Managemtn Tools > Join Attributes by Location, and inputting the csv coordinates for the first input, and polygon shape file for the second input.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.