Freehand Raster Georeferencer plugin updated for QGIS 3

A few weeks ago, I updated my Freehand Raster Georeferencer plugin for the newly released QGIS 3. I also included a few fixes for some issues as well as new features such as uniform scaling, a new “Georeference with 2 Points” tool (contributed by a user) or taking into account an existing world file. Those changes were backported to the plugin version for QGIS 2 so there should not be any difference between the QGIS 2 and 3 versions. See the updated doc for information.

toolbar

QGIS 3 was released at the end of February and included quite a few changes when it came to plugin development:

  • The most obvious change was that the version of Python used for plugins is now Python 3. My code was pretty much compatible, except that I had to switch to relative imports and drop the u from strings. I used the standard 2to3 tool to check the code.
  • The second most obvious change was the switch to PyQt 5 (instead of PyQt 4). Again, there were not a lot to changes: Basically, update the imported PyQt modules, as well as change the packages for widgets, now in PyQt5.QtWidgets instead of PyQt4.QtGui. I also had to rebuild the .py fils from the .ui with the pyuic5 tool.
  • I also had to update the metadata with the new QGIS 3 version (qgisMinimumVersion=3.0). I was not sure when I published the plugin for QGIS 3 if the QGIS 2 version would be kept available for users still on QGIS 2, but there was no problem: The QGIS plugin manager shows the latest published version of the plugin compatible with either QGIS 2 or 3, depending on which one is used.
  • Finally there were a lot of API changes. The project has released a list of backwards incompatible changes to help and mostly it was pretty clear what needed to be changed. Here are some more details on a few points:
    • The plugin is based around a QgsPluginLayer and I had to add 2 new classes that were not necessary in QGIS 2: one subclass of QgsDataProvider that needs to be returned by the dataProvider() method of my plugin layer + one subclass of QgsMapLayerRenderer that needs to be returned by the createMapRenderer() method.
    • Checking the visiblity of a QgsMapLayer used to be done with something like iface.legendInterface().isLayerVisible(layer). The QgsLegendInterface class has been removed and replaced by a layer tree API. Now, I am not sure if that is the best way but I performed the checking of the visibility of the map layer with iface.layerTreeView().layerTreeModel().rootGroup().findLayer(layer).itemVisibilityChecked()

The QGIS project has released a tool and some instructions for migrating plugins.

PS: I have my own consultancy and love to work on interesting problems. I have helped several startups and established companies deploy innovative GIS and Data Engineering solutions. Check out some showcases of my work at vellut.com. If you have a project that we can collaborate on, then please contact me at contact@vellut.com

Advertisements

Innov-Agri 2016

Innov-Agri is a large outdoor trade fair for agricultural machinery and equipment. In 2016, it took place in a field near Orléans. A lot of constructors were there and offered live demonstrations of their products. The company I work for was an exhibitor so I went there on the first day of the fair. I walked around and took a few pictures.

Continue reading Innov-Agri 2016

“Freehand Raster Georefencer” plugin for QGIS

Some time ago, I released a plugin for QGIS called “Freehand Raster Georeferencer” that allows interactive raster georeferencing. It implements some tools (move, rotate, scale, stretch…) to manipulate a raster directly on the map, on top of the other layers. This is in contrast with the standard raster georeferencing tool of QGIS, which needs control points and then an export to be able to check the georeferencing.

move

Above, the Move tool.

Once the georeferencing is satisfactory, it is possible to export a new raster with a world file and then import it into QGIS in order to use all the available raster analysis tools. The main limitation of the plugin is the lack of support for all the GDAL raster formats: The plugin actually implements its own raster layer that uses Qt to perform reading and only some raster formats are supported (BMP, JPEG, PNG, TIFF).

The code is opensource and on Github. Here is some documentation on the tools.

PS: I have my own consultancy and love to work on interesting problems. I have helped several startups and established companies deploy innovative GIS and Data Engineering solutions. Check out some showcases of my work at vellut.com. If you have a project that we can collaborate on, then please contact me at contact@vellut.com

Paris in 3D with QGIS and three.js

Some time ago, I saw this article about using the Qgis2threejs plugin to export a QGIS map as a 3D visualisation in the browser, thanks to three.js and WebGL. When I recently tried to follow the post to reproduce the results, I had some problem sourcing the data (related to Vienna, Austria) so instead I searched for data related to Paris to create a similar scene. Here is the result corresponding to the screenshot above and another one with aerial photos, both showing the Montmartre area of Paris.

Continue reading Paris in 3D with QGIS and three.js

Tokyo Ramen Map on the Android app store

Tokyo Ramen Map

I released a free app called Tokyo Ramen Map a few weeks ago on the Play Store. It is a simple map application showing all the ramen restaurants in central Tokyo, along with ratings. I built it for my needs so it is quite bare bones. The main point was to make it work offline since I don’t have a data connection outside my apartment.

It uses cartographic data from the OpenStreetMap project, rendered on the device through the Mapsforge library. The positions and ratings of the ramen restaurants come from scraping the RamenDB website. All the code for the app is open source and available on github. It can also be used to generate OpenStreetMap-based apps for any city, with the option of pre-loading points (like the Ramen app) or letting the user add their own. As an example of the latter, I have released apps for Tokyo (Tokyo Offline Map), without the ramen shop layer, and Geneva (Geneva Offline Map).

PS: I have my own consultancy and love to work on interesting problems. I have helped several startups and established companies deploy innovative GIS and Data Engineering solutions. Check out some showcases of my work at vellut.com. If you have a project that we can collaborate on, then please contact me at contact@vellut.com

iBeacon on Nexus 10 with Android 4.4

Android has added support for Bluetooth Low Energy (aka Bluetooth Smart) and thus iBeacon (a profile of BLE) in version 4.3. However, on my Google Nexus 10 (2012 edition, now running Android 4.4 aka KitKat), support is disabled in the official version provided by Google, even though the hardware supports it. Since I want to try out (and maybe develop) apps that use iBeacons, that makes me very sad… Thankfully, there is a way to enable it, by replacing the original Bluetooth-related libraries on the device with patched libraries that add support for Bluetooth Low Energy.

I have created an update ZIP file for the Nexus 10 (aka Manta) and Android 4.4 build KRT16S: The file can be downloaded from here. It was generated by getting the source of Android (branch android-4.4_r1.2), applying this patch by Manuel Naranjo to reenable Bluetooth Low Energy, recompiling (with target aosp_manta-eng), replacing the content of the update ZIP created by XDA Developers user Keine with the newly compiled libraries and, finally, signing the new ZIP.

!!! Although this seems to work fine for me, I am very new to this so use the ZIP and the instructions below at your own risk !!!

To install (I assume the Nexus 10 has never been rooted or unlocked, which was the case for me):

  • Obtain the Android SDK (for the fastboot and adb tools)
  • Boot to fastboot mode (pressing the Power-Volume Up-Volume Down buttons for some time) and OEM-unlock your device (using “fastboot oem unlock”)
  • Boot to the factory recovery mode (pressing the Power-Volume Up buttons to get past the red triangle) and wipe the user data
  • Boot to Android and reenable USB debugging
  • Boot to fastboot mode and flash a custom recovery image like ClockworkMod (using “fastboot flash recovery recovery-clockwork-6.0.4.3-manta.img “)
  • Boot to the custom recovery mode and apply the update ZIP (by choosing the file from /sdcard; the file can be copied to the Nexus 10 using “adb push …”)
  • Boot to Android (no need to apply the custom recovery image permanently or root the device)

The patch can be tested with an Android app like iBeacon Locate (by the makers of this opensource iBeacon library for Android). I also needed an iBeacon transmitter: I used this opensource Mac OS X application that can run on my Macbook Air running Mavericks (but an iPhone or dedicated hardware could work too).

Here is the Mac OS X application broadcasting the iBeacon advertisement:

Screen Shot 2013-12-11 at 01.00.25

And here is what I get on the Nexus 10:

Screenshot_2013-12-11-00-59-22

Yeaaaah!!!

I was surprised to learn that the Nexus 10 cannot be updated in the usual way (OTA) after this kind of operation. It is possible to rollback to the original libraries of build KRT16S using this  ZIP (the files were obtained through “adb pull /system/lib ~/backup” before applying the BLE update ZIP). Then the new Android build can be installed (for example using sideloading) and the BLE update ZIP reapplied on top (I have tested this with 4.4.2 aka build KOT49H). After an OTA update and before applying the update ZIP, the libraries will have to be backed up to create a new rollback ZIP for that version. Or maybe more simply, the device can be reset to its factory version.

PS: I have my own consultancy and love to work on interesting problems. I have helped several startups and established companies deploy innovative GIS and Data Engineering solutions. Check out some showcases of my work at vellut.com. If you have a project that we can collaborate on, then please contact me at contact@vellut.com