Skip to content

Support exporting vectorLayer to qgis#390

Merged
martinRenou merged 39 commits intogeojupyter:mainfrom
arjxn-py:vectorlayer-qgis
Jan 30, 2025
Merged

Support exporting vectorLayer to qgis#390
martinRenou merged 39 commits intogeojupyter:mainfrom
arjxn-py:vectorlayer-qgis

Conversation

@arjxn-py
Copy link
Member

@arjxn-py arjxn-py commented Jan 24, 2025

Description

Shall close #388

image Fill Single Symbol: image

Fill Graduated:
image

image

Single Symbol Renderer:
image

Categorised Symbology:
image

Graduated Symbology:
image

Line Single Symbol:
image
Line Graduated:
image
Line Categorised:
image


📚 Documentation preview: https://jupytergis--390.org.readthedocs.build/en/390/
💡 JupyterLite preview: https://jupytergis--390.org.readthedocs.build/en/390/lite

@github-actions
Copy link
Contributor

Binder 👈 Launch a Binder on branch arjxn-py/jupytergis/vectorlayer-qgis

@arjxn-py arjxn-py added the enhancement New feature or request label Jan 24, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Jan 24, 2025

Integration tests report: appsharing.space

@gjmooney gjmooney mentioned this pull request Jan 27, 2025
4 tasks
@arjxn-py arjxn-py marked this pull request as ready for review January 27, 2025 10:32
@martinRenou martinRenou requested a review from gjmooney January 27, 2025 11:01
@arjxn-py arjxn-py changed the title [WIP]: Support exporting vectorLayer to qgis Support exporting vectorLayer to qgis Jan 29, 2025
symbol = QgsMarkerSymbol()
elif geometry_type == "line":
symbol = QgsLineSymbol()
symbol.setOutputUnit(Qgis.RenderUnit.Pixels)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably set the output unit to pixels for all the symbol types.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried that but it doesn't look right -
image
Without setting it to pixel for circle -
image

Copy link
Collaborator

@gjmooney gjmooney Jan 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it looks like to get QGIS to look like the jgis we want pixels for the stroke width, but millimeters for the size? We can call setSize on the symbol_layer with 2 * our radius and the units as pixels and it gets pretty close.

doubleradius

Copy link
Member Author

@arjxn-py arjxn-py Jan 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, for categorised rendering there's a long list for radius for some reason than categories itself in case of earthquakes.jgis

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol yea that file is actually in an impossible state from when I was doing the symbology stuff, I should probably fix that 🙃 .

arjxn-py and others added 3 commits January 29, 2025 17:42
@arjxn-py arjxn-py requested a review from gjmooney January 29, 2025 15:42
symbol_layer.setStrokeColor(stroke_color)

stroke_width = color_params.get("stroke-width", 1)
symbol_layer.setStrokeWidth(stroke_width)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QgsLineSymbol has a setWidth instead of a setStrokeWidth and circles use circle-stroke-width (all the circle symbology has a circle- prefix.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 👍🏻

@arjxn-py arjxn-py requested a review from gjmooney January 30, 2025 11:24
@arjxn-py
Copy link
Member Author

arjxn-py commented Jan 30, 2025

I've removed those properties which I'm unable to test (write in jGIS from QGIS) at the moment, I posted this message in relation and would greatly appreciate any input

Comment on lines +163 to +165
components = source.split("/")
file_name = components[-1]
file_name = file_name.split("|")[0]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this actually work when the local file is not in the same folder as the JGIS file?

e.g. if the JGIS file points to the geojson file in another folder ../path/to/my.geo.json?

I understand from the code only my.geo.json will be kept

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's track this in an issue!

Co-authored-by: martinRenou <martin.renou@gmail.com>
Copy link
Collaborator

@gjmooney gjmooney left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Comment on lines +185 to +186
color["fill-color"] = symbol.color().name()
color["stroke-color"] = symbol.color().name()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
color["fill-color"] = symbol.color().name()
color["stroke-color"] = symbol.color().name()
color["fill-color"] = symbol.color().name() + alpha
color["stroke-color"] = symbol.color().name() + alpha

I'm assuming we want this to have the alpha values like the Marker and Line symbols?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed these alpha values because it was resulting in these hex strings which were resulting in Assertion Error

Copy link
Member

@martinRenou martinRenou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the hard work!!

@martinRenou martinRenou merged commit ff7f2d1 into geojupyter:main Jan 30, 2025
13 of 14 checks passed
@arjxn-py arjxn-py deleted the vectorlayer-qgis branch February 3, 2025 11:07
HaudinFlorence pushed a commit to HaudinFlorence/jupytergis that referenced this pull request Jan 28, 2026
* Try exporting vectorLayer to qgis

* add index

* Needed for testing

* add layer_id[4] to layertree

* Update python/jupytergis_qgis/jupytergis_qgis/tests/test_qgis.py

Co-authored-by: martinRenou <martin.renou@gmail.com>

* vector layer exports

* update test

* remove eq.json from test

* add example for geojson from url

* try fixing tests

* stroke color for polygon

* Make graduated symbology work

* Make categorised symbology work

* GUI working

* examples for testing

* use types from jgis, use pixel as units

* circles work nicely

* All ranges in graduated symbology

* make categorised work for fill

* Working for lines too

* some cleanup

* Apply suggestions from code review

Co-authored-by: Greg Mooney <gregory.mooney@quantstack.net>

* Condense export logic into methods

* fix to fill

* fix to line

* Apply suggestions from code review

Co-authored-by: Greg Mooney <gregory.mooney@quantstack.net>

* Avoid setting opacity, stroke_color again

* In fill too

* circle stroke color

* correct path

* try fixing tests

* Give some consideration to circle-radius

* try lean test for now

* Simplify test more for now

* Update python/jupytergis_qgis/jupytergis_qgis/qgis_loader.py

Co-authored-by: martinRenou <martin.renou@gmail.com>

* non intentional typecasting

---------

Co-authored-by: martinRenou <martin.renou@gmail.com>
Co-authored-by: Greg Mooney <gregory.mooney@quantstack.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Export VectorLayer to QGIS does not work

3 participants