QGIS - Creating a map that uses live data - javascript

I am very new to qgis and qgis server, which I have downloaded the plugins of Openlayers, and qgis2web with qgis 2.18. As an added note, I have a wordpress site which the map will go into. I have created a map with multiple layers. Hooked up database's data to it to populate what midwest state counties people had went to, who had went to those counties, and how many times they have been to that county. Even colored coded it to show case results. Now I am ready to put the map on the web. Here is my Question: How do you put the map on the web so it will show live data from our database we are using?
I have create a map using qgis2web and exporting it and then use place it within my wordpress's wamp server and was able to display it using an iframe. BUT, I assume it only created that one static instance of the map. If the datbase were to update, it will not show the correct mapping results. In so, I want to keep the map constantly connected to the database so it will show live data. How would I show live data and having the map constantly update? I think I have downloaded the qgis server as well, and hopefully set that up correctly. Was thinking of doing that way as well, but no luck. Any help where to start, or what to do is appreciated.

You might want to consider using Rethinkdb. It pushes JSON to your apps in real time. https://github.com/rethinkdb/rethinkdb

When you export a map using qgis2web it will export your layers as a static files. Using the latest version (2.22.0) it goes into the "data" folder and will create a .js file with the geographic information stored as a geojson (https://en.wikipedia.org/wiki/GeoJSON). Now for a feed with live data this will definitely not work.
To achieve a live feed there are a number of ways to build one. There are certain services like Qgis Cloud (https://qgiscloud.com/) or Carto (http://carto.com/) that allow you to do that. However, these service might not necessarily suit your needs. (In Carto's case only the base functionality is free of charge. The features for building a live feed cost.)
If you want to build it yourself I'm not aware of a "simple solution". There are quite a few different ways to build a web GIS. In short you'd need your geodatabase (like postgres with postgis), a map server software (like geoserver) that renders the geographic information in the database as WMS/WFS services that in return can be visualised using Openlayers, Leaflet or other javascript libraries. The resulting map can be implemented on your site (Some CMS come with plugins that ease the process of implementing mapping services. I don't know about wordpress though).
In any case, it is probably best to just refer to already existing answers and tutorials:
https://gis.stackexchange.com/questions/8113/how-to-start-web-mapping

Related

Mapping project - I want to show KML files on a map and be able to sort them based on date, location etc

I am currently undertaking what might be an overly ambitious project for my skill level, but I think I could learn a lot form this exercise.
I work for an aerial surveying company and each time a project is flown, the LiDAR software creates a log file. From this log file, I have written a script that extracts the data and outputs a KML file with data such as flight line numbers, location, height etc.
What I now want to do is write a program that can upload these KML's to a database and show them in a window similar to Google Earth that the user can sort through the flight numbers, locations and dates etc. This would be an incredibly handy piece of software at work and a lot of people would use it, not to mention massive brownie points for my trying to secure a Jnr Dev position in the company going forward.
I know I could mostly use Google Earth to accomplish this task, but for me, it's kind of not the point.
So far, I have looked into Folium and LeafletJS.
https://leafletjs.com
https://pypi.org/project/folium/
Folium can manipulate data and Leaflet can present it, but I am not sure I have the best solution for the job and if it can do exactly what I need to. Especially considering that I only know a little Javascript. I am also not sure if Folium
Ideally, this app would be either a standalone piece of software, or something that my existing script writes to an online server and then can be opened and shown through a browser window. I am biting off more than I can chew with this, but I'm prepared for it to take a little time and be a good learning project. Preferably written in Python.
Any hints or suggestions to what packages I might use would be greatly appreciated. Or, if I am going about this in completely the wrong direction, please let me know.
Thanks a lot.
Welcome to SO.
Here are a few elements that might be useful to you :
leaflet can natively load geojson files. So you could either convert the kml files to geojson using python, or use a leaflet plugin (leaflet-omnivore for example) to read kml files with leaflet. As a first step, I would start with that : a web page that shows one of your flight path. The path data being just a geojson file that is loaded by your app.
then if you want your app to filter flight paths on some criterias, and if you have many of those files, you're going to need a backend. That means a server, with a database, potentially with geo-capabilities (postGIS, mongoDB,... there are many) and a backend application. So your front app (with the js and leaflet) is going to send some requests to your server (send me the file for the flight XYZ please), the backend receives that request, performs a database query, get the file and send it back to the client. The client displays the data on the map.
If you want to write the backend in Python, you can have a look at frameworks like Django or Flask.
That's a lot of tools, but if you start with the js + leaflet part, you will be happy to see a map quickly and will have something to show pretty soon. Then you can start having a look at the backend part. If you manage to get this project done...you definitely deserve that junior dev position.

Graphical map objects representation website

Sorry this question is too broad, but I need any advice, because I'm facing a task bit above my experience level.
The map should be displayed with database objects like restaurants/events/etc. The suggested platform is Python/Django (which is fine both for me and customer) for both frontend and backend. As a map itself I want to use Leaflet because its (presumably) flexible and free. In the first phase there should be just one toolbar with checkboxes, allowing to choose object types to be shown on the map and time range to choose objects.
My draft is the following:
Leaflet (js based) as map
use database for map objects with default Django admin first and add functionality when needed;
use HTML and Django widgets for toolbar, checkboxes and all other stuff;
The only concern is about the frontend/widgets. Is it all likely to work this way? Maybe its definetly better to switch to JS frontend for this type of application (as future planning)?
Your plan seems solid.
Maybe its definetly better to switch to JS frontend for this type of application (as future planning)?
You're already using JS with leaflet, so I assume you're asking about building your own or using a maps service API directly. That approach will take more time, and will lock you into the service API, so I would recommend against it.

Contouring function with OpenLayers3/GeoServer

We're stocking rasters in our database, and we want to implement a function inside our web app that will allow the user to add contour lines to the map based on a raster. We want the user to be able to customize the contour levels and colors.
Do anyone have an idea which tools I should be using? I think that I should be using the Python scripting extension of GeoServer, but I don't know if this is possible to implement such a function.
Thanks for your comments !
The easiest way to create contours on the fly from a raster data source in GeoServer is to use the rendering transform gs:Contour. There is a full example in the documentation. This shows how to use an SLD file to specify the contour values, which are then extracted on render and drawn using the remainder of the SLD file. The example assumes a fixed set of contours using a static file, this is easiest.
But the WMS standard allows a client (OpenLayers) to upload a new SLD file with a map request - this is exactly what you want to do here. I suggest that you generate a working SLD file and then use a templating engine of your choice to insert the user's chosen values into the file before sending it to GeoServer for processing. The downside of this is that you will need to send the SLD file with each request and tiling will probably not work well (at all?). You may be able to speed things up a bit by using library mode for the styles, but at the risk of complicating the client.

Calling Google Visualization API Server-Side

I'm working on a project that involves exporting some HTML reports on a website into PDF format. I'd like to use the excellent flying-saucer Java library to do this but my major stumbling block is that several of these reports use the Google Visualization API to generate charts with JavaScript. Flying-saucer doesn't currently support parsing/executing JS, so those charts don't show up in the generated PDF file.
I was hoping to work around this by seeing if there was some kind of web service I could call instead via server-side code that would return the chart image in Base64 as a variable that I could reference in my view instead of getting it via JS.
The old Google Image Charts API is exactly what I'm looking for, but it has unfortunately been deprecated and it looks like it's slated to be removed completely by next year, so it's not an option.
I'm hoping Google has a newer alternative. If not, is there some other method that's recommended? Thanks!
You can call the getImageURI method of the chart to generate an image/octet stream URI. You can send that data to your server, and you should be able to reconstruct the chart as a .png image file. I've never tried to do this server-side, so I'm not sure precisely how you would go about it, but this java tutorial might be of some assistance to you: http://www.programcreek.com/2009/02/java-convert-image-to-byte-array-convert-byte-array-to-image/
Years ago I wrote Eastwood Charts which implemented the Google Image Charts API as a servlet, backed by JFreeChart, so that you could generate charts without having to rely upon Google, or send your data to their servers. :-)
I don't maintain Eastwood Charts anymore (like Google, I can't be relied upon either) but it is open source and the code works so you might find it helpful. You could also modify it to meet your own requirements, which is something that wasn't possible with the Google service.

show image tiles from database

I am trying to build an asp.net web application (not using Silverlight) which zooms and pans into large images like Seadragon. But I do not like to use the deepzoom composer tool to create this files and store the tiles in some folder structure in my server. I would like to store them in a database. There is an Article here http://www.codeproject.com/Articles/33146/Silverlight-Database-Deep-Zoom which describes very nicely how to do this for the Silverlight version of the deepzoom with multiscaleimage control. My Idea is to achieve something similar but without Silverlight.
Maybe My question is similar to this The correct choice of tools for a new Deep Zoom application, I need your suggestions on how to build a control which can show the tiles from database.
Is your question about creating the tiles and storing them in the database? Or is it assuming you already have that, and wondering how best to display them?
If the latter, I recommend OpenSeadragon:
http://openseadragon.github.io/
You just need to write a custom tilesource to produce URLs for the tiles:
http://openseadragon.github.io/examples/tilesource-custom/
I don't know seadragon or deepzoom but in GIS applications with the help of GeoServer (free) you can serve big raster images with tiled-WMS (web map service).
Please google geoserver and wms-t keywords to check if they are suitable for your project or not.

Categories

Resources