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

2021-04-21 Thread Nicolas Cadieux
Good pointers Nyall,

I need to start working with this stuff.  

Nicolas Cadieux
https://gitlab.com/njacadieux

> Le 21 avr. 2021 à 21:24, Nyall Dawson  a écrit :
> 
> On Thu, 22 Apr 2021 at 06:43, wxgis  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.
> 
> If you're new to this then I'd suggest skipping the Python part and
> instead making a graphical model using Processing tools to do what you
> want. The visual aspect of making models will help guide you through
> the process, and there's plently of video tutorials on Youtube showing
> how to do this.
> 
> You can even then take the model and automatically convert it directly
> to a Python script with a single button click!
> 
> Hope that helps,
> Nyall
> ___
> Qgis-user mailing list
> Qgis-user@lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user


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

2021-04-21 Thread Stephen Kirby
Nyall and Nicholas (earlier) and qgis list --

This is fantastic information.  I'm going to dive in and see what I can
discover.  Automatic conversion of the model to Python script is definitely
neat! Really appreciate this awesome forum and the availability of QGIS!

Best to all,
Steve

On Wed, Apr 21, 2021 at 7:24 PM Nyall Dawson  wrote:

> On Thu, 22 Apr 2021 at 06:43, wxgis  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.
>
> If you're new to this then I'd suggest skipping the Python part and
> instead making a graphical model using Processing tools to do what you
> want. The visual aspect of making models will help guide you through
> the process, and there's plently of video tutorials on Youtube showing
> how to do this.
>
> You can even then take the model and automatically convert it directly
> to a Python script with a single button click!
>
> Hope that helps,
> Nyall
>
___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user


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

2021-04-21 Thread Nyall Dawson
On Thu, 22 Apr 2021 at 06:43, wxgis  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.

If you're new to this then I'd suggest skipping the Python part and
instead making a graphical model using Processing tools to do what you
want. The visual aspect of making models will help guide you through
the process, and there's plently of video tutorials on Youtube showing
how to do this.

You can even then take the model and automatically convert it directly
to a Python script with a single button click!

Hope that helps,
Nyall
___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user


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

2021-04-21 Thread Nicolas Cadieux
Hi,

Users of this group will give you good information on the QGIS Python api.  You 
can use that.

Another way is to use the python Shapely library.  Using the object.bounds 
method, you will have you xy min and max coordinate.  If you use the geopandas 
library, you can use he same shapely method but use the power on the pandas 
dataframe.  Of course, you can also make a vector query in QGIS and add the 
boundaries limite in a new field.

https://shapely.readthedocs.io/en/stable/manual.html?highlight=bound#object.bounds

You also achieve the same goal using Gdal.  This page is full of code and will 
give you 99% of what you need.

https://pcjericks.github.io/py-gdalogr-cookbook/geometry.html#calculate-envelope-of-a-geometry


Nicolas Cadieux
https://gitlab.com/njacadieux

> Le 21 avr. 2021 à 16:42, wxgis  a écrit :
> 
> 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.
> 
> TIA,
> Steve
> 
> 
> 
> --
> Sent from: http://osgeo-org.1560.x6.nabble.com/QGIS-User-f4125267.html
> ___
> Qgis-user mailing list
> Qgis-user@lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user


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

2021-04-21 Thread wxgis
Chris and list --

"...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."  Thanks
for your answer - from your last sentence Chris, does anyone know of some
python code (or snippets will help too) that can take a country boundary
(i.e., the polygon/lines you mention above) and convert to lat/lon?  Again,
do you recommend I start with an ESRI .shp file?  Can I get country
boundaries from an ESRI .shp file (this is critical for me, i.e., to get
country boundaries) or is there some other type of file I should use? 

I do like the idea of getting elevation from a DEM file.

TIA,
Steve



--
Sent from: http://osgeo-org.1560.x6.nabble.com/QGIS-User-f4125267.html
___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user


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

2021-04-21 Thread chris hermansen
Steve and list,

On Wed, Apr 21, 2021 at 1:41 PM wxgis  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.
___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user


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

2021-04-21 Thread wxgis
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.

TIA,
Steve



--
Sent from: http://osgeo-org.1560.x6.nabble.com/QGIS-User-f4125267.html
___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user