[Qgis-user] trigger action in qgis2web
In my desktop QGIS I have a short Python script that opens an HTML page including arguments (attributes of the selected feature). When I use QGIS2web to put the project on the web, I would like the user to trigger that action when he/she clicks on a feature. I would be grateful for advice on how to do that. = #This is the script for Action "showPhoto" import webbrowser host = "promPics.rf.gd" cName = "[%"common name"%]" lName = "[%"latin name"%]" picture = "[%"picture"%]" theURL = "http://; + host + "/?" theURL = theURL + "cName=" + cName + "&" theURL = theURL + "lName=" + lName + "&" theURL = theURL + "photo=" + picture webbrowser.open(theURL) = If you're interested, you can see an older, two-click, approach at BrooklynProm.epizy.com [Garden B only] ___ 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 trigger an "action" on a web map
In my desktop QGIS project, I define an "action" that opens an HTML page and passes parameters to it. I will use qgis2web to move the project to a web site and would like the web user to trigger that action by clicking on a feature. Is there a way to do this? Steve ___ 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] action to open an HTML file with arguments
Adam - Thanks for your sage advice. Prepending file:// solves my problem when the target HTML file is on my desktop hard drive. The arguments are sent and received correctly. I still have what turns out to be an unimportant problem when the target HTML file is on the web (I use a free web host, InfinityFree): my browser (Chrome) prepends the sending file's URL and then I get error 403 page not found. This turns out to be unimportant because it doesn't occur in QGIS: my action correctly sends arguments to the target HTML on my web site. Many thanks for your help. Steve == On 9/9/2023 7:17 AM, Adam Nielsen wrote: then the web page opens. But if the "Action Text" is C:/temp/receiveParms.html?arg1=C=D the web page fails to open. Probably because a question mark isn't a valid filename character so it gets escaped as %3F, and then the file doesn't exist with %3F in the filename so you get the error. The question mark isn't a traditional URL separator, it's passed to the server unchanged and the server may choose to only look at the part of the filename before the question mark but it doesn't have to. When there is no server and it's just on your filesystem the actual behaviour is probably browser-specific. I wrote sendParms.html which includes the following line: This isn't a valid URL because it doesn't contain a protocol. It would have to be afile:// URL which contains its own rules and semantics. You could try using the hash (#) symbol instead of the question mark, as the browser does not send the part after the hash to the server, so it should work with local files as well (just remember to use the file:// URL scheme to avoid unpredictable behaviour). You can pick out the part after the hash in the HTML by using Javascript code. 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
[Qgis-user] action to open an HTML file with arguments
I want to create a situation where clicking on a feature in a vector layer opens an HTML file and passes several attributes of the feature to the HTML file. I have successfully created an action which opens the HTML file, but I can't figure out how to pass the arguments. My action "type" is "open" and if the "Action Text" is C:/temp/receiveParms.html then the web page opens. But if the "Action Text" is C:/temp/receiveParms.html?arg1=C=D the web page fails to open. I also tried C:/temp/receiveParms.html?arg1="C"="D" and C:/temp/receiveParms.html?arg1=[% "garden" %] where "garden" is the name of an attribute. All of these efforts to pass arguments to an HTML file fail to open the file. In order to verify that receiveParms.html knows how to accept arguments, I wrote sendParms.html which includes the following line: This works as expected, successfully passing two parameters. I'm attaching the two HTML files. I'd be grateful if someone can tell me what I'm doing wrong. Thanks in advance for any suggestions. <<< text/html; charset=UTF-8; name="receiveParms.html": Unrecognized >>> Title: sender5 some text link to receiver ___ 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] mysterious polygon
Hi Harrissou, YES ! You've solved my problem and taught me something I knew nothing about. Many thanks. Steve On 6/10/2023 8:57 PM, Harrissou s. wrote: Hi Stephen, You seem to have fallen in the annotation layer "trap" [0]. There is no layer behind and polygon deletion is mentioned in the docs I pointed to. Basically, select it with the "modify annotations" tool on the same toolbar, and press Del. To create regular polygon feature, you have to select the layer, turn it into edit mode and use digitizing tools. Read [1]. Hope that helps. Harrissou [0] https://docs.qgis.org/3.28/en/docs/user_manual/map_views/map_view.html#interaction [1] https://docs.qgis.org/3.28/en/docs/user_manual/working_with_vector/editing_geometry_attributes.html#digitizing-an-existing-layer Le 11 juin 2023 01:22:43 GMT+02:00, Stephen Sacks via QGIS-User a écrit : My intention was to create a new vector layer consisting of several polygons. I used the CreatePolygon tool to mark the four vertices of a rectangle. I must have done something wrong because I've ended up with a polygon that seems to belong to no layer. In desperation I ran the following python code, hoping to delete the mysterious polygon, but it's still there. Are some layers not in the legend? How do I get rid of the polygon? from qgis.core import QgsProject from qgis.utils import iface project = QgsProject.instance() for lyr in project.mapLayers().values(): lyrName = lyr.name() print (lyrName) QgsProject.instance().removeMapLayers([lyr.id()]) ___ 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] mysterious polygon
My intention was to create a new vector layer consisting of several polygons. I used the CreatePolygon tool to mark the four vertices of a rectangle. I must have done something wrong because I've ended up with a polygon that seems to belong to no layer. In desperation I ran the following python code, hoping to delete the mysterious polygon, but it's still there. Are some layers not in the legend? How do I get rid of the polygon? from qgis.core import QgsProject from qgis.utils import iface project = QgsProject.instance() for lyr in project.mapLayers().values(): lyrName = lyr.name() print (lyrName) QgsProject.instance().removeMapLayers([lyr.id()]) ___ 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] trouble adding a basemap from a WMTS source
It turns out that my problem is not getting the map from New York's DOITT, but in re-projecting it from EPSG:900913 to the project's EPSG:2263. If I leave it in EPSG:900913 it doesn't disappear. But I worry that some trouble may result if my basemap has a different CRS from all the other layers. = Original post (7/4/2022, 8:17 PM): My project CRS is EPSG:2263; all 21 layers were created in this project with CRS EPSG:2263 , which seems appropriate for a public park in Brooklyn, NY. If I use Google Satellite Hybrid as basemap, everything looks to be in the right place. I would like to replace the Google basemap with one of many maps available from the New York City Department of Information Technology & Telecommunications (DOITT https://maps.nyc.gov/tiles/#basemap-layers-wmts). But after many tries, all I get is a totally blank layer. Here, in detail, is what I have done: 1. right-click on WMS/WMTS in browser and choose New Connection 2. name box: DOITT Monday 3. URL: https://maps.nyc.gov/wmts/1.0.0/?REQUEST=getcapabilities 4. leave configuration default: No Authentication leave HTTP and options blank 5. click OK 6. "DOITT Monday" appears as a new item in browser under WMS/WMTS 7. there are 15 sub-items under DOITT Monday. The CRS for each of them is EPSG:900913 , although the DOITT web page led me to expect 4326 or 3857 8. I drag one of them ("basemap") onto the map canvas; right-click on it and set its CRS to EPSG:2263. The project CRS remains 2263. 9. I see a msg at the top of the canvas: "Used a ballpark transform from EPSG:2263 to EPSG:900913" , which seems to me to be the opposite of what I asked for 10. the added layer appears totally blank. Toggling its checkmark in the layer panel has no effect. Zoom-to-layer makes the scale go to a nine-digit number. Zoom to 1:100 has no effect. 11. I tried again, with a new, blank project, with project CRS set to EPSG:900913. I added one layer by dragging "basemap" from "DOITT Monday" onto the canvas. The canvas remained blank. I added one small layer from my real project, transformed it to 900613, and "zoomed to layer" so as to focus on part of my park. My layer appeared but still no visible basemap. What am I doing wrong? Thanks for any advice. Steve ___ 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] trouble adding a basemap from a WMTS source
My project CRS is EPSG:2263; all 21 layers were created in this project with CRS EPSG:2263 , which seems appropriate for a public park in Brooklyn, NY. If I use Google Satellite Hybrid as basemap, everything looks to be in the right place. I would like to replace the Google basemap with one of many maps available from the New York City Department of Information Technology & Telecommunications (DOITT https://maps.nyc.gov/tiles/#basemap-layers-wmts). But after many tries, all I get is a totally blank layer. Here, in detail, is what I have done: 1. right-click on WMS/WMTS in browser and choose New Connection 2. name box: DOITT Monday 3. URL: https://maps.nyc.gov/wmts/1.0.0/?REQUEST=getcapabilities 4. leave configuration default: No Authentication leave HTTP and options blank 5. click OK 6. "DOITT Monday" appears as a new item in browser under WMS/WMTS 7. there are 15 sub-items under DOITT Monday. The CRS for each of them is EPSG:900913 , although the DOITT web page led me to expect 4326 or 3857 8. I drag one of them ("basemap") onto the map canvas; right-click on it and set its CRS to EPSG:2263. The project CRS remains 2263. 9. I see a msg at the top of the canvas: "Used a ballpark transform from EPSG:2263 to EPSG:900913" , which seems to me to be the opposite of what I asked for 10. the added layer appears totally blank. Toggling its checkmark in the layer panel has no effect. Zoom-to-layer makes the scale go to a nine-digit number. Zoom to 1:100 has no effect. 11. I tried again, with a new, blank project, with project CRS set to EPSG:900913. I added one layer by dragging "basemap" from "DOITT Monday" onto the canvas. The canvas remained blank. I added one small layer from my real project, transformed it to 900613, and "zoomed to layer" so as to focus on part of my park. My layer appeared but still no visible basemap. What am I doing wrong? Thanks for any advice. Steve ___ 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] adding a layer from a zipped file
Hi Richard, Your "wild guess" is exactly right. I tested it. I copied file "GardenA.qml" into the same folder where "GardenA.zip" is located. Then told QGIS to add vector layer "GardenA.zip". It added layer "GardenA" using the correct color and labels. A similar test added layer "GardenAtrees.zip" with the correct svg symbol. You've solved the mystery. THANK YOU. I'm not happy with the resulting layer name ("GardenA - GardenA.shp" instead of just "GardenA") so I'll have to change all the layer names. But I can write a Python script to do that.) I've never used geopackages. Something new for me to learn. Cheers, Steve On 5/30/2022 3:44 AM, Richard Duivenvoorde wrote: Hi Stephen, Wild guessing here (not tested). I think: GDAL is responsible for loading the data from shape OR zipped shape QGIS is responsible for loading of a corresponding qml file. Normally, when QGIS (using GDAL) loads foo.shp, it will check if there is a foo.sld or foo.qml NEXT to it, and if so, uses it to STYLE the data. Now if you zipped foo.shp+files into foo.zip... Maybe QGIS is clever enough to ALSO look INTO the zip (and if not, this would be a nice Feature Request...) But else: try to put foo.qml next to the foo.zip But if you zipped the files into bar.zip... Then I would try to put a 'bar.qml' next to it (and hoping that QGIS decides that it has the same 'base name'. If all that fails: I would create a Feature Request for it (or start using Geopackages ...) Note that using geopackages, you also have 1 file, and you can save style INTO the geopackage (and even put more layers+styles into it etc etc). Regards, Richard Duivenvoorde On 5/29/22 19:02, Stephen Sacks via Qgis-user wrote: Hi Phil, Thanks for your reply. This morning I updated my QGIS from version 3.16.3 to version 3.22.7 . With complete optimism, I reloaded several layers from zipped shapefiles, but alas the problem remains: polygons appear in random colors and without labels and point layers have dots instead of the svg icons they have when I load the same layers from the un-zipped six shapefile files. When I examine the zip files with Windows File Explorer, I see the .qml files are there and uncorrupted. I'm using a five-year-old plain vanilla Dell desktop running 64-bit Windows 10. I did the zipping with Thunderbird's Archive. Then, separately, zipped one layer with Windows File Explorer zipper. Same result. Am I doing something wrong? Shall I try updating to QGIS 3.24 ? Is it "stable"? What does it mean that version 3.22 is "stable"? Steve On 5/29/2022 12:03 AM, Phil Wyatt wrote: Hi Stephen, You might let us know your operating system and which version of QGIS you are using because it works as you desire in the latest development (3.24.3) and Long Term Release versions (3.22.7). It may just be a matter of updating QGIS. Cheers - Phil *From:*Qgis-user *On Behalf Of *Stephen Sacks via Qgis-user *Sent:* Sunday, 29 May 2022 5:29 AM *To:* qgis forum *Subject:* [Qgis-user] adding a layer from a zipped file When I write a layer as a shape file, it appears on my C: drive as six files, all with the same name but different extensions. Then I zip those six into a single file (xxx.zip). When I reload that layer from the zip file (Layer > AddLayer > VectorLayer > File > Dataset > xxx.zip), QGIS is almost smart enough to restore the layer correctly. The polygon features are in the right place and their attribute table is correct. *My problem* is that it ignores one of the six files, the "style" file (xxx .qml) which specifies color, labeling, and symbol). Do I have to unzip before restoring layer xxx ? I know I could open the layer's properties and use Style > Load Style from file xxx.qml . But when I'm restoring several layers that's a lot of key strokes (and may require that I unzip). It seems to me that this shouldn't be necessary. [I encounter the same problem with point layers and polygon layers.] ___ 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] adding a layer from a zipped file
Hi Phil, Thanks for your reply. This morning I updated my QGIS from version 3.16.3 to version 3.22.7 . With complete optimism, I reloaded several layers from zipped shapefiles, but alas the problem remains: polygons appear in random colors and without labels and point layers have dots instead of the svg icons they have when I load the same layers from the un-zipped six shapefile files. When I examine the zip files with Windows File Explorer, I see the .qml files are there and uncorrupted. I'm using a five-year-old plain vanilla Dell desktop running 64-bit Windows 10. I did the zipping with Thunderbird's Archive. Then, separately, zipped one layer with Windows File Explorer zipper. Same result. Am I doing something wrong? Shall I try updating to QGIS 3.24 ? Is it "stable"? What does it mean that version 3.22 is "stable"? Steve On 5/29/2022 12:03 AM, Phil Wyatt wrote: Hi Stephen, You might let us know your operating system and which version of QGIS you are using because it works as you desire in the latest development (3.24.3) and Long Term Release versions (3.22.7). It may just be a matter of updating QGIS. Cheers - Phil *From:*Qgis-user *On Behalf Of *Stephen Sacks via Qgis-user *Sent:* Sunday, 29 May 2022 5:29 AM *To:* qgis forum *Subject:* [Qgis-user] adding a layer from a zipped file When I write a layer as a shape file, it appears on my C: drive as six files, all with the same name but different extensions. Then I zip those six into a single file (xxx.zip). When I reload that layer from the zip file (Layer > AddLayer > VectorLayer > File > Dataset > xxx.zip), QGIS is almost smart enough to restore the layer correctly. The polygon features are in the right place and their attribute table is correct. *My problem* is that it ignores one of the six files, the "style" file (xxx .qml) which specifies color, labeling, and symbol). Do I have to unzip before restoring layer xxx ? I know I could open the layer's properties and use Style > Load Style from file xxx.qml . But when I'm restoring several layers that's a lot of key strokes (and may require that I unzip). It seems to me that this shouldn't be necessary. [I encounter the same problem with point layers and polygon layers.] ___ 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] adding a layer from a zipped file
When I write a layer as a shape file, it appears on my C: drive as six files, all with the same name but different extensions. Then I zip those six into a single file (xxx.zip). When I reload that layer from the zip file (Layer > AddLayer > VectorLayer > File > Dataset > xxx.zip), QGIS is almost smart enough to restore the layer correctly. The polygon features are in the right place and their attribute table is correct. *My problem* is that it ignores one of the six files, the "style" file (xxx .qml) which specifies color, labeling, and symbol). Do I have to unzip before restoring layer xxx ? I know I could open the layer's properties and use Style > Load Style from file xxx.qml . But when I'm restoring several layers that's a lot of key strokes (and may require that I unzip). It seems to me that this shouldn't be necessary. [I encounter the same problem with point layers and polygon layers.] ___ 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] quit() and exit()
In case there may be someone out there who is interested in my question, below is Asim's answer (with one correction he made). When run in the Python console, this code causes execution of the script to stop and a window to pop up titled "Execution error" with my explanatory message. And, unlike quit() and exit(), it does NOT terminate QGIS. fName = 'xyz' vrbl = False class MyExcpt(Exception): pass if not vrbl: raise MyExcpt("Unable to find file %s" % fName) print ('abc') ___ 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] quit() and exit()
I would like to terminate a Python script gracefully. Both quit() and exit() not only abort the script but end the entire QGIS app. For example, if a file I want to read doesn't exist, the following four lines of code terminate QGIS: filePath = Path(fName) if not filePath.is_file(): print ('Unable to find file ', fName) exit() Substituting quit() for exit() doesn't help. I could omit both, and put all of the remaining code under an "else" but that seems rather clunky. Any suggestions would be welcome. ___ 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] from xxx import zzz
Please pardon what may be a dumb question from a self- (half-) taught student of Python. I often steal fragments of code from the internet (especially including this forum) and sometimes get an error message like "xxx is not an attribute of yyy" . My problem, I think, is a missing " from xyz import abc". My question to you now is whether there is some way to know what to import, and from which module, for any particular Python statement. More specifically, I get this error message: AttributeError: 'QgsEditFormConfig' object has no attribute 'setHidden' when I run the following code: from qgis.core import QgsProject from qgis.core import * from qgis.utils import iface from qgis.core import * from PyQt5.QtWidgets import QInputDialog from PyQt5.QtWidgets import * from qgis.PyQt.QtCore import * from qgis.gui import * def oneA( lyr, columnName, option ): flds= lyr.fields() indx = flds.indexOf(columnName) config = lyr.editFormConfig() config.setHidden(indx, option) lyr.setEditFormConfig(config) lyr = iface.activeLayer() aField = 'NAME' oneA (lyr, aField, True) When I type this code in the QGIS environment, autocompletion leads me to believe that "setHidden" is allowed after "config." but I must admit I don't understand the meaning of the several choices specified in the parentheses. I'd be grateful if someone would explain that to me. Also, am I correct in thinking that an asterisk following "import" means "everything in this module"? I'm running QGIS 3.16.3 under Windows 10. Thanks in advance for any help. ___ 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] hide attribute from popup window
Sebastian - Your advice is exactly what I needed. It works perfectly. THANK YOU. There's one thing I would add for others who want the same advice: the attribute form is found at the tab called "manage custom forms and field editor configuration" On 3/20/2022 9:18 PM, Sebastian Gutwein wrote: If you change it to hidden in the layer properties>attribute form> widget type you won't see it in the identify window or feature form window. The default is text. On Sun, Mar 20, 2022 at 8:18 PM Stephen Sacks via Qgis-user wrote: I would like to limit which fields appear in the popup window when I click on a feature. In the layer's attribute table, I can Hide a field but it still appears in the popup window when I click a feature with the Identify tool. ___ 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] hide attribute from popup window
I would like to limit which fields appear in the popup window when I click on a feature. In the layer's attribute table, I can Hide a field but it still appears in the popup window when I click a feature with the Identify tool. ___ 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] qgis2web: lost jpg images
I'm using qgis2web to move a map from my desktop (QGIS 3.16) to a web host. It works well except that jpg images, which appear correctly when I click on point features on the desktop, don't appear on the web . Instead, the web version tries to execute a link of the form http://a.b.com/images/http__x.y.com_z_name.jpg where a.b.com is my web site and images is a folder created by qgis2web x.y.com/z is the correct URL for name.jpg This would make sense if qgis2web were to put into the "images" folder a copy of the desired picture (with slashes replaced by underscores in the file name). But the images folder is empty. I don't know how qgis2web is supposed to work: does it intend to put into a folder on my site copies of all the images I use? or is it designed to keep on my site only the corresponding URLs? Possibly related: I've tried to set the default path for the photo field in the attribute table for this layer (Properties > AttributesForm > widgetType=attachment) but it seems to have no effect. If anyone cares to investigate, my URL is temp9.epizy.com . "GardenBtrees" is the layer at issue; I don't yet have photos for any other layer. I'll be grateful for any advice. Steve ___ 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] loadNamedStyle
I'm writing a Python script to load a "qml" style file. The following two lines work correctly: lyr1 = iface.activeLayer() lyr1.loadNamedStyle('xxx.qml') but the following two lines cause an error message: lyr2 = instance.parameterAsSource(parameters, "INPUT", context) lyr2.loadNamedStyle('xxx.qml') AttributeError: QgsProcessingFeatureSource: object has no attribute 'loadNamedStyle' My problem is that lyr1 is a QgsVectorLayer but lyr2 is a QgsProcessingFeatureSource So the issue comes down to how to load a named style file onto a QgsProcessingFeatureSource. The complete code is below. Thanks for any advice. Steve == from qgis import processing from qgis.processing import alg from qgis.core import QgsProject from qgis.utils import iface @alg(name='getMyStyle', label='load BigPicStyle on the active layer (alg)', group='examplescripts', group_label='Example scripts') @alg.input(type=alg.SOURCE, name='INPUT', label='Input vector layer') @alg.input(type=alg.STRING, name='theStyle', label='name of style file') @alg.output(type=alg.STRING, name='OUTPUT', label='output lbl') def getMyStyle(instance, parameters, context, feedback, inputs): """ Asks for a style name and then loads that style. By default, the layer acted on is the active layer, but a dropdown menu lets user choose another layer. """ stylePath = 'C:/Promenade/GIS/data/styles/' whichFile = parameters.get('theStyle') # note: lyr1 is QgsVectorLayer; lyr2 is QgsProcessingFeatureSource lyr1 = iface.activeLayer() lyr2 = instance.parameterAsSource(parameters, "INPUT", context) lyr1.loadNamedStyle(stylePath + whichFile + '.qml') #this works lyr1.triggerRepaint() #next line causes AttributeError: # 'QgsProcessingFeatureSource' object has no attribute 'loadNamedStyle' lyr2.loadNamedStyle(stylePath + whichFile + '.qml') lyr2.triggerRepaint() ___ 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] trouble accessing New York City basemap
I need an orthoimagery basemap layer for a project involving a public park in Brooklyn, NY. I'm hoping that what I want is at : https://maps.nyc.gov/tiles/#aerial-layers-tms . Instructions at: www.maps.nyc.gov/tiles/#qgis tell me to install a plugin called " TileLayer Plugin". I downloaded that plugin (a zip file), but QGIS tells me that it's not compatible with my QGIS 3.16. I'd appreciate advice on how to get either (1) this map with a different plugin, or (2) a different orthoimagery basemap that includes the Brooklyn Promenade. Thanks. Steve ___ 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] On my website, how do I link a photo to a map feature?
On my website is a map created by qgis2web. I need advice on how to link map features to photos ( jpg files). In desktop QGIS I can put file:///C:\[folder]\[subfolder]\[filename] in the attribute table and the user can click on it in the popup. But I don't know how to reference those jpg files when the map is on the web. I can put the photos in a folder on my web host (I'm using InfinityFree) and then I need some way to say "file xxx is in that folder." In some circumstances two dots means parent folder, so I tried using the expression above and replacing the C: with two dots but that didn't become a live link. I'll be grateful if someone will tell me how to do this. ___ 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] qgis2web doesn't include an aerial view layer
I have added to my QGIS project an aerial view from New York City's Dept of Information Techn (DoITT). My problem is that the output from qgis2web includes all my layers except the aerial view. DoITT says its maps are "compatible with most JavaScript web mapping libraries such as OpenLayers, MapBox, Leaflet". Using a google satellite view encounters the same problem. I tried a workaround by clipping the NY layer using a polygon layer (all I need is about one sq mile) but that yields a Python error. Any advice would be welcome. ___ 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] satellite basemap of New York city for qgis2web
Thanks Phil for your reply. My knowledge of html and Java is minimal. I need qgis2web to write it for me. I got an aerial view from Mapbox that looks OK with my polygon and point layers in my desktop QGIS. But qgis2web crashes unless I select OpenLayers or Leaflet. When I send the qgis2web output files to my web host (infinityFree) the aerial view layer is missing. (You can see it at www.temp5.epizy.com, showing a few of the 35 gardens along Brooklyn's Promenade.) I hope a DoITT aerial view will work with qgis2web. I've tried geoServer but can't figure out how to make it give me a DoITT map. ___ 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] satellite basemap of New York city for qgis2web
I want an aerial image from New York City's mapping service (DoITT) to serve as a basemap for my qgis desktop project. I intend to use qgis2web to put on the web my map of Brooklyn's Promenade gardens. It seems that I should be able to click Layer > add Layer > add WMS/WMTS , but I'll need the appropriate URL. The DoITT website has lists of maps but not a URL. Thanks for any help you can offer. Steve ___ 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] getting a base map from Mapbox
YES !!! I went back and re-tried several attempts I had made to get a satellite base map from Mapbox. In every case when I change the "S" in my Mapbox username from uppercase to lowercase it works flawlessly. Thank you Andrea and Jorge (and Ben Hur and Richard who steered me to Mapbox). Steve ___ 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] getting a base map from Mapbox
Hi Jorge, Thanks for your reply to my request for help in getting a base map from Mapbox. I'm using QGIS 3.10.12 - A Coruna on a plain vanilla Dell desktop running Windows 10. When I click on the link in your message my Chrome browser opens a tab showing hundreds of lines of HTML, among which I see frequently my Mapbox user ID (profSacks). So I guess that proves that something is availble to the public. More importantly when I copy the URL from the message you sent and paste it into the URL in the QGIS new layer dialog and click Connect it WORKS ! I have added the Mapbox satellite layer to my QGIS map. I can see the buildings in and around our park. Can you explain why I succeeded using your URL but not mine ? I'm grateful for your help, but now I need to understand. Thanks. Steve ___ 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] getting a base map from Mapbox
For the first time, I'm trying to use a map from Mapbox as a base map in QGIS. I opened an account at Mapbox.com and made a map there using their "Satellite streets." I clicked Publish and chose Publicly available. I copied that map's Style URL and Access token and plugged them and my Mapbox username into what I believe is the correct endpoint template. Then back at my desktop QGIS, I clicked Layer > Add Layer >Add WMS/WMTS layer > new . Then I entered a name and plugged in my custom endpoint URL. Then I clicked OK and saw at the bottom "93546 of 93546 bytes of capabilities downloaded." Then I clicked Connect and got the following message: "Failed to download capabilities". I'd be grateful if someone will tell me what I'm doing wrong. Thanks, Steve Here are the specifics. 1. Source of instructions: https://docs.mapbox.com/help/tutorials/mapbox-arcgis-qgis/ 2. endpoint template from tutorial: https://api.mapbox.com/styles/v1/YOUR_USERNAME/YOUR_STYLE_ID/wmts?access_token=pk.eyJ1IjoicHJvZnNhY2tzIiwiYSI6ImNrbDhnaHFlZTBhb2Yyb25sMThvMTNsd2kifQ.E7N3o-toUEV01DBOt1-FPw 3. endpoint URL with my personal specifics plugged in: https://api.mapbox.com/styles/v1/profSacks/ckl8hw2rm53v918o7e09ig6mq/wmts?access_token=pk.eyJ1IjoicHJvZnNhY2tzIiwiYSI6ImNrbDhnaHFlZTBhb2Yyb25sMThvMTNsd2kifQ.E7N3o-toUEV01DBOt1-FPw 4. error message: Failed to download capabilities: Download of capabilities failed: Error transferring https://api.mapbox.com/styles/v1/profsacks/ckl8hw2rm53v918o7e09ig6mq/wmts? access_token=pk.eyJ1IjoicHJvZnNhY2tzIiwiYSI6ImNrbDhnaHFlZTBhb2Yyb25sMThvMTNsd2kifQ.E7N3o-toUEV01DBOt1-FPw=WMS=GetCapabilities - server replied: Not Found ___ 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] free web host for output of QGIS2web
I want my map to be available on a free web host. QGIS2web seems to do a good job of preparing it for export. My base map is Google Hybrid. Does that mean I must use Google Cloud as web host? Can I use files created by QGIS2web on other web hosts ? (Infinityfree, Byethost, WordPress, WIX, . . . ) Thanks for any advice. Steve ___ 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] Qgis does not start after win10 update
I, too, have been unable to launch QGIS since the recent win10 update. The message I get is "Could not load qgis_app.dll . . . The specified module could not be found. . . . Check C:\ProgramFiles\QGIS3.10\bin\qgis-ltr-bin.env for correct environment paths" I looked at the .env file, where qgis_app.dll isn't mentioned, but there is a line that says "PATH=C:\PROGRA~1\QGIS 3.10\apps\qgis-ltr\bin; . . .[more paths] " I verified that qgis_app.dll is in C:\ProgramFiles\QGIS 3.10\apps\qgis-ltr\bin Does this mean the "missing" dll is where it should be? I would welcome any advice. ___ 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] wishing for accurate lattitude/longitude from a cell phone
In order to make widely available some wise advice, I'm sending to this list a message I received from Neil B. In addition to Neil's message below, I want to mention that Nicolas Cadieux also provided similar information, saying I'd have to pay around $1,000 for equipment that gives consistently accurate location coordinates. And thanks, also to Falk Huettmann and Bernd Vogelgesang for their replies. Message from Neil B: Hello Stephen. Glad that you're having success. I would like to start off by saying that it is best to always reply to the mailing list and not directly to the person who submitted the email. Mailing lists work really well in that there is a pool of people out there who may be able to offer advice or may have an alternate method to solve the problem that may turn out to be a better way. On the flip side by maintaining the email chain through the mailing list, the follow up emails that provide information are stored in the archives which benefits anyone searching the internet to have the complete trail of information. As far as your results they are acceptable for the device you're using. GPS in phones are never built to precision survey standards and there is no reason for them to be. If you're within 30ft of where the phone thinks you should be then you can easily navigate the rest of the way by visual sight. High end equipment to achieve sub-inch accuracy is probably in the range of thousands of dollars. One thing to keep in mind is there is a difference between the accuracy of a device and to what level of precision they display. While the app on the phone may display 8 decimal places of a lat/long coordinate and tell you if you have moved a foot, it doesn't help that the coordinate it is displaying is out +/- 30 feet. The accuracy of a device can also be affected by the environment where the device is being operated. In regards to cell phones, they use multiple sources to determine location such as GPS, cell phone towers, and wifi points to perform the triangulation. Lack of line of sight to satellites, signals from cell towers bouncing off of surrounding buildings, or someone's wireless router using inaccurate position information can all affect the accuracy of what is being displayed on your phone. So the question is how are you determining that the coordinates are wrong? If you have information that you trust to be authoritative then adjust your points to those values and carry on. I have no advice or opinions on inexpensive devices that may help with a more accurate reading. Please do not respond directly to me. This email account is not actively monitored and I don't always have the time to follow up with the emails. All the best with your endeavours. ~Neil B. On Fri, May 15, 2020 at 7:52 PM Stephen Sacks <mailto:sack...@earthlink.net>> wrote: Hi Neil, With your help, I have successfully brought the corners of our gardens back from Pennsylvania to the Promenade here in Brooklyn Heights, New York. Thank you. At the risk of wearing out my welcome, I'm now asking for more advice. My point features are approximately where they should be but not exactly, some points are just a few feet off and some are 10 or even 30 feet off. I imported the data trying both EPSG 4326 and 4269. I'm now convinced that the problem is due to (1) my Google Pixel 3 cellphone, (2) the app I'm using ("Latitude Longitude" published by gps-coordinates), and especially (3) my less-than-steady hands. I capture coordinates by standing at spot, waiting for the blue dot to settle, and then touching the blue dot. Often I don't touch the screen at exactly the right place. I tried another app ("GPS Coordinates" published by Financept) which is better in that it allows me to zoom in, but I'm still not always getting it right. I'm thinking now that I need specialized equipment. That is what I want to ask you. Can you recommend some inexpensive device that will allow me to simply press a button to record accurately the coordinates of the point where I'm standing? Keep in mind that this is a community project with no funding. I live on Social Security and a university pension, but I'm willing to pay something in the range of $50 or a bit more. Do you know of anything at such a modest price, or would I have to pay much more? Or perhaps you know of better software for my Android Pixel 3 phone. Thanks in advance for any advice you might offer. Steve ___ 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] advice on which CRS to use
I'm mapping the location of trees and plants along the famous Promenade in Brooklyn, NY. Above a bottom layer of GoogleSatelliteHybrid, I've drawn polygons representing 35 gardens, and then there are layers for trees in each garden, plants, etc. The project CRS is EPSG:2263 since having coordinates measured in feet is very convenient because volunteers are giving me pieces of graph paper with trees, etc. marked in pencil; each square on the graph paper represents one foot. I want to plot all that relative to the northwest corner of each garden. Now here's my problem. Using my cell phone and an Android app called Lat Long, I captured latitude and longitude at each corner. When I create a layer of garden corners they all appear to be in Pennsylvania. I know that this forum (and many web sites) are full of hundreds of explanations of how to reconcile different CRS's. I've read many lengthy explanations and advice. I'm sorry to be dumb, but I just can't bring those corner points back to Brooklyn. I know that along my gardens the longitude is something like -73.993 degrees (or 985217 feet) and latitude approximately 40.695 degrees (or 193982 feet). And the long and lat reported by my phone is close to that. But when I put long and lat into QGIS (by reading delimited data from a .csv file) the long becomes -77.519 and the lat 40.112 (about 200 miles west and slightly south of where they should be). The .csv file has columns labelled "Longitude" and "Latitude" ; the Data Source Manager > Delimited Text window shows that QGIS got that right. The attribute table of that layer seems to confirm that. I've tried loading the corner points file and then saving it as a shape file with crs 2263, but it still puts those points in Pennsylvania. Any advice would be very welcome. Thanks in advance for your thoughts. Steve ___ 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 rotate a grid
Phil - Thanks for sending that link to a relevant video. I had trouble using it because of the differences between the 2.8 and 3.0 GUI. But the video's mention of using moving and rotating tools turned out to help me solve my problem. Apparently, the "rotation" input box at the bottom of my screen in QGIS 3.4 will rotate all layers, without regard to which ones are selected and/or editable. HOWEVER, if I click on the Toolbox icon at the top of my screen (a gear wheel), it opens a large panel at the right which includes "Rotate" and "Translate" tools which in turn operate on only selected layers. Of course, I should have known this, but I'll claim my circumstance as new to GIS as excuse. Thanks. Steve ___ 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 rotate a grid
I am using QGIS 3.4.12-Madeira . I have successfully superimposed a grid on my map, using two different methods: (1) View > Decorations > Grid and (2) Vector > ResearchTools > grid . With either method I see the grid just as I want it. My problem comes in rotating the grid _without rotating other layers_. Various UTube snippets make it seem easy to adjust the grid's rotation and position to line up with other layers, but when I change the Rotation field at the bottom of my screen all layers rotate. I've tried saving the grid as a new layer, I've tried selecting the grid layer, I've tried selecting all the lines of the grid, but I can't figure out how to rotate just the grid. What am I doing wrong ? Thanks in advance for your advice. Steve ___ 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] shapefile of Europe
To several people who replied to my request for help in finding a shapefile of Europe: Thank You ! You've given me what I need. Steve ___ 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] shapefile of Europe
I would be grateful if someone would tell me where I can get a shapefile for the countries of eastern and western Europe. I want just polygons of country borders. A few major cities would be nice, but I do NOT need streets. I'll want to be able to color each country according to my own list of attributes. I did find an ESRI .lpk file, which I unzipped using 7zip, but it does not seem to contain any shapefiles (two .gdb folders containing dozens of files with extensions I don't know). Geofabrik has individual European countries, including streets, but that's more detail than I want. Thanks for any advice you can offer. Steve ___ 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] features that represent TWO attributes
I'm trying to create a layer with features that reflect two attributes. I want each point to be marked by a circle whose (1) color reflects its type (city, town, or suburb), and whose (2) size reflects its population. From layer properties, I first select Style and choose "Categorized" based on column "Type." This gives me circles with different colors for different types. Then I choose "Graduated" based on column "Population." This gives me circles with different sizes. Unfortunately, setting the sizes wipes out the different colors. I've tried setting the sizes first, but then setting the colors wipes out the different sizes. How do I set both size and color ? I'm using QGIS 2.14.1 on Windows 7. Thanks in advance for your help. Steve ___ Qgis-user mailing list Qgis-user@lists.osgeo.org List info: http://lists.osgeo.org/mailman/listinfo/qgis-user Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-user
[Qgis-user] trouble getting data from OpenStreetMap
Please excuse a naive question from a new QGIS user. I have installed QGIS (version 2.14.1-Essen, code revision ea85bef) on my Dell desktop running Windows 7 Home Premium. I've failed on my very first task, namely to create a layer using data from OpenStreetMap. Very carefully following instructions in the User Guide, I did the following three steps: 1. Vector > OpenStreetMap > Download Data: I chose Manual and entered longitudes -77.0 and -70.0, and lat's 44.0 and 41.0, which roughly encompasses New York and Massachusetts. After some back-and-forth of the progress bar, an .osm file of size 337 bytes appeared on my hard drive and I got a message saying "Download has been successful." 2. Vector > OpenStreetMap > ImportTopologyFromXML: I selected the .osm file just created and accepted the suggested file name for the .db output, and the connection name. The box next to "Create Connection" remained checked. "Import has been successful" message appeared immediately, and a .db file of size nearly 6 MB showed up on my hard drive. 3. Vector > OpenStreetMap > ExportTopologyToSpatialLite: I did this step three times, once for points, once for polylines, and once for polygons. In each case, the input DB file was the db file created in step 2 above. In each case, under Exported tags I chose Load from DB, and in each case not a single tag appeared for me to choose from. For each layer, I got an "Export has been successful" message. However, when the three layers (points, lines, polygons) appeared in the Layers Panel, all of them had zero feature count and all three attribute tables are totally empty. What am I doing wrong ? Why don't I see the streets of New York and Massachusetts ? Thank you in advance for your help. I'll be embarrassed if my error is blindingly obvious. Steve ___ Qgis-user mailing list Qgis-user@lists.osgeo.org List info: http://lists.osgeo.org/mailman/listinfo/qgis-user Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-user