[postgis-users] questions/issues when creating a topology

Lucas Ferreira Mation lucasmation at gmail.com
Thu Feb 25 13:15:32 PST 2016


Pre-Note: This message follows up from a tread with several questions about
how to create a topology from a set of adminsitrative polygons. Strk kindly
helped me solve 6/7 of my original questions (tks!). However I am still
having trhouble with item "2)" of my original question. So I'll ask again
as a follow up on this tread (for future reference)


Original question (rephrased):
2) In most test I did, I got an error when uploading one or two polygons
(out of a 900 polygons in Acre state). How can I add these afterward?
Assume all neighbor polygons have been added to the topogeometry. Thus the
topology already includes a face that would be the equivalente of one of
the error polygons. Let's that I see in QGIS that polygon A correspond to
face 13 of the topogeometry. Can I insert this by "brute force", by editing
the text the corresponding cell of the topogeometry column?


So I found out sector code '290390405000036' (in the original dataset ids)
corresponds to face 13314 of the topogeometry. And I tried to insert this
by "brute" force:
UPDATE temp_geom_bahia2 SET tg_geom_dump_utm = '(28,1,13314,3)' WHERE
cod_setor = '290390405000036'

The desired cell in column tg_geom_dump_utm  of table  temp_geom_bahia2 is
filled.

But when I visualise the topogeom in QGIS it is still empty at the are
where sector '290390405000036' would be.

 the topogeom still displays a hole for that area when I see it in Qgis
(even after updating).

Any ideas on how to insert that?


regard
From: Sandro Santilli <strk at keybit.net>
To: PostGIS Users Discussion <postgis-users at lists.osgeo.org>
Subject: Re: [postgis-users] Topology: error creating aggregated
        topogeom (at city level) from a neighborhoods topogeom
Message-ID: <20160201150444.GB20829 at localhost>
Content-Type: text/plain; charset=us-ascii

On Mon, Feb 01, 2016 at 11:03:14AM -0200, Lucas Ferreira Mation wrote:

> >Here you're trying to pass a "layer_id" as the "type" of component for a
non-hierarchical layer, thus the error

> *TopoElementArray_Agg(ARRAY[(tg_geom_dump_utm).id,(tg_geom_
dump_utm).layer_id])*
> works.

Yes, that's how you're supposed to use it.

> What is not very clear from the syntax is if the syntax of
> *TopoElementArray_Agg
> should follow the child or the parent topogeom "class" (hierarquical or
not)

It's TopoElement that matters, TopoElementArray_Agg is just an
aggregate to collect a set of TopoElement objects.

TopoElement is documented here:
http://postgis.net/docs/manual-2.2/topoelement.html

"second element represents layer identifier of the child TopoGeometry"

> To recap, this is the code that works:

Consider adding it to the PostGIS Wiki !

This may be a good starting point:
http://trac.osgeo.org/postgis/wiki/UsersWikiCreatingTopoGeometryObjects

--strk;


2016-01-25 14:10 GMT-02:00 Lucas Ferreira Mation <lucasmation at gmail.com>:

> 2) update. Apparently my "manual" brute force insertion does not work.
>
> UPDATE temp_geom_bahia2 SET tg_geom_dump_utm = '(28,1,13314,3)' WHERE
> cod_setor = '290390405000036'
>
> The desired cell in column tg_geom_dump_utm  of table  temp_geom_bahia2 is
> filled. But the topogeom still displays a hole for that area when I see it
> in Qgis (even after updating).
>
> Any ideas on how to insert that?
>
>
> regards
> Lucas
>
>
>
>
>
> 2016-01-25 13:26 GMT-02:00 Lucas Ferreira Mation <lucasmation at gmail.com>:
>
>> Sandro,
>>
>> tks very much for the answers. After week to parse and try to implement
>> your sugestions I think we made good progress. Of of the 316k polygons, we
>> get 308 polygons that were not included.
>> Bellow are some follow-up questions (in line bellow).
>>
>>
>>> Message: 1
>>> Date: Sun, 17 Jan 2016 14:23:25 +0100
>>> From: Sandro Santilli <strk at keybit.net>
>>> To: PostGIS Users Discussion <postgis-users at lists.osgeo.org>
>>> Subject: Re: [postgis-users] questions/issues when creating a topology
>>> Message-ID: <20160117132325.GA8245 at localhost>
>>> Content-Type: text/plain; charset=us-ascii
>>>
>>> On Thu, Jan 14, 2016 at 09:57:48AM -0200, Lucas Ferreira Mation wrote:
>>>
>>> > 1) What is the role of ST_Force2D() function in
>>> >  toTopoGeom(ST_Force2D(geom),...) ? The code fails if I omit this
>>> function.
>>> > However my data is already 2D.
>>>
>>> ST_Force2D should make no difference when the input is already 2D.
>>> If it does there's a bug hiding somewhere and you're welcome to
>>> file a ticket about it (with a way to reproduce).
>>>
>>>
>> I actually managed to run most test cases without  the ST_Force2D()
>> function. The only case it did make a difference was when creating a
>> topology with the original SRID (4674 , SIRGAS 2000) and no tolerance
>> parameter. With the  ST_Force2D() wrapipng the input polygons, the loop
>> runs. Without it, there is a crash in the database (connection lost with
>> database).
>>
>>
>>> > 2) In most test I did, I got an error when uploading one or two
>>> polygons
>>> > (out of a 900 polygons in Acre state). How can I add these afterward?
>>> > Assume all the edges that define those error-polygons have already been
>>> > added. How do I define a new face  by those edges and attribute that
>>> to the
>>> > topogeom for these error-polygons?
>>> >
>>> > Let's say polygon A can be defined by edges 1, 2, 3 and 4, which are
>>> > already in the topology when other polygons were inserted. How do I
>>> define
>>> > face A and attribute that to the topogeom?
>>>
>>> Faces are automatically defined. You associate attributes with
>>> TopoGeometry objects, which you can define in your case by specifying
>>> the faces making up the polygon.
>>> See http://postgis.net/docs/manual-dev/CreateTopoGeom.html
>>>
>>>
>>  Ok, got it to work. To document for others. Fist I used QGIS to know the
>> original polygon - face pairs. This is done manually, by overlaying
>> serveral layers (orginal polygons, topgeom, face bounding boxes). For
>> example, from the atached image, I learnt that  I should associate the
>> polygon cod_setor=290390405000036 with face_id=13314 of the corresponding
>> topology. This, this fixes the "hole" in the topology for that polygon
>>
>> UPDATE temp_geom_bahia2 SET tg_geom_dump_utm = '(28,1,13314,3)' WHERE
>> cod_setor = '290390405000036'
>>
>> You may also try to re-run toTopoGeom on the previously failed
>>> polygons. Sometimes the function works when finding a different
>>> starting state.
>>>
>>
>> This worked for 50 aditional cases of of the 358 errors (on the test with
>> UTM reprojected polygons and with tolerance parameter of 1m).
>>
>> I'll now try to increase the tolerance parameter (to say 2m, 5m, 10m) to
>> see if the remaining polygons get added to the topology.
>>
>>
>>>
>>> > 3) Is there a way to manually edit topologies, in QGIS for instance?
>>> I'm
>>> > thinking of a workflow for repairing a map. After doing the automatic
>>> fixes
>>> > in Postgis and creating a topology, someone wants to manually correct
>>> some
>>> > feature. For instance, move an edge or a point, while maintaining the
>>> > topological properties. Is there a QGIS plugin  for that?
>>>
>>> https://plugins.qgis.org/plugins/pgtopoeditor/
>>>
>>>
>> I see cool options to remove find dangling edges, remove edges and points
>> and find Orpaned topogeoms. But supose I wanto to change the shape of an
>> edge, by mooving a few vertices among it's path in QGIS, while preserving
>> the nodes where it intersects with other edges. Is it possible to do that
>> (and preserve the topological properties)? What about moving nodes? Can
>> pgtopoeditor manage that?
>>
>>
>>
>>> > 4) Is not including a tolerance parameter  in to... equivalent to a
>>> zero
>>> > tolerance?
>>>
>>> Yes. This is something that might be good to change in the future
>>> but for now it is the same.
>>>
>>> > 5) Does topology behaves differently depending on whether the SRID is
>>> in
>>> > decimal degrees or meters? Ideally, I would prefer to have the
>>> tolerance
>>> > parameter in meters, as it is a more intuitive unit and have a constant
>>> > amount of "snapping" across the areas. However that means choosing a
>>> > specific UTM zone for reprojecting each state. However states in
>>> Brasil are
>>> > quite large, spanning more then one UTM zone. Even Acre, the small
>>> state I
>>> > used for testing spans two UTM zones
>>>
>>> Topology makes no intepretation of projections.
>>> Coordinates are always considered to be cartesian.
>>>
>>> > 6) I tested creating topologies with the original Sirgas 2000 decimal
>>> > degree spatial reference (srid 4674, a decimal degree system, quite
>>> similar
>>> > to wgs84 but slightly more optimized for Brasil) and also with  a
>>> >  reprojection to a UTM zone (srid 32719), which is where most of the
>>> > polygons are located. The errors are not the same.
>>>
>>> When you pass no (or 0) tolerance, one is computed automatically based
>>> on the minimum drift detectable by a "double precision" number.
>>> Using lat/lon units usually means numbers closer to the 0 thus having
>>> a smaller minimum tolerance. This changes overall results.
>>>
>>> > 7) Has there been any progress on some sort of index for
>>> topogeometries, so
>>> > spatial queries can run faster? (I found this 2013 tread
>>> > <
>>> http://osgeo-org.1560.x6.nabble.com/spatial-index-for-topology-td5085935.html
>>> >on
>>> > the topic, but nothing more recent). Of course one can always cast to
>>> > geometry (topogeom::geometry) and index that, but that is duplicating
>>> the
>>> > information somewhat.
>>>
>>> No progress. A TopoGeometry object is externally defined so cannot really
>>> be indexed on itself. The geometry cast is volatile for this reason,
>>> and cannot be used in an index.
>>>
>>> What you could do is change the select queries to filter on bounding
>>> box of components. It would be a pretty complex query as it'd have to
>>> step by the "relation" table and the "layer" table to finally get
>>> to the real data, which si already indexed.
>>>
>>> Or you could build a cache of bounding boxes, automatically updating
>>> it whenever the primitives in the topology are updated, and use that
>>> column as a filter.
>>>
>>
>> this is interesting idea. Any example on this?
>>
>>
>>>
>>> --strk;
>>>
>>>   ()   Free GIS & Flash consultant/developer
>>>   /\   http://strk.keybit.net/services.html
>>>
>>>
>>> ------------------------------
>>>
>>> Subject: Digest Footer
>>>
>>> _______________________________________________
>>> postgis-users mailing list
>>> postgis-users at lists.osgeo.org
>>> http://lists.osgeo.org/mailman/listinfo/postgis-users
>>>
>>> ------------------------------
>>>
>>> End of postgis-users Digest, Vol 167, Issue 10
>>> **********************************************
>>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20160225/cc96e795/attachment.html>


More information about the postgis-users mailing list