Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create QGIS Plugin #251

Open
rafapereirabr opened this issue Jun 24, 2021 · 13 comments
Open

create QGIS Plugin #251

rafapereirabr opened this issue Jun 24, 2021 · 13 comments
Assignees

Comments

@rafapereirabr
Copy link
Member

No description provided.

@pedro-andrade-inpe
Copy link
Contributor

Maybe it would be interesting to make the data available as Web Feature Services (WFS).

@JoaoCarabetta
Copy link
Collaborator

Web Features Services seems to be the right tool to make geobr data available.

A tutorial on how it works:
https://docs.qgis.org/2.18/en/docs/training_manual/online_resources/wfs.html

I couldn't find a tutorial, though. Does anyone know how to build it?

@rafapereirabr
Copy link
Member Author

I'm not familiar with Web Feature Services (WFS). What is the advanted of WFS instead of the plugin download the geopackage files into QGIS?

@pedro-andrade-inpe
Copy link
Contributor

You do not need to develop a graphical interface, as the user will need only to configure how to access the data through the available funcionalities of QGIS. Additionally, the data will be available to any tool that can read this standard. The disadvantage is that you need a server to provide the data. Tipically we use Geoserver.

@sandrofsousa
Copy link

This might be a stupid comment from a newbie on the package, so please feel free to educate me. Perhaps we should step back a bit and define which problem exactly the plugin would solve on QGIS? I'd say the typical QGIS user would download the data, merge it with a shapefile and move on with his/her spatial analysis. In the Segreg plugin that I developed, the data is stored locally as a table of features that can be saved with the shapefile and reused later. Do you all have in mind cases where this data would be consumed without a shapefile?
This contextualisation might also help others to hop in and contribute.

@rafapereirabr
Copy link
Member Author

Hi @sandrofsousa . Thanks for chipping in. The aim of geobr is to help users easily and efficiently download official spatial data sets of Brazil. Currently, each data set is stored as a geopackage file at our server in Ipea. The Python and R packages basically download those geopackge files from the server given parameters of geography, year, etc etc. We currenly have over 3200 data files summing aprox. 16GB. This means that storaing the data set locally or withing the plugin / r/python pacakges is not an option.

The idea I have in mind for the QGIS plugin would be a simple interface to the Python package. So the user would select a few parameters (basically the same parameters used in the functions of the Python package), and the pluging would download the geopackage data and read it to memory.

@sandrofsousa
Copy link

Oh I see @rafapereirabr, thanks for clarifying. In fact your idea is exactly what I tough, but I failed to articulate it. By downloading I meant only the required data, not the full dataset. The idea proposed by @pedro-andrade-inpe and @JoaoCarabetta seems to be the way, I'll look into it.

@JoaoCarabetta
Copy link
Collaborator

JoaoCarabetta commented Jun 25, 2021

As far as I understood, we have three options:

1. Integrate to QGIS through WFS by creating a geoserver.

Advantages:

  • WFS is a standardized way to share geodata
  • No need to create a user interface

Drawbacks:

  • Create and maintain a geoserver. i.e. we'd need to duplicate all data to a geoserver.
  • We might lose some filtering capabilities that geobr provides (I might be wrong)

2. Integrate to QGIS through WFS by creating a Flask server on top of Python geobr

Advantages:

  • WFS is a standardized way to share geodata
  • No need to create a user interface
  • No need to copy all the data to a new server

Drawbacks:

  • Create and maintain a Flask server that matches WFS standards
  • Maintain a server runing 24/7

3. Integrate to QGIS through Plugin

Advantages:

  • No need to create a server or copy data
  • Ability to control how each dataset will be filtered

Drawbacks:

  • Create and maintain user interface in QGIS that matches the evolution of geobr
  • Plugins are not exactly meant to download data, but to modify data

@rafapereirabr
Copy link
Member Author

An important thing to note regarding data filters. When the user runs :

m <- geobr::read_municipality(code_muni = 4106902 )

the behavior of geobr is to first download one geopackage of all municipalities in the state 41, and only then filter the data to keep the observations where code_muni = 4106902. This means that geobr filters the data set locally. I wanted to clarify this point because it might affect what route we take from here give the 3 options listed by @JoaoCarabetta above.

Not being familiar with WFS nor Flask servers, I would prefer to stick with option 3. Do you guys know any other QGIS plugins that download data that I could have look at?

@sandrofsousa
Copy link

With option 3, the following plugins do something similar. They simply provide an interface that allows to navigate the dataset and select which table is needed, then, the data is saved as a QGIS virtual layer.
istacqgis
cbers4a

Developing the plugin interface is not a big issue, it's done using Qt I can help with that. I had a few breaking points when I updated my plugin from QGIS 2 to 3, besides that it is quite stable.

@JoaoCarabetta
Copy link
Collaborator

I also think that option 3 might be the easiest to implement and maintain.

@sandrofsousa do you mind building a POC that calls a geobr API, maybe read_country, so that we can start developing from there?

If you can, open a PR and add the plugin on a folder called qgis_plugin.

@sandrofsousa
Copy link

I will work on that @JoaoCarabetta and open a PR when I get a minimal example working, it might take a while though :)

@JoaoCarabetta
Copy link
Collaborator

@sandrofsousa did you manage to work on it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants