2

I need to plot the distribution of a plant species on a map. I have created a shapefile for the species plots (name of file is PLANT). The coordinate system of this file is WGS84. On the attribute table of this shapefile I put the fields Latitude, Longitude, ID and Type.

I have a georerefenced map of Madeira Island, using the WGS84 coordinate system. What I want to do is using the Madeira Island map as a reference, I want to plot the distribution of a plant species so that when I click a on the map to add a point to the PLANT shapefile, the lat/long coordinates of that point go automatically to the latitude and longitude fields on the PLANT attribute table.

Can anyone tell me how this can be done or reference me to a tutorial that explains how this can be done?

In short, how can I make the latitude and longitude fields of a attribute table be automatically filled when I click with the mouse on a map?

I'm not experienced in using QGIS.

5

You can do this after you placed the points on the map with field calculator: Just open the attribute table and press the fieldcalculator create a X and a Y field and then enter $x for the field with X-coordinate and $y for Y-coordinate . More info: click here

If you put your data in a spatial database , you can use triggers to fill these fields automatically, for example in spatialite:

    CREATE TRIGGER LOCATIONS_UPDATE_XY AFTER UPDATE OF "GEOM" ON LOCATIONS
              BEGIN
                UPDATE LOCATIONS
                SET "X"= X( "GEOM" ), "Y"=  Y( "GEOM" )
                WHERE ID = old.ID;
              END;
  • 1
    Seems this results in a value of null for me... – Chris Sobolewski Feb 2 '16 at 2:41

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.