HowTo fix country border topology problem?

16 messages Options
Embed this post
Permalink
Roger André

HowTo fix country border topology problem?

Reply Threaded More More options
Print post
Permalink
Hi GRASS list,

I've imported a shapefile of country polygons and am trying to use
v.clean properly to clean the topology.  Here is what I have done so
far:

  456  v.in.ogr dsn=unep_coastlines.shp -o type=boundary out=unep_countries
  461  v.clean unep_countries out=unep_clean type=boundary
tool=rmdangle,rmsa,break,rmdupl,rmbridge,bpol thresh=-1,0,0,0,0,0
  467  v.centroids unep_clean out=unep_clean_2
  475  v.clean unep_clean_2 out=unep_clean_2_rmdac tool=rmdac thresh=0

After doing this, I see that I still have some strange looking borders
in Asia.  You can see what they look like here -
http://lagerratrobe.blogspot.com/2009/10/using-grass-to-fix-topology.html.
 I'm not 100% sure what the "x" means, but I think it indicates that
the country border is not a solid line.

How can I remove those extra bits, and create proper areas for each country?

Thanks,

Roger
--
_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user
Martin Landa

Re: HowTo fix country border topology problem?

Reply Threaded More More options
Print post
Permalink
Hi,

2009/10/16 Roger André <[hidden email]>:
> After doing this, I see that I still have some strange looking borders
> in Asia.  You can see what they look like here -
> http://lagerratrobe.blogspot.com/2009/10/using-grass-to-fix-topology.html.
>  I'm not 100% sure what the "x" means, but I think it indicates that
> the country border is not a solid line.

probably centroids of extra-small areas? Try to display only centroids
to check it.

d.vect map type=centroid

You can remove areas using

v.clean tool=rmarea thresh=<area threshold value>

Martin

--
Martin Landa <landa.martin gmail.com> * http://gama.fsv.cvut.cz/~landa
_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user
Micha Silver

Re: HowTo fix country border topology problem?

Reply Threaded More More options
Print post
Permalink
In reply to this post by Roger André
Roger André wrote:

> Hi GRASS list,
>
> I've imported a shapefile of country polygons and am trying to use
> v.clean properly to clean the topology.  Here is what I have done so
> far:
>
>   456  v.in.ogr dsn=unep_coastlines.shp -o type=boundary out=unep_countries
>   461  v.clean unep_countries out=unep_clean type=boundary
> tool=rmdangle,rmsa,break,rmdupl,rmbridge,bpol thresh=-1,0,0,0,0,0
>  
I think your list of tools and thresholds is odd:
tool            thresh         result
------------------------------------
rmdangle   -1         ignored
rmsa         0            does nothing

What you need is rmarea with a thresh >0  (as Martin pointed out) in
addition to the break tool.
--
Micha

>   467  v.centroids unep_clean out=unep_clean_2
>   475  v.clean unep_clean_2 out=unep_clean_2_rmdac tool=rmdac thresh=0
>
> After doing this, I see that I still have some strange looking borders
> in Asia.  You can see what they look like here -
> http://lagerratrobe.blogspot.com/2009/10/using-grass-to-fix-topology.html.
>  I'm not 100% sure what the "x" means, but I think it indicates that
> the country border is not a solid line.
>
> How can I remove those extra bits, and create proper areas for each country?
>
> Thanks,
>
> Roger
> --
> _______________________________________________
> grass-user mailing list
> [hidden email]
> http://lists.osgeo.org/mailman/listinfo/grass-user
>
> This mail was received via Mail-SeCure System.
>
>
>  


_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user
Martin Landa

Re: HowTo fix country border topology problem?

Reply Threaded More More options
Print post
Permalink
Hi,

2009/10/16 Micha Silver <[hidden email]>:

[...]

> rmdangle   -1         ignored

no, it is just remove all dangles regardless their length.

Martin

--
Martin Landa <landa.martin gmail.com> * http://gama.fsv.cvut.cz/~landa
_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user
Roger André

Re: HowTo fix country border topology problem?

Reply Threaded More More options
Print post
Permalink
Ok, well now I have a big dissolved polygon with a bunch of small
unconnected lines inside of it.  I'd like to get rid of the lines, and
just have the external border left.

Any ideas?
--



On Fri, Oct 16, 2009 at 1:37 PM, Martin Landa <[hidden email]> wrote:

> Hi,
>
> 2009/10/16 Micha Silver <[hidden email]>:
>
> [...]
>
>> rmdangle   -1         ignored
>
> no, it is just remove all dangles regardless their length.
>
> Martin
>
> --
> Martin Landa <landa.martin gmail.com> * http://gama.fsv.cvut.cz/~landa
>
_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user
Martin Landa

Re: HowTo fix country border topology problem?

Reply Threaded More More options
Print post
Permalink
2009/10/16 Roger André <[hidden email]>:
> Ok, well now I have a big dissolved polygon with a bunch of small
> unconnected lines inside of it.  I'd like to get rid of the lines, and
> just have the external border left.
>
> Any ideas?

in the case that type of those "unconnected lines" is 'line', you can
use 'v.extract' with 'type' parameter to filter desired features.

v.extract in=imap out=omap type=boundary,centroid

Martin

--
Martin Landa <landa.martin gmail.com> * http://gama.fsv.cvut.cz/~landa
_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user
hamish-2

Re: HowTo fix country border topology problem?

Reply Threaded More More options
Print post
Permalink
In reply to this post by Roger André
Roger wrote:
> Ok, well now I have a big dissolved
> polygon with a bunch of small
> unconnected lines inside of it.  I'd like to get rid
> of the lines, and just have the external border left.
>
> Any ideas?

v.extract type=area

?


Hamish




_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user
Roger André

Re: HowTo fix country border topology problem?

Reply Threaded More More options
Print post
Permalink
Tried the v.extract route - it didn't help.  The little segments came
along.  So I decided to look at the original data and pull one the
polygons from it, to see if I could spot anything strange about it.  I
did find something, maybe, maybe one of the experts here can explain
it.

Here is what v.clean reports:

Number of nodes: 55
Number of primitives: 59
Number of points: 0
Number of lines: 0
Number of boundaries: 46
Number of centroids: 13
Number of areas: 13
Number of isles: 9

This country should have 9 areas, which matches the number of isles.
I'm trying to figure out how to remove the extra areas (rmarea thresh
value is tricky), but I wonder if there is a way to make the areas
match the isles?
--


On Fri, Oct 16, 2009 at 2:57 PM, Hamish <[hidden email]> wrote:

> Roger wrote:
>> Ok, well now I have a big dissolved
>> polygon with a bunch of small
>> unconnected lines inside of it.  I'd like to get rid
>> of the lines, and just have the external border left.
>>
>> Any ideas?
>
> v.extract type=area
>
> ?
>
>
> Hamish
>
>
>
>
>
_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user
Martin Landa

Re: HowTo fix country border topology problem?

Reply Threaded More More options
Print post
Permalink
Hi,

2009/10/17 Roger André <[hidden email]>:
> Tried the v.extract route - it didn't help.  The little segments came

sure, because there are no 'lines' - just 'boundaries' and 'centroids'
which constract 'areas'.

> along.  So I decided to look at the original data and pull one the
> polygons from it, to see if I could spot anything strange about it.  I
> did find something, maybe, maybe one of the experts here can explain
> it.
>
> Here is what v.clean reports:
>
> Number of nodes: 55
> Number of primitives: 59
> Number of points: 0
> Number of lines: 0
> Number of boundaries: 46
> Number of centroids: 13
> Number of areas: 13
> Number of isles: 9
>
> This country should have 9 areas, which matches the number of isles.
> I'm trying to figure out how to remove the extra areas (rmarea thresh
> value is tricky), but I wonder if there is a way to make the areas
> match the isles?

I was facing probably to the similar problem, it's described here [1].
Sorry it's in Czech, anyway from the commands you can probably
understand what was the problem. I hope it can help you a bit.

Martin

[1] http://gama.fsv.cvut.cz/wiki/index.php/GRASS_GIS_-_Konzistence_vektorov%C3%BDch_dat

--
Martin Landa <landa.martin gmail.com> * http://gama.fsv.cvut.cz/~landa
_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user
achim

v.to.rast with empty vector-file

Reply Threaded More More options
Print post
Permalink

Dear grass users,

has anyone an idea how to handle v.to.rast, if vector-file is empty? ->
it produces an error and no map is created:

Loading data...
ERROR: Database connection not defined for layer 2

I want an null-raster-map instead.

I created the empty vector map with v.extract (in an script)

Thanks,
Achim






_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user
Markus Metz-2

Re: v.to.rast with empty vector-file

Reply Threaded More More options
Print post
Permalink

Achim Kisseler wrote:

> Dear grass users,
>
> has anyone an idea how to handle v.to.rast, if vector-file is empty? ->
> it produces an error and no map is created:
>
> Loading data...
> ERROR: Database connection not defined for layer 2
>
> I want an null-raster-map instead.
>  
r.mapcalc "nullmap = null()"

???

Markus M
_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user
achim

Re: v.to.rast with empty vector-file

Reply Threaded More More options
Print post
Permalink
Thanks for response, Markus!

I just did that a minute ago.

But I found out that I don't have to handle that exception in my case: I
do a r.patch further on, which works even if one raster-file is missing.
So there is no need of an null-map anymore.

Thanks again,
Achim


Markus Metz schrieb:

>
> Achim Kisseler wrote:
>> Dear grass users,
>>
>> has anyone an idea how to handle v.to.rast, if vector-file is empty? ->
>> it produces an error and no map is created:
>>
>> Loading data...
>> ERROR: Database connection not defined for layer 2
>>
>> I want an null-raster-map instead.
>>  
> r.mapcalc "nullmap = null()"
>
> ???
>
> Markus M
_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user
Roger André

Re: HowTo fix country border topology problem?

Reply Threaded More More options
Print post
Permalink
In reply to this post by Martin Landa
Hi Martin,

Thanks, that is a exactly the problem.  Your page is perfect for
showing the cause and solution.

One question though, since the solution relies on removing polygons
whose areas are less than a minimum threshold, how can we do this
accurately with a global data set?  I suppose I could extract each
country, reproject it to a local projection, clean out the bad
polygons, then reproject to lat/lon, and finally patch all of the
separate countries back into single file.

Roger
--



On Sat, Oct 17, 2009 at 12:57 AM, Martin Landa <[hidden email]> wrote:

> Hi,
>
> 2009/10/17 Roger André <[hidden email]>:
>> Tried the v.extract route - it didn't help.  The little segments came
>
> sure, because there are no 'lines' - just 'boundaries' and 'centroids'
> which constract 'areas'.
>
>> along.  So I decided to look at the original data and pull one the
>> polygons from it, to see if I could spot anything strange about it.  I
>> did find something, maybe, maybe one of the experts here can explain
>> it.
>>
>> Here is what v.clean reports:
>>
>> Number of nodes: 55
>> Number of primitives: 59
>> Number of points: 0
>> Number of lines: 0
>> Number of boundaries: 46
>> Number of centroids: 13
>> Number of areas: 13
>> Number of isles: 9
>>
>> This country should have 9 areas, which matches the number of isles.
>> I'm trying to figure out how to remove the extra areas (rmarea thresh
>> value is tricky), but I wonder if there is a way to make the areas
>> match the isles?
>
> I was facing probably to the similar problem, it's described here [1].
> Sorry it's in Czech, anyway from the commands you can probably
> understand what was the problem. I hope it can help you a bit.
>
> Martin
>
> [1] http://gama.fsv.cvut.cz/wiki/index.php/GRASS_GIS_-_Konzistence_vektorov%C3%BDch_dat
>
> --
> Martin Landa <landa.martin gmail.com> * http://gama.fsv.cvut.cz/~landa
>
_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user
Brent Wood

Re: HowTo fix country border topology problem?

Reply Threaded More More options
Print post
Permalink
In reply to this post by Roger André
Roger,

If you load the data into PostGIS, this sort of operation is relatively
trivial....

One of the reasons I don't use GRASS is that projections are tied to
workspaces, instead of datasets & I use data in several projections
concurrently, I don't want to have to keep several copies of the same
dataset as required by GRASS.

If you are interested in looking at this approach, feel free to contact
me.

Brent Wood

Cheers,

  Brent Wood

Brent Wood
DBA/GIS consultant
NIWA, Wellington
New Zealand
>>> Roger André<[hidden email]> 10/18/09 6:03 AM >>>
Hi Martin,

Thanks, that is a exactly the problem.  Your page is perfect for
showing the cause and solution.

One question though, since the solution relies on removing polygons
whose areas are less than a minimum threshold, how can we do this
accurately with a global data set?  I suppose I could extract each
country, reproject it to a local projection, clean out the bad
polygons, then reproject to lat/lon, and finally patch all of the
separate countries back into single file.

Roger
--



On Sat, Oct 17, 2009 at 12:57 AM, Martin Landa <[hidden email]>
wrote:

> Hi,
>
> 2009/10/17 Roger André <[hidden email]>:
>> Tried the v.extract route - it didn't help.  The little segments came
>
> sure, because there are no 'lines' - just 'boundaries' and 'centroids'
> which constract 'areas'.
>
>> along.  So I decided to look at the original data and pull one the
>> polygons from it, to see if I could spot anything strange about it.
I

>> did find something, maybe, maybe one of the experts here can explain
>> it.
>>
>> Here is what v.clean reports:
>>
>> Number of nodes: 55
>> Number of primitives: 59
>> Number of points: 0
>> Number of lines: 0
>> Number of boundaries: 46
>> Number of centroids: 13
>> Number of areas: 13
>> Number of isles: 9
>>
>> This country should have 9 areas, which matches the number of isles.
>> I'm trying to figure out how to remove the extra areas (rmarea thresh
>> value is tricky), but I wonder if there is a way to make the areas
>> match the isles?
>
> I was facing probably to the similar problem, it's described here [1].
> Sorry it's in Czech, anyway from the commands you can probably
> understand what was the problem. I hope it can help you a bit.
>
> Martin
>
> [1]
http://gama.fsv.cvut.cz/wiki/index.php/GRASS_GIS_-_Konzistence_vektorov%C3%BDch_dat
>
> --
> Martin Landa <landa.martin gmail.com> * http://gama.fsv.cvut.cz/~landa
>
_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user

NIWA is the trading name of the National Institute of Water &
Atmospheric Research Ltd.
_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user
Martin Landa

Re: HowTo fix country border topology problem?

Reply Threaded More More options
Print post
Permalink
Hi,

2009/10/18 Brent Wood <[hidden email]>:
> One of the reasons I don't use GRASS is that projections are tied to
> workspaces, instead of datasets & I use data in several projections
> concurrently, I don't want to have to keep several copies of the same
> dataset as required by GRASS.

right, projection is related to GRASS location. Or better to say all
data layers from one GRASS location need to be in the same projection.

If you have data layers in different projections, for every projection
you need to have separate GRASS location and re-project vector layers
by manually (v.proj). This could be simplified with GRASS 7 and better
OGR support. Then you could access different e.g. PostGIS layers
directly. Those layers would be reprojected by PostGIS into projection
matching GRASS location settings.

Martin

--
Martin Landa <landa.martin gmail.com> * http://gama.fsv.cvut.cz/~landa
_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user
Markus Metz-2

Re: HowTo fix country border topology problem?

Reply Threaded More More options
Print post
Permalink
In reply to this post by Roger André

Roger André wrote:

> Hi Martin,
>
> Thanks, that is a exactly the problem.  Your page is perfect for
> showing the cause and solution.
>
> One question though, since the solution relies on removing polygons
> whose areas are less than a minimum threshold, how can we do this
> accurately with a global data set?  I suppose I could extract each
> country, reproject it to a local projection, clean out the bad
> polygons, then reproject to lat/lon, and finally patch all of the
> separate countries back into single file.
>  
AFAIK, v.clean tool=rmarea calculates area sizes in square meters for
latlon locations, no need to reproject, it should be accurate enough.

Markus M

> Roger
> --
>
>
>
> On Sat, Oct 17, 2009 at 12:57 AM, Martin Landa <[hidden email]> wrote:
>  
>> Hi,
>>
>> 2009/10/17 Roger André <[hidden email]>:
>>    
>>> Tried the v.extract route - it didn't help.  The little segments came
>>>      
>> sure, because there are no 'lines' - just 'boundaries' and 'centroids'
>> which constract 'areas'.
>>
>>    
>>> along.  So I decided to look at the original data and pull one the
>>> polygons from it, to see if I could spot anything strange about it.  I
>>> did find something, maybe, maybe one of the experts here can explain
>>> it.
>>>
>>> Here is what v.clean reports:
>>>
>>> Number of nodes: 55
>>> Number of primitives: 59
>>> Number of points: 0
>>> Number of lines: 0
>>> Number of boundaries: 46
>>> Number of centroids: 13
>>> Number of areas: 13
>>> Number of isles: 9
>>>
>>> This country should have 9 areas, which matches the number of isles.
>>> I'm trying to figure out how to remove the extra areas (rmarea thresh
>>> value is tricky), but I wonder if there is a way to make the areas
>>> match the isles?
>>>      
>> I was facing probably to the similar problem, it's described here [1].
>> Sorry it's in Czech, anyway from the commands you can probably
>> understand what was the problem. I hope it can help you a bit.
>>
>> Martin
>>
>> [1] http://gama.fsv.cvut.cz/wiki/index.php/GRASS_GIS_-_Konzistence_vektorov%C3%BDch_dat
>>
>> --
>> Martin Landa <landa.martin gmail.com> * http://gama.fsv.cvut.cz/~landa
>>
>>    
> _______________________________________________
> grass-user mailing list
> [hidden email]
> http://lists.osgeo.org/mailman/listinfo/grass-user
>
>  
_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user