From kea raster with Raster Attribute Table to shapefile with attribute table

86 views
Skip to first unread message

Alexandra Mates

unread,
Jul 14, 2014, 11:41:15 AM7/14/14
to rsgislib...@googlegroups.com
I have a kea file with a RAT that I'd like to convert into a smoothed polygon shapefile, maintaining the attribute table. I was wondering whether anyone has already investigated into this task, and if there is a relatively straightforward way around it, using either the open source GEOBIA libraries or proprietary software? GDAL / RSGISlib / ArcMap doesn't seem to support it.

Thanks!

Daniel Clewley

unread,
Jul 14, 2014, 12:07:27 PM7/14/14
to Alexandra Mates, rsgislib...@googlegroups.com
Hi Alex,

I'd do something like the following:

1) Use gdal_polygonize to convert to a vector (attributed with object ID).
2) Export the columns you want from the RAT to and ASCII file using rastergis.export2Ascii
3) Join attribute table from the polygons with the ASCII file using QGIS or ArcMap

As for smoothing the polygons I'm not sure the best way to go about this.

Thanks,

Dan

--
You received this message because you are subscribed to the Google Groups "RSGISLib Support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rsgislib-suppo...@googlegroups.com.
To post to this group, send email to rsgislib...@googlegroups.com.
Visit this group at http://groups.google.com/group/rsgislib-support.
For more options, visit https://groups.google.com/d/optout.

Pete Bunting [pfb]

unread,
Jul 15, 2014, 3:11:25 AM7/15/14
to Dan Clewley, Alexandra Mates, rsgislib...@googlegroups.com
Hi Alex, 

Smoothing polygons and ensuring they are topologically correct (i.e., no gaps and/or slithers) it quite difficult and we don’t have anything implemented for this. You would probably want to store the polygons within topological file format / structure (i.e., postgis - is there a smoothing function in there?) to help implement this.

If you just want to smooth them and aren’t worried about the topology then you could just apply a morphological closing - this is not within the python binding yet but is within the RSGISLib XML interface. However, it’s worth noting that the file size will significantly increase as a lot of nodes are added to the polygons. 

Best wishes, 

Pete
****************************************************
* Dr Pete Bunting
* Senior Lecturer in Remote Sensing
* Earth Observation and Ecosystem Dynamics Group
* Department of Geography and Earth Sciences
* Aberystwyth University
* Aberystwyth
* Ceredigion
* SY23 3DB
* UK

* Ph: +44 (0) 1970 622615
* Mob: +44 (0) 7917 842743
* Email: p...@aber.ac.uk
* ORCID: http://orcid.org/0000-0002-7435-0148
****************************************************

Alexandra Mates

unread,
Jul 15, 2014, 12:48:59 PM7/15/14
to rsgislib...@googlegroups.com, alexand...@envsys.co.uk
Thanks Dan, it works well for exporting a given column, apart from the fact that it doesn't export the FID column which is I believe necessary for the join, and I don't know how to refer to it. I tried 'FID', 'OBJECTID', '', 'DN'.




On Monday, 14 July 2014 17:07:27 UTC+1, Dan Clewley wrote:
Hi Alex,

I'd do something like the following:

1) Use gdal_polygonize to convert to a vector (attributed with object ID).
2) Export the columns you want from the RAT to and ASCII file using rastergis.export2Ascii
3) Join attribute table from the polygons with the ASCII file using QGIS or ArcMap

As for smoothing the polygons I'm not sure the best way to go about this.

Thanks,

Dan
On 14 Jul 2014, at 16:41, Alexandra Mates <alexand...@envsys.co.uk> wrote:

I have a kea file with a RAT that I'd like to convert into a smoothed polygon shapefile, maintaining the attribute table. I was wondering whether anyone has already investigated into this task, and if there is a relatively straightforward way around it, using either the open source GEOBIA libraries or proprietary software? GDAL / RSGISlib / ArcMap doesn't seem to support it.

Thanks!


--
You received this message because you are subscribed to the Google Groups "RSGISLib Support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rsgislib-support+unsubscribe@googlegroups.com.
To post to this group, send email to rsgislib-support@googlegroups.com.

Daniel Clewley

unread,
Jul 15, 2014, 1:01:16 PM7/15/14
to Alexandra Mates, rsgislib...@googlegroups.com
Hi Alex,

I've created an issue about exporting the object ID when exporting to ASCII. Will add when I get chance.

You can just add a column to the ASCII file with the object ID, they're sequential and start at 0.

Thanks,

Dan

To unsubscribe from this group and stop receiving emails from it, send an email to rsgislib-suppo...@googlegroups.com.
To post to this group, send email to rsgislib...@googlegroups.com.

David Trethewey

unread,
Jul 19, 2014, 9:11:12 AM7/19/14
to rsgislib...@googlegroups.com
Is that sequential starting at 0 with the column headers or starting at
0 with the actual data? I have written a script to add the object IDs in
to my RATs but it may be off by 1.

Do you know of a handy automated way of doing the join in a script
fashion, and saving the columns into the vector polygon file itself? I
have a number of vector polygon files now from applying RSGISlib to
Martian images, topography and derived topographic layers.

regards,
David Trethewey


On 15.07.14 18:01, Daniel Clewley wrote:
> Hi Alex,
>
> I've created an issue about exporting the object ID when exporting to
> ASCII. Will add when I get chance.
>
> You can just add a column to the ASCII file with the object ID, they're
> sequential and start at 0.
>
> Thanks,
>
> Dan
>
> On 15 Jul 2014, at 17:48, Alexandra Mates <alexand...@envsys.co.uk
> <mailto:alexand...@envsys.co.uk>> wrote:
>
>> Thanks Dan, it works well for exporting a given column, apart from the
>> fact that it doesn't export the FID column which is I believe
>> necessary for the join, and I don't know how to refer to it. I tried
>> 'FID', 'OBJECTID', '', 'DN'.
>>
>>
>>
>> On Monday, 14 July 2014 17:07:27 UTC+1, Dan Clewley wrote:
>>
>> Hi Alex,
>>
>> I'd do something like the following:
>>
>> 1) Use gdal_polygonize to convert to a vector (attributed with
>> object ID).
>> 2) Export the columns you want from the RAT to and ASCII file
>> using rastergis.export2Ascii
>> 3) Join attribute table from the polygons with the ASCII file
>> using QGIS or ArcMap
>>
>> As for smoothing the polygons I'm not sure the best way to go
>> about this.
>>
>> Thanks,
>>
>> Dan
>>
>> On 14 Jul 2014, at 16:41, Alexandra Mates
>> <alexand...@envsys.co.uk
>> <mailto:alexand...@envsys.co.uk>> wrote:
>>
>>> I have a kea file with a RAT that I'd like to convert into a
>>> smoothed polygon shapefile, maintaining the attribute table. I
>>> was wondering whether anyone has already investigated into this
>>> task, and if there is a relatively straightforward way around it,
>>> using either the open source GEOBIA libraries or proprietary
>>> software? GDAL / RSGISlib / ArcMap doesn't seem to support it.
>>>
>>> Thanks!
>>>
>>> <http://rspsoc2014.co.uk/>
>>> *RSPSoc 2014 - 2nd -5th September <http://rspsoc2014.co.uk/>*
>>>
>>> --
>>> You received this message because you are subscribed to the
>>> Google Groups "RSGISLib Support" group.
>>> To unsubscribe from this group and stop receiving emails from it,
>>> send an email to rsgislib-suppo...@googlegroups.com
>>> <mailto:rsgislib-suppo...@googlegroups.com>.
>>> To post to this group, send email
>>> to rsgislib...@googlegroups.com
>>> <mailto:rsgislib...@googlegroups.com>.
>>> <http://groups.google.com/group/rsgislib-support>.
>>> For more options, visit https://groups.google.com/d/optout
>>> <https://groups.google.com/d/optout>.
>>
>>
>> <http://rspsoc2014.co.uk/>
>> *RSPSoc 2014 - 2nd -5th September <http://rspsoc2014.co.uk/>*
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "RSGISLib Support" group.
>> To unsubscribe from this group and stop receiving emails from it, send
>> an email to rsgislib-suppo...@googlegroups.com
>> <mailto:rsgislib-suppo...@googlegroups.com>.
>> To post to this group, send email to rsgislib...@googlegroups.com
>> <mailto:rsgislib...@googlegroups.com>.
>> Visit this group at http://groups.google.com/group/rsgislib-support.
>> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google
> Groups "RSGISLib Support" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to rsgislib-suppo...@googlegroups.com
> <mailto:rsgislib-suppo...@googlegroups.com>.
> To post to this group, send email to rsgislib...@googlegroups.com
> <mailto:rsgislib...@googlegroups.com>.

Daniel Clewley

unread,
Jul 19, 2014, 12:42:55 PM7/19/14
to David Trethewey, rsgislib...@googlegroups.com
Hi David,

The data starts at 0.

I've updated RSGISLib so the latest version (2.2.902) writes out the object ID (I've updated the conda Linux build).

As for a script to automate joining you could try writing something using the OGR Python bindings. If you're storing the vectors as spatiallite / PostGIS you might be able to write something to add to the attribute table using SQL syntax.

Thanks,

Dan
> To unsubscribe from this group and stop receiving emails from it, send an email to rsgislib-suppo...@googlegroups.com.
> To post to this group, send an email to rsgislib...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages