umap-project / umap

uMap lets you create maps with OpenStreetMap layers in a minute and embed them in your site.
https://umap-project.org
Other
1.05k stars 213 forks source link

Add a Category type for layers #1433

Open severinmenard opened 7 months ago

severinmenard commented 7 months ago

Sorry if this is being implemented, but I did not find it in the roadmap.

Currently, if you want to have categories in your uMap, you have to create a separate layer for each of them. It would be interesting to allow uMap to add this feature for qualitative data, now that it covers quantitative data with the choropleth feature. Here is how it looks like in QGIS: https://docs.qgis.org/3.28/en/docs/training_manual/vector_classification/classification.html

yohanboniface commented 7 months ago

Hi Severin, can you elaborate a bit on how this feature should be used ? And maybe add a basic example.

Also have you tried the new (while quite basic) facet functionality ? It may be on that direction.

If it helps, let's make a visio so you can explain that to me! :)

Hopes you're well!

differentieel commented 6 months ago

Like to support this request with a project I am working on - where the attached image illustrate the need of having CATEGORIES for layers - if that categories are available they should be visible for the visitor by choice ON or OFF.

For the mapmaker that option organizes his or her work in a much better way.

SECOND: how hard I try to reorder the layers - every time I come back to make changes - the order is set for its own - and not the way I had chosen - if you go for Categories (please do), please check the order mechanism.

UMAP_Category-Layers-plus

The project can be found at https://umap.openstreetmap.fr/nl/map/akkrum-nes-gecombineerde-gebiedsvisie_962780#14/53.0355/5.8489

yohanboniface commented 6 months ago

@differentieel thanks for your feedback! From the user point of view, do you mean something like this proposal ?

https://github.com/umap-project/umap/pull/1351

differentieel commented 6 months ago

@yohanboniface it is something like that - which probably starts by the mapmakers editing area

but please check the ordering of layers for a bug, please (i know that is something else but it effects the same environment ;)

severinmenard commented 6 months ago

Hello @yohanboniface :) !

No, no, no, I meant something different than group of layers. Typical examples of categorized styles :

This kind of layers may have a quite large number of classes, and currently makes their creation in uMap quite complicated. It is super common in mapping software like QGIS (no need to propose color ramps as the example below to start, just the capacity to style every category within a specific field):

Screenshot2144

differentieel commented 6 months ago

@severinmenard @yohanboniface we are typical talking about two different ways of organizing - that interesting - should we address both request in different issues?

yohanboniface commented 6 months ago

@differentieel Yes, I'd say so. Is your category point related to #939 ? And layer ordering related to #375 ?

differentieel commented 6 months ago

@yohanboniface my second point - the ordering of layers- is related to #375

the grouping of layers request seems to be a new request (according to the response of @severinmenard

severinmenard commented 6 months ago

For me https://github.com/umap-project/umap/issues/939 is related to the grouping of layers, not categorizing within a layer. Categories is something you should choose as a layer type (among cluster and co)

yohanboniface commented 6 months ago

@severinmenard here is a "proposal", mainly to see if I understand the need and start a reflexion:

What do you think ? (if it's understandable :p )

yohanboniface commented 6 months ago

ref #60

davidbgk commented 6 months ago

I wonder how it would be efficient (performance wise) with many layers to apply these complex rules to each 🤔

yohanboniface commented 6 months ago

The complexity of the rules is the complexity of the selector (key=value or whatever it becomes); once this selector is computed, it's only about reading in another javascript object (eg. the value of color key if any).

Each rule would be evaluated once for each feature displayed in the map each time a datalayer is shown (which is once in general, but can be hidden/shown by a user, or can be computed again when editing styles properties).

I'd say, the time complexity is linear and indexed to the number of rules AND number of features in the map.

Also, if the rule "selector" becomes more complex (eg. a regex, or a combination of rules: key1 > 3 AND key2 != 'value'), the cost will be higher. And the UX in this case would also be harder. I guess we'd have to find the right set of operators. Arbitrate if we allow combining them (x=y AND (a=b OR c=d)) and if we allow complex operators like regex.

severinmenard commented 6 months ago

@yohanboniface what you are suggesting is actually another way of rendering in QGIS, close to the fancy, new https://docs.qgis.org/3.28/en/docs/user_manual/working_with_vector/vector_properties.html#rule-based-renderer, but what I suggest is the modest, basic https://docs.qgis.org/3.28/en/docs/user_manual/working_with_vector/vector_properties.html#categorized-renderer

yohanboniface commented 6 months ago

The notion of category in QGis in not clear to me (I'm not a QGis user, apart from very basic uses). The documentation explain how to use them, but not for what use cases.

Can you describe some uses cases ? Maybe even pointing me to a given map and explain what you'd like to be able to do in this map ?

What I understand of your need seems close to other needs I've been aware of, and are something like "be able to change the behaviour/style of some features according to their properties, and not to the layer they belong to". So I'm trying to figure out a generic way to cover those cases. But the more use cases I have, the better will be solution we come with ;)

severinmenard commented 6 months ago

Use cases are typically any data organized in classes: roads, land cover, crops... even a simple yes/no/dontwanttoanswer/nr. These classes can be found in a single field. For the user, it is really easy to choose the Categorize rendering, as it automatically creates all existing classes within the field, and the user can focus on styling each of them. One refinement you will find in QGIS is the ability to delete or hide an existing class, or manually add a class that does not yet exist in your dataset, but this can be added later. Rule-based rendering offers much more refinement, of course, but for the many use cases where you just want to render the different classes of a single field, this is a much simpler and faster way to do it for the users.