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

[Feat] v.out.postgis enhancement #406

Closed
Doctor-Who opened this issue Mar 9, 2020 · 5 comments
Closed

[Feat] v.out.postgis enhancement #406

Doctor-Who opened this issue Mar 9, 2020 · 5 comments
Labels
enhancement New feature or request

Comments

@Doctor-Who
Copy link

Is your feature request related to a problem? Please describe.

With v.out.postgis everything is correctly exported from GRASS to PostGIS database but taking from an hour to 4-6 hours to be reimported.
v.out.ogr is faster 10 to 30 minutes but layer rendering is different with overlap and duplicate feature.

Input layer example :
Some of features are duplicated or overlapping.

Outlook-wbhwtoba

v.out.org result :
GRASS cuts and intersects everything but duplicate (underlap / overlap) are still keep even if we use layer argument (try 0 or 1 or 2),
0 keep only duplicate, 1 keep everything, 2 is empty or not exists.

Outlook-anrrpmh5

v.out.postgis result :
GRASS cuts everything and there is no under or overlap with other object. I've got one and perfectly clean layer.

image

Describe the solution you'd like
Same quality of v.out.postgis but as fast as v.out.ogr

Describe alternatives you've considered
Export v.out.org > GPKG and then reimport GPKG to PostGIS ... Bad alternative from my opinion.

Additional context
We produce "heavy" layer such as Urban Atlas, High Resolution Layer, (for Copernicus Land Monitoring). Lot of nodes, polygons, etc.

@landam landam added the enhancement New feature or request label Mar 11, 2020
@Doctor-Who
Copy link
Author

Just a small update, if you need I fund that enhancement it's not a problem but I can do that only until end of this year :/

@metzm
Copy link
Contributor

metzm commented Nov 1, 2020

The result of v.out.ogr is correct, the result of v.out.postgis is wrong.

If I understand correctly, the vector to be exported has been imported previously with v.in.ogr. Please provide a sample dataset for testing in shapefile, GeoPackage or similar format.

More detailed explanations:
When a vector with overlapping polygons is imported, the overlapping parts are converted to a topological vector representation: the overlapping parts are represented as separate topological areas and get the categories of all overlapping polygons. These category values are stored in layer 1, if only one OGR layer has been imported. In this case, the number of overlapping polygons is stored as category value in layer 2. Topological areas that represent overlapping parts of input polygons can be identified by selecting areas that have a category in layer 2. In a topological representation, overlaps are areas with more than one category in layer 1. Such overlaps can be resolved by deleting the wrong category value(s) from areas with several category values in layer 1. The user has to decide which category values are wrong.

See also vector categories

@Doctor-Who
Copy link
Author

Thanks for your explanation. I understand well now but I'm trying to find an automatic full GRASS way.
I will prepare tomorrow a sample dataset.

From now, example data from PostGreSQL :
image
Dark blue area are duplicates. Dark blue area with non white linear but light blue are underneath the bigger polygon.
Everything has unique gid value.

Import PostGIS > GRASS with v.clean - snap, v.clean - break
image
Everything has been cut out, got perfect topology with some duplicated geometries.
Got unique cat value except for exact duplicate object but other v.clean function, such remove duplicate geometries are not working due to what you explain during our training session and here.

From now, I've export with v.out.ogr to PostGIS and use following SQL query ;

DELETE FROM schema.layer AS a
    USING schema.layer AS b
WHERE a.gid > b.gid AND ST_Equals(a.geom, b.geom);

Is there an automatic way in GRASS to do that or should we consider to add a new v.clean function for that (We can see how to fund that) ?

image
Result is fine, no duplicate and topology fit perfect.

@Doctor-Who
Copy link
Author

Dear @metzm
Please find a GPKG with sample data downloadable here : https://cloud.sirs-fr.com/index.php/s/emcazNaF7XaqagQ
It contains a landcover database after snap, clean process and with exact geometries duplicate
An other layer will help you to locate those cases.

@Doctor-Who
Copy link
Author

Solve by using v.out.ogr instead and then clean duplicate with PostGIS

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

No branches or pull requests

3 participants