[Qgis-user] Projection change of Open Street Map in python

2023-12-28 Thread noshin prachi via QGIS-User
Dear all,

I am trying to create a map in python where I have a shape file in the BTM
projection system. I want to add OpenStreetMap as the base map under the
shape file. Can anyone suggest me how to change the coordinate system of
the map in python?


Regards,
Noshin Saiyara
___
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] MIKE dfsu file in QGIS

2023-12-20 Thread noshin prachi via QGIS-User
Dear all,
I am trying to make a mike dfsu file visible in QGIS. For that I have used
MDAL  DHI Drivers. Now I have this dfsu file visible in QGIS. But when I am
trying to get this map using Jupyter , all the layers from QGIS get
visible in the map except the dfsu file. Can anyone suggest any solution
for this?

Regards,
Noshin Saiyara
___
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] Accessing iface from jupyter

2023-12-12 Thread noshin prachi via QGIS-User
Thank you for your response. I have succeeded in adding all the shapefiles
and google map layer in my map. I have another type of file which is mike
dfsu file.I have added the layer dictionary in the attachment. I have five
dfsu files as you can see. I need to make each layer active one at a time
and create a map. So there will be five maps finally. But I can't find any
resource with a solution for handling such files. Can you share any way to
add such a file in a map?
[image: image.png]

Regards,
Noshin Saiyara




On Fri, 8 Dec 2023 at 03:15, Thomas Gratier 
wrote:

> Hi,
>
> iface is only accessible via QGIS console. It's not available within
> Jupyter. See the examples for standalone usage of PyQGIS to manipulate QGIS
> project, create an UI
> https://gist.github.com/ThomasG77/f711853e5fb81c746d2a1af0b2a9ecf5 and
> run some PyQGIS things within Jupyter
> https://gist.github.com/ThomasG77/223064813d8aefda5b3cdb05c2588fa1
> Links more to help you getting started on a right track when doing
> standalone dev using PyQGIS.
>
> Regards
>
> Thomas GRATIER
>
> Le mar. 5 déc. 2023 à 11:38, noshin prachi via QGIS-User <
> qgis-user@lists.osgeo.org> a écrit :
>
>> Dear all,
>> I am trying to create a map from qgis using jupyter. I have few layers
>> that need to be added to the map. I have tried to add iface by importing
>> iface   from qgis.utils import iface, plugins . But I am getting the
>> following error.
>> [image: image.png]
>>
>> Please help me in this regard.
>>
>> Regards,
>> Noshin Saiyara
>> ___
>> 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] Accessing iface from jupyter to create map from QGIS

2023-12-06 Thread noshin prachi via QGIS-User
Thank you Adam for your response. I have imported iface from from
qgis.utils import iface. I am working in qgis environment.   It is my first
work with qgis and I am finding it difficult to understand. Can you please
share where I am going wrong? Is there any other way to activate a layer
from multiple layers and create a map?  I have google street map , shape
file and dfsu file in these layers which are required to be added in the
map.

On Wed, 6 Dec 2023 at 18:10, Adam Nielsen via QGIS-User <
qgis-user@lists.osgeo.org> wrote:

> > While trying to activate with iface.setactivelayer I am facing an error.
>
> The error is complaining that iface is None.  Your code doesn't show
> what value you assigned to this variable - where did you set iface and
> what value did you set it to?  I think you forgot to set it and that is
> why you are getting this error.
>
> Cheers,
> Adam.
> ___
> 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
>

(base) C:\Users\FFWS>conda activate qgis

(qgis) C:\Users\FFWS>jupyter notebook
[I 2023-12-06 15:20:33.915 ServerApp] Package notebook took 0.s to import
[I 2023-12-06 15:20:33.962 ServerApp] Package jupyter_lsp took 0.0473s to import
[W 2023-12-06 15:20:33.962 ServerApp] A `_jupyter_server_extension_points` 
function was not found in jupyter_lsp. Instead, a 
`_jupyter_server_extension_paths` function was found and will be used for now. 
This function name will be deprecated in future releases of Jupyter Server.
[I 2023-12-06 15:20:33.993 ServerApp] Package jupyter_server_terminals took 
0.0269s to import
[I 2023-12-06 15:20:33.993 ServerApp] Package jupyterlab took 0.s to import
[I 2023-12-06 15:20:34.087 ServerApp] Package notebook_shim took 0.s to 
import
[W 2023-12-06 15:20:34.087 ServerApp] A `_jupyter_server_extension_points` 
function was not found in notebook_shim. Instead, a 
`_jupyter_server_extension_paths` function was found and will be used for now. 
This function name will be deprecated in future releases of Jupyter Server.
[I 2023-12-06 15:20:34.087 ServerApp] jupyter_lsp | extension was successfully 
linked.
[I 2023-12-06 15:20:34.102 ServerApp] jupyter_server_terminals | extension was 
successfully linked.
[I 2023-12-06 15:20:34.118 ServerApp] jupyterlab | extension was successfully 
linked.
[I 2023-12-06 15:20:34.118 ServerApp] notebook | extension was successfully 
linked.
[I 2023-12-06 15:20:34.477 ServerApp] notebook_shim | extension was 
successfully linked.
[I 2023-12-06 15:20:34.509 ServerApp] notebook_shim | extension was 
successfully loaded.
[I 2023-12-06 15:20:34.509 ServerApp] jupyter_lsp | extension was successfully 
loaded.
[I 2023-12-06 15:20:34.509 ServerApp] jupyter_server_terminals | extension was 
successfully loaded.
[I 2023-12-06 15:20:34.524 LabApp] JupyterLab extension loaded from 
C:\Users\FFWS\anaconda3\envs\qgis\lib\site-packages\jupyterlab
[I 2023-12-06 15:20:34.524 LabApp] JupyterLab application directory is 
C:\Users\FFWS\anaconda3\envs\qgis\share\jupyter\lab
[I 2023-12-06 15:20:34.524 LabApp] Extension Manager is 'pypi'.
[I 2023-12-06 15:20:34.524 ServerApp] jupyterlab | extension was successfully 
loaded.
[I 2023-12-06 15:20:34.524 ServerApp] notebook | extension was successfully 
loaded.
[I 2023-12-06 15:20:34.524 ServerApp] Serving notebooks from local directory: 
C:\Users\FFWS
[I 2023-12-06 15:20:34.524 ServerApp] Jupyter Server 2.10.0 is running at:
[I 2023-12-06 15:20:34.524 ServerApp] 
http://localhost:/tree?token=99f5ac6fd1ec2cac299b0dcc61f5392edd69a7bbed37f1eb
[I 2023-12-06 15:20:34.524 ServerApp] 
http://127.0.0.1:/tree?token=99f5ac6fd1ec2cac299b0dcc61f5392edd69a7bbed37f1eb
[I 2023-12-06 15:20:34.524 ServerApp] Use Control-C to stop this server and 
shut down all kernels (twice to skip confirmation).
[C 2023-12-06 15:20:34.571 ServerApp]

To access the server, open this file in a browser:

file:///C:/Users/FFWS/AppData/Roaming/jupyter/runtime/jpserver-5788-open.html
Or copy and paste one of these URLs:

http://localhost:/tree?token=99f5ac6fd1ec2cac299b0dcc61f5392edd69a7bbed37f1eb

http://127.0.0.1:/tree?token=99f5ac6fd1ec2cac299b0dcc61f5392edd69a7bbed37f1eb
[I 2023-12-06 15:20:34.665 ServerApp] Skipped non-installed server(s): 
bash-language-server, dockerfile-language-server-nodejs, 
javascript-typescript-langserver, jedi-language-server, julia-language-server, 
pyright, python-language-server, python-lsp-server, r-languageserver, 
sql-language-server, texlab, typescript-language-server, 
unified-language-server, vscode-css-languageserver-bin, 
vscode-html-languageserver-bin, vscode-json-languageserver-bin, 
yaml-language-server
[I 2023-12-06 15:20:41.701 ServerApp] Creating new notebook in
[I 2023-12-06 15:20:48.258 ServerApp] Kernel started: 
67fc13ce-4b7f-4808-88c7-72f2aff472c6
[I 20

[Qgis-user] Accessing iface from jupyter to create map from QGIS

2023-12-05 Thread noshin prachi via QGIS-User
Dear all,
I am trying to create a map from qgis. I have added a few layers and
created a layout in qgis. All I want is to create a script to get a map
from the layer on the layout that I have created in qgis. I have attached
the code. I am thinking of activating each layer at a time so that only the
activated layer will be on the layout and a map will get generated. While
trying to activate with iface.setactivelayer I am facing an error. So no
layer is added to the layout. I have added the code  and image of the
generated map.
[image: Day-1.png]

[image: image.png]

How to access the layer in qgis? how to deactivate the first layer and then
move to the next layer for the next map.

Regards,
Noshin
#!/usr/bin/env python
# coding: utf-8

# In[61]:


import os
from datetime import datetime, timedelta
from qgis.core import (
QgsGeometry,
QgsMapSettings,
QgsPrintLayout,
QgsMapSettings,
QgsMapRendererParallelJob,
QgsLayoutItemLabel,
QgsLayoutItemLegend,
QgsLayoutItemMap,
QgsLayoutItemPolygon,
QgsLayoutItemScaleBar,
QgsLayoutExporter,
QgsLayoutItem,
QgsLayoutPoint,
QgsLayoutSize,
QgsUnitTypes,
QgsProject,
QgsFillSymbol,
QgsAbstractValidityCheck,
check,
)

from qgis.PyQt.QtGui import (
QPolygonF,
QColor,
)

from qgis.PyQt.QtCore import (
QPointF,
QRectF,
QSize,
)


# In[70]:


project_path = r"C:\Users\FFWS\Desktop\Boundary_Generation_For_2D\2D Overland 
Flow Model-Boundary Generation\2D Overland Flow Model-Boundary 
Generation\bin\Debug\C2_FloodMap_SERM_V01.qgz"

project_instance = QgsProject.instance()

project_instance.read(project_path)
print(project_instance.fileName())


# In[71]:


map_layers = QgsProject.instance().mapLayersByName('V1054_SWRM_SW_2D 
PS_LR_Dike_Updt_statBaseFlood Map_Day01')[0]
iface.setActiveLayer(map_layers)


# In[64]:


projectInstance = QgsProject.instance()
layoutmanager = projectInstance.layoutManager()
layout = layoutmanager.layoutByName("SW_Day_1")


# In[65]:


map_label = QgsLayoutItemLabel(layout)


# In[67]:


firstDay ="2023-11-25 09:00:00"

dateTimeObj = datetime.strptime(firstDay, "%Y-%m-%d %I:%M:%S" )

secDay=(dateTimeObj+ timedelta(days = 1))

PreparedDayValue = secDay.strftime('%Y-%m-%d %I:%M:%S')
map_label.setText("Valid for: " +firstDay.strip('"')+ " "+"to" +" 
"+PreparedDayValue + ", Prepared on: " +  firstDay)



# In[68]:


layout.removeLayoutItem(map_label)
layout.addLayoutItem(map_label)


# In[69]:


map_label.attemptMove(QgsLayoutPoint(1.6, 0.5, QgsUnitTypes.LayoutInches))
exporter = QgsLayoutExporter(layout)
exporter.exportToImage(r"C:\Users\FFWS\Desktop\Boundary_Generation_For_2D\2D 
Overland Flow Model-Boundary Generation\2D Overland Flow Model-Boundary 
Generation\bin\Debug\Day-1.png", QgsLayoutExporter.ImageExportSettings() )


# In[ ]:




___
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] Accessing iface from jupyter

2023-12-05 Thread noshin prachi via QGIS-User
Dear all,
I am trying to create a map from qgis using jupyter. I have few layers that
need to be added to the map. I have tried to add iface by importing iface
 from qgis.utils import iface, plugins . But I am getting the following
error.
[image: image.png]

Please help me in this regard.

Regards,
Noshin Saiyara
___
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] PyQGIS Jupyter Notebooks on Windows Using Conda

2023-12-03 Thread noshin prachi via QGIS-User
Dear all,
I am trying to create a conda environment with qgis which will be ready to
be used in a Jupyter notebook. I have added all the steps that I have
followed in the attachment named steps. I have copied path from qgis which
is being opened  from the conda environment.
But when I am trying to use  from qgis.core import QgsApplication,
QgsVectorLayer, QgsProcessingFeedback   - I am getting an error message
that the qgis module does not exist.

I am using windows 10, python 3.10.9, qgis 3.30. Please help me in this
regard

Best regards,
Noshin Saiyara

(base) C:\Users\FFWS>conda create -n qgis python=3.10.9
WARNING: A conda environment already exists at 
'C:\Users\FFWS\anaconda3\envs\qgis'
Remove existing environment (y/[n])? n


CondaSystemExit: Exiting.


(base) C:\Users\FFWS>conda activate qgis

(qgis) C:\Users\FFWS>python
Python 3.10.9 | packaged by Anaconda, Inc. | (main, Mar  8 2023, 10:42:25) [MSC 
v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()

(qgis) C:\Users\FFWS>conda install -c conda-forge qgis=3.30.0
Collecting package metadata (current_repodata.json): done
Solving environment: unsuccessful initial attempt using frozen solve. Retrying 
with flexible solve.
Collecting package metadata (repodata.json): done
Solving environment: done


==> WARNING: A newer version of conda exists. <==
  current version: 23.5.0
  latest version: 23.10.0

Please update conda by running

$ conda update -n base -c defaults conda

Or to minimize the number of packages updated during conda update use

 conda install conda=23.10.0



## Package Plan ##

  environment location: C:\Users\FFWS\anaconda3\envs\qgis

  added / updated specs:
- qgis=3.30.0


The following packages will be downloaded:

package|build
---|-
python-3.10.9  |h4de0772_0_cpython15.1 MB  conda-forge
python_abi-3.10|  4_cp310   7 KB  conda-forge

   Total:15.2 MB

The following NEW packages will be INSTALLED:

  blas   conda-forge/win-64::blas-2.120-mkl
  blas-devel conda-forge/win-64::blas-devel-3.9.0-20_win64_mkl
  blosc  conda-forge/win-64::blosc-1.21.5-hdccc3a2_0
  boost-cpp  conda-forge/win-64::boost-cpp-1.78.0-h9f4b32c_4
  brotli-python  conda-forge/win-64::brotli-python-1.1.0-py310h00ffb61_1
  cairo  conda-forge/win-64::cairo-1.16.0-hd694305_1014
  ceres-solver   conda-forge/win-64::ceres-solver-2.1.0-h45bfb9c_2
  certificonda-forge/noarch::certifi-2023.11.17-pyhd8ed1ab_0
  cfitsioconda-forge/win-64::cfitsio-4.2.0-h9ebe7e4_0
  charset-normalizer conda-forge/noarch::charset-normalizer-3.3.2-pyhd8ed1ab_0
  coverage   conda-forge/win-64::coverage-7.3.2-py310h8d17308_0
  curl   conda-forge/win-64::curl-8.1.2-h68f0423_0
  draco  conda-forge/win-64::draco-1.5.6-h181d51b_0
  eigen  conda-forge/win-64::eigen-3.4.0-h91493d7_0
  exiv2  conda-forge/win-64::exiv2-0.27.6-hadc2d18_1
  expat  conda-forge/win-64::expat-2.5.0-h63175ca_1
  font-ttf-dejavu-s~ 
conda-forge/noarch::font-ttf-dejavu-sans-mono-2.37-hab24e00_0
  font-ttf-inconsol~ conda-forge/noarch::font-ttf-inconsolata-3.000-h77eed37_0
  font-ttf-source-c~ 
conda-forge/noarch::font-ttf-source-code-pro-2.038-h77eed37_0
  font-ttf-ubuntuconda-forge/noarch::font-ttf-ubuntu-0.83-h77eed37_1
  fontconfig conda-forge/win-64::fontconfig-2.14.2-hbde0cde_0
  fonts-conda-ecosy~ conda-forge/noarch::fonts-conda-ecosystem-1-0
  fonts-conda-forge  conda-forge/noarch::fonts-conda-forge-1-0
  freetype   conda-forge/win-64::freetype-2.12.1-hdaf720e_2
  freexl conda-forge/win-64::freexl-1.0.6-h67ca5e6_1
  future conda-forge/noarch::future-0.18.3-pyhd8ed1ab_0
  gdal   conda-forge/win-64::gdal-3.6.3-py310h644bc08_0
  geos   conda-forge/win-64::geos-3.11.1-h1537add_0
  geotiffconda-forge/win-64::geotiff-1.7.1-hb4c6682_7
  gettextconda-forge/win-64::gettext-0.21.1-h5728263_0
  gflags conda-forge/win-64::gflags-2.2.2-ha925a31_1004
  glib   conda-forge/win-64::glib-2.78.1-h12be248_0
  glib-tools conda-forge/win-64::glib-tools-2.78.1-h12be248_0
  glog   conda-forge/win-64::glog-0.6.0-h4797de2_0
  gslconda-forge/win-64::gsl-2.7-hdfb1a43_0
  gst-plugins-base   conda-forge/win-64::gst-plugins-base-1.22.7-h001b923_0
  gstreamer  conda-forge/win-64::gstreamer-1.22.7-hb4038d2_0
  hdf4   conda-forge/win-64::hdf4-4.2.15-h1334946_6
  hdf5   conda-forge/win-64::hdf5-1.12.2-nompi_h57737ce_101
  httplib2   conda-forge/noarch::httplib2-0.22.0-pyhd8ed1ab_0
  icuco