Re: [Qgis-user] how to properly reference longitude values in different datasets

2018-12-21 Thread Lee Eddington
As a raster.

Sent from my iPhone

> On Dec 21, 2018, at 12:09 AM, Saber Razmjooei 
>  wrote:
> 
> Did you open your layer as Mesh layer or Raster?
> 
> Cheers
> Saber
> 
>> On Fri, 21 Dec 2018 at 05:59, Lee Eddington  
>> wrote:
>> That worked.
>> 
>> Thanks,
>> Lee
>> 
>> 
>>> On Dec 20, 2018, at 6:06 AM, Saber Razmjooei 
>>>  wrote:
>>> 
>>> Climate Data Operator (CDO):
>>> https://code.mpimet.mpg.de/projects/cdo/
>>> 
>>> cdo sellonlatbox,-180,180,-90,90 input.grib output.grib
>>> 
>>> Regards
>>> Saber
>>> 
 On Thu, 20 Dec 2018 at 13:00, Lee Eddington  
 wrote:
 Can you point me to the external tools?
 
 Thanks,
 Lee
 
 
> On Dec 20, 2018, at 12:46 AM, Saber Razmjooei 
>  wrote:
> 
> This is a known issue and can be fixed with some external tools. 
> I have filed a bug:
> https://issues.qgis.org/issues/20853
> And hopefully get around to fix it in 3.6
> 
> Regards
> Saber
> 
>> On Thu, 20 Dec 2018 at 01:44, Lee Eddington  
>> wrote:
>> I’m pretty new to QGIS and am trying to figure out how to modify 
>> longitude values of layers.  I was able to add a raster layer in GRIB2 
>> format (NCEP global meteorological data).  The longitude values range 
>> from 0 to 360 degrees.  I’m able to view and do calculations on the data 
>> with no problem.  I also added shaded relief and coastline data from 
>> Natural Earth.  This data has longitude values from -180 to 180 degrees. 
>>  So from -180 to 0 degrees I only see the Natural Earth data, from 0 to 
>> 180 degrees I see both datasets and from 180 to 360 degrees I only see 
>> the GRIB2 data.  I want both datasets to be referenced the same with 
>> regards to longitude (-180 to 180, 0 to 360 or whatever).  It seems like 
>> this should be a fairly easy problem to fix by either adding 180 degrees 
>> to longitudes from the Natural Earth data or subtracting 180 from the 
>> GRIB2 longitudes, but I can’t figure out how to do it.
>> 
>> I’m using QGIS version 3.4.1-Madeira.  The CRS I’m working in is what 
>> QGIS put the GRIB2 data into when I added it:   * Generated CRS 
>> (+proj=longlat +a=6371229 +b=6371229 +no_defs)
>> 
>> Thanks,
>> Lee
>> 
>> ___
>> 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
> 
> 
> -- 
> Saber Razmjooei
> www.lutraconsulting.co.uk
> +44 (0)7568 129733
 
>>> 
>>> 
>>> -- 
>>> Saber Razmjooei
>>> www.lutraconsulting.co.uk
>>> +44 (0)7568 129733
>> 
> 
> 
> -- 
> Saber Razmjooei
> www.lutraconsulting.co.uk
> +44 (0)7568 129733
___
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] How to define generic VectorFileWriter

2018-12-21 Thread Reginald
Update 

#capabilities doesn't mean the editortool is toggled

from qgis.PyQt.QtCore import *
from qgis.core import QgsWkbTypes

perceellayer=None
editlayer=None
layers = [layer for layer in QgsProject.instance().mapLayers().values()]
for lyr in layers:
if lyr.name() == "Parcels":
perceellayer = lyr
if lyr.name() == "layername_of_layer_you_want_to_edit":
editlayer = lyr
if not editlayer.isEditable():
editlayer.startEditing()

percelen = []
features = perceellayer.selectedFeatures()
geom = None
for f in features:
if geom == None:
geom = f.geometry()
else:
geom = geom.combine(f.geometry())
velden = editlayer.fields()
prov = editlayer.dataProvider()
feat = QgsFeature(velden)
feat.setGeometry(geom)
iface.openFeatureForm(editlayer,feat,updateFeatureOnly=True,showModal=False)
(res, outFeats) = editlayer.dataProvider().addFeatures([feat])
print("done")

Regards,



--
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] How to define generic VectorFileWriter

2018-12-21 Thread Reginald
Hi,

For those who are interrested in the result I post this script:


#script uses selected features of parcellayer as geometry for editable other
vector layer
#make sure there is only one layer editable, otherwise only the first
occuring layer will be used

from qgis.PyQt.QtCore import *
from qgis.core import QgsWkbTypes

perceellayer=None
editlayer=None
layers = [layer for layer in QgsProject.instance().mapLayers().values()]
for lyr in layers:
if lyr.name() == "parcels":
perceellayer = lyr
if lyr.type() == QgsMapLayer.VectorLayer:
cap = lyr.dataProvider().capabilities()
if cap & QgsVectorDataProvider.AddFeatures:
editlayer = lyr
percelen = []
features = perceellayer.selectedFeatures()
geom = None
for f in features:
if geom == None:
geom = f.geometry()
#perc = f["primarynum"] + f["bisnumber"] + f["expletter"] +
f["expnum"]
else:
geom = geom.combine(f.geometry())   

velden = editlayer.fields()
prov = editlayer.dataProvider()
feat = QgsFeature(velden)
feat.setGeometry(geom)
iface.openFeatureForm(editlayer,feat,updateFeatureOnly=True)
(res, outFeats) = editlayer.dataProvider().addFeatures([feat])
print("done")

///

Regards, 



--
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] Couldn't load SIP module. Python support will be disabled.

2018-12-21 Thread Andre Joost

Am 21.12.18 um 11:08 schrieb Giacomo Fontanelli:

Hi forum

I just installed QGIS 3.4 in Lubuntu 18.10 64 bit using repositories.

When I lunch the application I immediately get an error message

Couldn't load SIP module.
Python support will be disabled.


Traceback (most recent call last):
   File "", line 1, in
   File "/usr/lib/python3/dist-packages/qgis/__init__.py", line 80, in
 import qgis.gui
   File "/usr/lib/python3/dist-packages/qgis/gui/__init__.py", line 27, in
 from qgis._gui import *
RuntimeError: the sip module implements API v12.0 to v12.4 but the
qgis._gui module requires API v12.5



This might be caused by the virtual package sip-py3api-12.5 which should 
be provided by python3-sip (4.19.12+dfsg-1) [universe] using the Ubuntu 
cosmic repo.


If you have python-sip (4.19.13+dfsg-1) from the debian sid repo, it 
provides only virtual sip-api-12.4 and that is not what QGIS is built 
against.


HTH,
Andre Joost


___
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] How to define generic VectorFileWriter

2018-12-21 Thread Reginald
Thanks Nyall,

I found some other information here:

https://gis.stackexchange.com/questions/279734/understanding-qgis-api-documentation

now I'm trying to find out how to print the FileWriter Error object as a
string.

Regards



--
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] How to define generic VectorFileWriter

2018-12-21 Thread Nyall Dawson
On Fri, 21 Dec 2018 at 19:03, Reginald  wrote:
>
> Hi,
>
> I'm trying to implement a way to copy the geometry of selected parcels to an
> editable layer in a qgs project.
> I'm using QGIS 3.4.2.
>
> My code looks like this:
>
> from qgis.PyQt.QtCore import *
> from qgis.core import WKB

This should be

from qgis.core import QgsWkbTypes

See https://qgis.org/pyqgis/master/core/QgsWkbTypes.html

Nyall

>
> perceellayer=None
> editlayer=None
> layers = [layer for layer in QgsProject.instance().mapLayers().values()]
> for lyr in layers:
> if lyr.name() == "Adpf1836007":
> perceellayer = lyr
> if lyr.type() == QgsMapLayer.VectorLayer:
> cap = lyr.dataProvider().capabilities()
> if cap & QgsVectorDataProvider.AddFeatures:
> editlayer = lyr
> percelen = []
> features = perceellayer.selectedFeatures()
> geom = None
> for f in features:
> if geom == None:
> geom = f.geometry()
> else:
> geom = geom.combine(f.geometry())
>
> velden = editlayer.fields()
> fpad = editlayer.dataProvider().dataSourceUri()
> feat = QgsFeature(velden)
> feat.setGeometry(geom)
> fout = QgsVectorFileWriter.writeAsVectorFormat(editlayer, fpad, "31370",
> WKB.Polygon, "ESRI Shapefile")
> if fout == QgsVectorFileWriter.NoError:
> print("succes")
> print("done")
>
> In this example I try to write to a shapefile, but it fails complaining it
> can not import WKB. I would like to write to any kind of Vectorfile
> depending of the vectorfile that was set writeable. Any ideas on how to do
> this? The cookbook is kind of short concerning writing features.
>
> Regards,
>
>
>
> --
> 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

[Qgis-user] Couldn't load SIP module. Python support will be disabled.

2018-12-21 Thread Giacomo Fontanelli
Hi forum

I just installed QGIS 3.4 in Lubuntu 18.10 64 bit using repositories.

When I lunch the application I immediately get an error message

Couldn't load SIP module.
Python support will be disabled.


Traceback (most recent call last):
  File "", line 1, in
  File "/usr/lib/python3/dist-packages/qgis/__init__.py", line 80, in
import qgis.gui
  File "/usr/lib/python3/dist-packages/qgis/gui/__init__.py", line 27, in
from qgis._gui import *
RuntimeError: the sip module implements API v12.0 to v12.4 but the
qgis._gui module requires API v12.5

Python version:
3.6.7 (default, Oct 22 2018, 11:32:17)
[GCC 8.2.0]

QGIS version:
3.4.2-Madeira 'Madeira', 5645791

Python path:
['/usr/share/qgis/python',
'/home/giacomo/.local/share/QGIS/QGIS3/profiles/default/python',
'/home/giacomo/.local/share/QGIS/QGIS3/profiles/default/python/plugins',
'/usr/share/qgis/python/plugins', '/usr/lib/python36.zip',
'/usr/lib/python3.6', '/usr/lib/python3.6/lib-dynload',
'/usr/local/lib/python3.6/dist-packages', '/usr/lib/python3/dist-packages']


I've got QT version 5.1.1.


Could you help me? Thank you
___
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] How to define generic VectorFileWriter

2018-12-21 Thread Reginald
Hi,

I'm trying to implement a way to copy the geometry of selected parcels to an
editable layer in a qgs project.
I'm using QGIS 3.4.2.

My code looks like this:

from qgis.PyQt.QtCore import *
from qgis.core import WKB

perceellayer=None
editlayer=None
layers = [layer for layer in QgsProject.instance().mapLayers().values()]
for lyr in layers:
if lyr.name() == "Adpf1836007":
perceellayer = lyr
if lyr.type() == QgsMapLayer.VectorLayer:
cap = lyr.dataProvider().capabilities()
if cap & QgsVectorDataProvider.AddFeatures:
editlayer = lyr
percelen = []
features = perceellayer.selectedFeatures()
geom = None
for f in features:
if geom == None:
geom = f.geometry()
else:
geom = geom.combine(f.geometry())   

velden = editlayer.fields()
fpad = editlayer.dataProvider().dataSourceUri()
feat = QgsFeature(velden)
feat.setGeometry(geom)
fout = QgsVectorFileWriter.writeAsVectorFormat(editlayer, fpad, "31370",
WKB.Polygon, "ESRI Shapefile")
if fout == QgsVectorFileWriter.NoError:
print("succes")
print("done")

In this example I try to write to a shapefile, but it fails complaining it
can not import WKB. I would like to write to any kind of Vectorfile
depending of the vectorfile that was set writeable. Any ideas on how to do
this? The cookbook is kind of short concerning writing features.

Regards,



--
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