0

I have a dataset that lists entities per district - where district is a named shape that exists on a map. I have a different dataset that contains entities of the same type, only instead of being positioned categorically (i.e. by district name) they are positioned using lat-long coordinates.

So, given a shapefile (in either ESRI or GML3), how can I transform a list of lat-long coordinates into a matching list of named districts?

I am looking for the most generic algorithm possible, but if there are tools/modules out there that perform this function natively, that would be good to know too.

2

One of the easiest ways of doing this would be to import the data into PostGIS and use an update function similar to the following

UPDATE coord_list SET coord_districts = (SELECT district_name FROM polygon_districts WHERE ST_Within(coord_list.geom,polygon_districts.geom)

So you would have to add in a field called coord_districts (or whatever you want to call it really) to your point dataset and this query will update this field based on which district it is found in.

2

Here is an alternative to the answer above using QGIS (I'm using Nodebo version):

1) Save your list of lat and long coordinates in a .csv file; put aside.

2) Load your district layer (I assume it is a polygon layer).

3) Load your .csv file asa point layer

4) Perform "Join Attributes by Location" in QGIS or spatial join (in ArcMap)

  • In QGIS nodebo search "join attributes by location" in the processing toolbar.

  • Sekect your csv (points) layer as target layer.

  • Select your district layer as join layer.

  • In the geometric predicate group, choose "within" radio button.

  • Run the tools

5) Save the resulting layer in a .csv file

  • Right click the layer.
  • Choose "Save as.."
  • Select .csv

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.