[Qgis-user] python(3) script to calculate latitude longitude values from (ESRI) shape file

chris hermansen clhermansen at gmail.com
Wed Apr 21 13:51:40 PDT 2021


Steve and list,

On Wed, Apr 21, 2021 at 1:41 PM wxgis <thinjogger at gmail.com> wrote:

> Hi -
> Wondering if there is existing Python(3) script code that can take an
> (ESRI)
> shape file as input and then calculate latitude/longitude/elevation values
> for country boundaries.  For example, if the input file is a SHP file for
> France, the output would be the lat/lon/elevation values for the country
> boundaries.  I am quite new to QGIS, looking at version 3.18 (so only know
> about ESRI shape files, maybe there are other types of SHP files?), and
> read
> that in QGIS  I can edit the attribute table for a given layer and add
> latitude/longitude attributes, but I am hoping to this more
> programmatically, using the QGIS Python console.  I gladly welcome any
> ideas
> on this.
>

Most polygon data that I've run into tends to be 2D ie there's no elevation
value.  Things like contours are 2½D ie each line is at the same elevation
and so the elevation is stored as an attribute of the line.

Boundaries would typically be either polygons or lines.  As the elevation
varies along the polygon  or line, you would need 3D data.  If you have 2D
data and a DEM you can convert the 2D data to 3D and then interpolate the
elevation values along the polygon or line from the DEM.  Some file formats
will not support 3D polygons or lines.

But something in the way you're stating what you want makes me think you
actually want points along the boundary, each point with latitude,
longitude and elevation.  If that's the case, you can convert your polygons
or lines to points and then again assuming you have a DEM you can
interpolate the elevations at the points.

If your data is not in lat/lon you can project it to lat/lon either before
you start or after you finish.

Does this help?


-- 
Chris Hermansen · clhermansen "at" gmail "dot" com

C'est ma façon de parler.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20210421/cb936419/attachment.html>


More information about the Qgis-user mailing list