Page MenuHomePhabricator

Add coordinates to imported data
Closed, ResolvedPublic

Description

The imported data did not include coordinates. These can be constructed by creating a centroid for each polygon in the shapefile, converting the projection to wgs84 and exporting the x/lon, y/lat values.

Event Timeline

Steps in Qgis:

  1. Import polygon shp file
  2. VectorGeometry toolsPolygon centroids
  3. Right click on the new layerSave AsCRSWGS84 (EPSG 4326)
  4. Open the new file and ensure the CRS for the whole view is set to EPSG 4326 (bottom right corner)
  5. Right click on the layerOpen attribute tableCtrl-E
  6. Ctrl-I Set name to "lon", precision to "6", expression to "$x" click "ok"
  7. Ctrl-I Set name to "lat", precision to "6", expression to "$y" click "ok"
  8. Ctrl-Sclose window
  9. use e.g. XYtools to extract the nvrid, lon, lat fields as a spreadsheet.

Extracted coordinates:

Items with Nature ID without coords.

This script loads the results of the query above and compares it with one of the CSV files in order to output the necessary QS code in a file. Since it runs the query automatically, only WD items that have no coordinate Property will be affected. Items that already have coordinates e.g. from a Wikipedia import will not be affected.

Usage:

python3 qs_wle_coords.py --infile coords_NR.csv --outfile reservat_coords.tsv

--infile : name of one of the two files above
--outfile : name of the file where to save the QS code

The output looks like this and is ready to be used in Quick Statements (import commands -> version 1 format -> run)

Q30169787	P625	@63.6522/16.196913
Q30169901	P625	@59.531262/18.835281
Q30170296	P625	@59.044214/14.513086
Q30171477	P625	@56.173853/14.529247

To ensure the centroids are also inside the polygon i used the realcentroid plugin instead of # VectorGeometry toolsPolygon centroids.

While the NP centroids where the same this gave me a new set of NR centroids.