How can I get US Congressional District code by latitude and longitude OR user address? I have already downloaded Congressional district shapefile from Census files.
-
1Welcome to Geographic Information Systems! Welcome to GIS SE! We're a little different from other sites; this isn't a discussion forum but a Q&A site. Your questions should as much as possible describe not just what you want to do, but precisely what you have tried and where you are stuck trying that. Please check out our short tour for more about how the site works– Ian Turton ♦Jan 2, 2022 at 16:54
1 Answer
Create points from your lat/lon values - see e.g. here how to do it.
On the point layer, apply this expression:
overlay_within('district', "code")[0]
and replacedistrict
with the name of the polygon layer containing the districts andcode
with the attribute field containing the US Congressional District code.
-
I am beginner. I am using OSGeo4W Shell How can implement these points like Create points from lat/lon values,– jagjeetJan 2, 2022 at 15:00
-
It depends: how/where do you have your lat/lon values? Is it a csv you can load to QGIS? see here: gis.stackexchange.com/q/415660/88814– BabelJan 2, 2022 at 15:08
-
Basically, I have website when user comes on website i am getting user lat/lon values and based on this lat/lon i need to getting user congressional district code.– jagjeetJan 2, 2022 at 15:21
-
I have already download congressional district shape file. census.gov/cgi-bin/geo/shapefiles/…– jagjeetJan 2, 2022 at 15:25
-
So save/import lat/lon as CSV. This is a very common topic and there are a lot of tuturials, look here: google.com/search?q=csv+qgis+import+points , e.g. this video: youtu.be/Xgi-UdyDi1k and also here: qgistutorials.com/en/docs/3/importing_spreadsheets_csv.html– BabelJan 2, 2022 at 15:26