FLO-2DSoftware / FLO-2DMapCrafter

The QGIS FLO-2D MapCrafter plugin repository
0 stars 0 forks source link

Smooth grid edges #23

Open rpachaly opened 11 months ago

rpachaly commented 11 months ago

Find a way to smooth the grid edges like Mapper

image

image

rpachaly commented 11 months ago

@FLO-2DKaren Hi Karen. Do you have any idea on how to do this on QGIS? I'm trying to find an efficient way to do the same thing that mapper does but nothing seems to smooth the edges the way mapper does.

I need to run a couple of algorithms to get the same mapper result. It will take around 3-5 seconds per map I think.

FLO-2DKaren commented 11 months ago

Did you use raster contour tool?

rpachaly commented 11 months ago

image

To get this kind of result, I follow these steps:

  1. Create the "Contour Polygons" from the raster
  2. Create the "Raster pixel to points"
  3. Create the "Concave hull (k-nearest neighbor)" using the "Raster pixel to points" -> to remove the square edges
  4. Apply the "Smooth" for better visualization using the "Concave hull (k-nearest neighbor)" -> it is not necessary
  5. Clip the "Contour Polygons" with "Smooth" to remove the edges.

It is not efficient but it works.

rpachaly commented 11 months ago

It works fine for continuous data, but for categorized data (e.g. hazard maps) it is bad.

FLO-2DKaren commented 11 months ago

Maybe we should see what the Mapper code is doing. I’ll ask JJ to give us some help.

FLO-2DKaren commented 11 months ago

@FLO-2DJJ hi JJ. Can you tell us how Mapper builds contour maps? If you follow this conversion you’ll get an idea of what’s happening with the raster maps.

rpachaly commented 11 months ago

hould see what the Mapper code is doing. I’ll ask JJ to give us some help.

Great idea! If I have to code everything, I'll have something to be based on.

FLO-2DJJ commented 11 months ago

Yes. I've been following this. Great work Robson. Tomorrow I'll see if there is something that can be done according to my experience with Mapper. It uses a different approach but could show some light on the issue.

On Fri, 27 Oct 2023, 9:51 pm Robson Pachaly, @.***> wrote:

hould see what the Mapper code is doing. I’ll ask JJ to give us some help.

Great idea! If I have to code everything, I'll have something to be based on.

— Reply to this email directly, view it on GitHub https://github.com/FLO-2DSoftware/FLO-2DMapCrafter/issues/23#issuecomment-1783429088, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE32O74OQG46U5FOW7X3Q5LYBQGDFAVCNFSM6AAAAAA6SXGH2WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOBTGQZDSMBYHA . You are receiving this because you were mentioned.Message ID: @.***>

FLO-2DJJ commented 11 months ago
1. Create the "Contour Polygons" from the raster
2. Create the "Raster pixel to points"
3. Create the "Concave hull (k-nearest neighbor)" using the "Raster pixel to points" -> to remove the square edges
4. Apply the "Smooth" for better visualization using the "Concave hull (k-nearest neighbor)" -> it is not necessary
5. Clip the "Contour Polygons" with "Smooth" to remove the edges.

@rpachaly hi Robson, can I see the code you are using here. Do you have a branch with this code so that I can see it? I t doesn't seem to be in the "new_mapping" branch.

rpachaly commented 11 months ago

@FLO-2DJJ Hi JJ,

No, this is not coded yet. This is just the QGIS native algorithms that I intent to use. If you think this is a good approach, I'll code this way. Otherwise, feel free to suggest other approaches.

FLO-2DJJ commented 11 months ago

Ok. No problem. Currently I'm looking at the old Mapper code to see the approach. The code itself is obsolete and no longer supported but it could show a direction to follow. Thanks.

On Sat, 28 Oct 2023, 4:52 pm Robson Pachaly, @.***> wrote:

@FLO-2DJJ https://github.com/FLO-2DJJ Hi JJ,

No, this is not coded yet. This is just the QGIS native algorithms that I intent to use. If you think this is a good approach, I'll code this way. Otherwise, feel free to suggest other approaches.

— Reply to this email directly, view it on GitHub https://github.com/FLO-2DSoftware/FLO-2DMapCrafter/issues/23#issuecomment-1783836928, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE32O77V6ECMDTX7HOQRTWTYBULZHAVCNFSM6AAAAAA6SXGH2WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOBTHAZTMOJSHA . You are receiving this because you were mentioned.Message ID: @.***>

FLO-2DJJ commented 11 months ago

To create filled contours (shaded contours) in the old Mapper, like this Maximum Water Surface Elevation image

it doesn't create contour lines first. Instead it creates a 2D rectangular matrix (280 x 222 in this example) with the value of the variable in each cell (or a very small negative value to indicate novalue). Then it calls a SimplePlot function (SimplePlot was the name software used) to create the the plot. Maybe we could try a similar approach in QGIS. I have not found it yet.

rpachaly commented 11 months ago

Thanks JJ! This is a good direction to follow. I don't think that creating the contours is a good approach, specially for categorized data.

rpachaly commented 11 months ago

The GRASS r.resamp.inter algorithm interpolate the raster values and create a very good internal result. But the edges are still grid-like and it misses some areas close to the raster's edges.

image

rpachaly commented 11 months ago

This plugin is also good. It creates contour polygons from points. https://github.com/ccrook/QGIS-Contour-Plugin

FLO-2DJJ commented 11 months ago

Interesting. I'm going to try creating cell centroids and continue from there.

On Tue, 31 Oct 2023, 5:59 pm Robson Pachaly, @.***> wrote:

This plugin is also good. It creates contour polygons from points. https://github.com/ccrook/QGIS-Contour-Plugin

— Reply to this email directly, view it on GitHub https://github.com/FLO-2DSoftware/FLO-2DMapCrafter/issues/23#issuecomment-1787617992, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE32O74C2JO2PQPCIF5UZE3YCEU5VAVCNFSM6AAAAAA6SXGH2WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOBXGYYTOOJZGI . You are receiving this because you were mentioned.Message ID: @.***>

FLO-2DJJ commented 11 months ago

Yes Robson, the https://github.com/ccrook/QGIS-Contour-Plugin plugin produces acceptable results. Let's try its several options to see if we can adopt it.

imagen

imagen

It creates a 'Vector points' layer.

imagen imagen

imagen imagen

279021435-5e7f41d7-cc66-48ca-bab7-2deb931b2735

rpachaly commented 11 months ago

That looks good! I'm think that the best option so far is to understand the Contour Plugin logic and adapt it to MapCrafter. I was worried about the processing time to create a map, but Mapper also takes some seconds to generate a Shaded Contour map.

FLO-2DKaren commented 11 months ago

I suggest we let the end users figure this out for now. Not many people request contours and those who do should be able to figure it out with the QGIS toolbox. Let's not spend more time on this. We have more important tasks.