gospodarka-przestrzenna / MongoConnector

Qgis mongodb plugin
GNU General Public License v2.0
10 stars 5 forks source link

Embedded documents support #4

Closed VasiliosKalogirou closed 7 years ago

VasiliosKalogirou commented 8 years ago

Hello,

I want to ask if it's possible to load a collection of which the documents have the coordinates field embedded in them. For example, I have loaded a GeoJSON file in a collection in MongoDB, is it possible to then add this collection using the plugin in QGIS?

Thanks

mk45 commented 8 years ago

Hello,

  1. It is not possible yet.
  2. It might be done soon because I have some time now (I think up to end of the week).
  3. We need to discus details mongo + geojson + QGIS. I really like this idea.
  4. As a workaround for now I propose rewriting values from geometry -> coordinates to ex.: point for each document (mongo). This can be easly done in MongoDB itself. Later You can use plugin.
  5. I believe You have every geojson feature in separate mongo document.
  6. I would like to receive data sample just for reference (few rows).

Best regards. Maciej Kamiński

VasiliosKalogirou commented 8 years ago

Hello Maciej,

All your points were spot on. I have used some random GeoJSON files I downloaded from OpenStreetMap if you would like to have some data for reference; all the datasets downloaded come in the same format. I believe that the real issue could be your in point no.5: A GeoJSON object can contain multiple geometries inside of the same type i.e. we can have a GeoJSON object containing multiple points. As a result, a document in MongoDB will represent multiple features/points.

Kind regards, Vasilios

mk45 commented 7 years ago

I made few modifications so the new version is out. You can download from github and try before i upload into QGIS plugins site. Please tell me if it suits Your needs now.

VasiliosKalogirou commented 7 years ago

Many thanks Maciej. I will look at it tomorrow. Cheers, Vas

VasiliosKalogirou commented 7 years ago

Hi again, I am having some problems installing the plugin. Can you please recommend a way to install it by downloading from GitHub?

mk45 commented 7 years ago
  1. download plugin from github as zip
  2. extract
  3. remove *-master suffix so that directory name would be MongoConnector
  4. copy folder to Your plugins folder and replace old MongoConnector folder. Depends on operating system for me ~/.qgis2/python/plugins/
  5. :( I'll upload it to QGIS plugins in a minute so if You face any issues the just wait.
VasiliosKalogirou commented 7 years ago

Thanks, I have now successfully installed it. It works fine with this format of data:

{ "type": "Feature", "properties": { "id": 1.0, "osm_id": 4757536.0, "name": null, "type": "taxiway" }, "geometry": { "type": "LineString", "coordinates": [ [ 33.284198244997214, 35.144497784256515 ], [ 33.282674834095417, 35.143663533433646 ] ] } } { "type": "Feature", "properties": { "id": 2.0, "osm_id": 5212814.0, "name": null, "type": "runway" }, "geometry": { "type": "LineString", "coordinates": [ [ 33.32026431706737, 35.11236466879344 ], [ 33.320523234056395, 35.110997748023919 ] ] } }

From what I understand, it is difficult to load a feature-collection-type geojson file from mongodb in QGIS, where one document consists of a feature collection made up by multiple points/linestrings/polygons. Please let me know your thoughts on the last one. Many thanks again for making this work.

mk45 commented 7 years ago

Ok super it works for your data. (At least partialy) Yes that http://geojson.org/geojson-spec.html#geometrycollection is a real problem. QGIS allows layer to be one type only. That means we can make it only LineString layer or Multipoligon layer and so on ... After all my work I've done with QGIS I wish they are more data manipulating/driven software rather than CAD-like-drawing-board.

As a workaround I would split geometries into few layers. In future this plugin might add few different layers at once, but now it is beyond its simple design.

VasiliosKalogirou commented 7 years ago

I am actually referring to the feature collection, which is described in section "1.1.Examples" of the same page (geojson.org website). In this case, a feature collection consisting of multiple features is loaded into mongo as one document. GeoJSON files consisting of a feature collection can easily be loaded (drag-and-drop) and read in QGIS. The issue I am facing, is how to visualize this type of data from MongoDB to QGIS, because most GeoJSON files can be found as feature collections.

mk45 commented 7 years ago

Oh I see! It think it would be not what it meant to be. A single document in mongo is limited in size and considered approach would limit drastically size of geojson data that can be stored. Another example. If one keeps data in mongoldb that's probably because of some map-reduce or other data processing features mongo provides. This is only/mostly useful if every feature is in other document. Finally geojson file format is supported (but edit) by QGIS just by drag-and-drop file into QGIS window (layers panel). So no need for mongo here only as an tool of other type.

mk45 commented 7 years ago

Closing ticket now. Vote 5 stars for a plugin if You wish.