Currently, I am trying to write a script to select the visualized points with user interaction. I looked through vtk sources and it seems one can use widget called vtkBoxWidget2 to select. However, I can not find an example in python.
My aim is to let user resize and modify the boxwidget (that's easy with the pipeline ) and then select the points inside of the box and return the selected point ids
I would appreciate if anyone could share a snippet of the codes for this task in python.
Thanks in advance
There is an example where the usage of vtkBoxWidget2 is demonstrated. It is located in the VTK source directory:
interaction/Widgets/Testing/Python/TestInteractorEventRecorder.py
Or just grab it from the VTK repository on github.
Related
I am trying to create an interactive map in R or Python that could be hosted on a website and shared via a link. Creating interactive map is no problem, however I want users with the link to be able to edit the map.
i.e zoom into an area and click on a point and add data to the map.
I would be happy to use R or Python to do this but cannot find any resources to put me in the correct direction. All the resources I am seeing are using pre-existing data whereas I want to create new data on the map and allow others with access to be able to edit to.
Does anyone know some good resources for this type of application?
Thank you.
I am trying to use GTK and libchamplain to display a map from local map data. The application is to be run on computers with no internet connection.
After taking a look at the mapbox.py example it seems like one should replace the NetworkTileSource source with FileTileSource. So I used the minimal.py example to work with FileTileSource:
widget = GtkChamplain.Embed()
widget.set_size_request(640, 480)
tile_source = Champlain.FileTileSource.new_full(
ID,
NAME,
LICENSE_TEXT,
LICENSE_URL,
MIN_ZOOM,
MAX_ZOOM,
TILE_SIZE,
Champlain.MapProjection.MERCATOR,
Champlain.ImageRenderer())
tile_source.load_map_data("map.osm")
widget.get_view().set_map_source(tile_source)
Unfortunately, when running the application, the map is not being displayed, and I receive the following error message:
(minimal.py:26308): libchamplain-WARNING **: NULL pixbuf
Based on some C examples (one, two), I assume that there is a so-called renderer missing, called Memphis, which is C only. It seems like Champlain's ImageRenderer, despite its similar name, is not the right tool for this.
So my question is how I would continue at this point. There are quite a few OSM renderers besides Memphis, probably some written in Python as well, but which one(s) would integrate well with Champlain?
It doesn't have to be be OSM, either. A collection of pre-rendered PNG would be fine with me, too. It's just that the FileTileSource documentation specifically mentions "Loads the OpenStreetMap XML file at the given path", which is why I assume better support for OSM.
Any help is much appreciated.
I managed to do it in a very simplistic way: just organize your tiles respecting the #z#/#x/#y# logic as described in the docs, then don't change anything in that mapbox.py example except the URI. your case, for a file structure on the /tmp directory could look like:
MAX_ZOOM,
TILE_SIZE,
Champlain.MapProjection.MERCATOR,
"file:///tmp/tiles-#Z#/#X#/#Y#.png",
#"https://a.tiles.mapbox.com/v4/mapbox.streets/#Z#/#X#/#Y#.png?access_token=" + ACCESS_TOKEN,
Champlain.ImageRenderer())
still according to the docs, the FileTileSource is meant for using a single osm file. I'm not so sure how that works, I didn't yet try it.
My objective is to generate a python plug-in for QGIS that will open a CSV and define a field within the table to display as a map tip.
I'm trying to achieve this task and have got stuck on trying to set the layer properties using python, rather than opening the 'layer properties' dialog, selecting the Display tab and entering HTML expression...
the HTML expression I'm trying to insert into the layer properties is:
field1= '<b>\"title\"</b><br/>\n'+'[%CONCAT(\'<img src=\"\',\"file\",\'\" width=\"400\"></img>\')%]'
where "title" and "file" are fields within the CSV, giving rise to:
<b>"title"</b><br/>
[%CONCAT('<img src="',"file",'" width="400"></img>')%]
This gives me the right HTML to slot into a relevant place - and it works when I use this manually, but I'm now lost trying to find how to change the layer properties using python...
There seems to be a function called
setDisplayAttributes but I can't really follow the API description well enough to understand whether it is the correct function and I can't find any examples using this function.
Any help would be appreciated - I'm a toddler with Python but probably pre-pubescent with QGIS (Version 2.8 on Windows 10) so if you are able to work in words of less than 47 syllables that would be grand.
Many thanks in advance.
EDIT: I've realised this might not be the right place for this
question so have posted on GIS.stackexchange. My apologies and I will
update whichever one gets answered so that folk can find it. If you
choose to vote this down for my stupidity, so be it.
You can find the other version here:
https://gis.stackexchange.com/questions/169997/qgis-layer-import-csv-and-set-display-html-map-tip-using-python
I have a parent file type that is folderish, and I would like to include a thumbnail of the first page of a child pdf in the template. Can someone roughly outline the tools and process you can imagine would achieve this, so that I can investigate further?
Getting out the first page of pdf can be achieved by using ghostscript.
This is an example script which forms an gostscript command and stores the images. I took this from collective.pdfpeek. Which by the way could solve your problem right away :-)
Until few days ago I would have recommended you not to use it, since it was a little bit buggy, but they recently shipped a new version, so give it a try! I'm not sure whether they now support DX or not.
So the workflow for you should be.
Uploading a PDF
Subscribe modified/creation events.
create image of first page using ghostscript (check my command, or collective.pdfpeek)
store it as blob (NamedBlobImage) on your uploaded pdf.
Also implement some queueing like collective.pdfpeek to not block all your threads with ghostscript commands.
OR
Give collective.pdfpeek a shot!
BTW:
imho on a large scale the preview generation for pdfs needs to be implemented as a service, which stores/manages the images for you.
Are there any packages that allow for the interactive display of GIS shapefiles? I'm looking to create a simple GUI that displays simple shapefiles (coastlines, etc) but can't seem to find where to start. I was originally tasked with doing this in R but I would like to try and use python and Qt.
Mapnik supports GIS shape files and has a Python interface.
I think you can use a combination of the shapefile library for reading files, and shapely for all the processing of the data.
I have used shapely for working with geo data feeds that have been loaded into a database, to work with the point and polygon data.
Per your comments, if you just want to simply display a shapefile in your PyQt app, then really all you need is to convert it to an SVG and display it directly. I have not used this conversion lib but I am sure there are more like it. Then you can just use a QSvgWidget to load and display it