[mapserver-users] [ASK] Merge polygon from multiple source files

lars.schylberg at blixtmail.se lars.schylberg at blixtmail.se
Fri Sep 18 15:18:25 PDT 2015


There is actually two ways to do this with Mapserver:

You could join them with a ogrtindex.  Then You are not actually merging the polygons but that doesn't matter 
since You will only display the polygon and not the outline.

To do the ogrtindex You will do something like this with a bash script

#/bin/sh
#
# make an ogr index file for mapserver for the S57 data
# this example shows how to do chart level 2 and DEPARE layer
DIR=.
CL=2
IFS=$'\n' read -r -d "" -a files <<< "$(find "$DIR" -name "??${CL}*.000" -type f)"
ogrtindex -lname DEPARE Chartindex_${CL}_depare.shp ${files[@]}
--------------------------------------------------------------------------------------------------------

To display in mapserver:

LAYER
    NAME DEPARE_2
    TYPE POLYGON
    CONNECTIONTYPE OGR
    TILEINDEX "Chartindex_2_depare.shp"
    TILEITEM "Location"
    STATUS ON
    CLASS
        NAME "<= 0"
        EXPRESSION ([DRVAL2] <= 0)
        STYLE
          COLOR 155 200 163
        END
    END
    CLASS
        NAME "0-10"
        EXPRESSION (([DRVAL2]> 0) AND ([DRVAL2] < 10))
        STYLE
          COLOR 145 202 243
        END
    END
    CLASS
        NAME "10-20"
        EXPRESSION (([DRVAL2] >= 10) AND ([DRVAL2] < 20))
        STYLE
          COLOR 180 218 247
        END
    END
    CLASS
        NAME "Deep water > 20"
        EXPRESSION (([DRVAL2] >= 20) AND ([DRVAL2] < 30))
        STYLE
          COLOR 210 234 231
        END
    END
    CLASS
        NAME "Deep water > 30"
        EXPRESSION ([DRVAL2] >= 30)
        STYLE
          COLOR 234 255 243
        END
    END
END # Layer

The second option to really join the depare areas is to run ogr2ogr two or three times.
(all this should of course be scripted)

First: ogr2ogr to convert all S57 DEPARE layers to shape (or sqlite ) - one by one
Second step: merge all shape files with ogr2ogr (make a loop and merge one by one)
Third step: join the polygons with a vrt file:

Something like this (file called "depare_join.vrt"):

 <OGRVRTDataSource>
   <OGRVRTLayer name='DEPARE_VRT'>
   <SrcDataSource relativeToVRT='1' shared='1'>./combined_2_depare.shp</SrcDataSource>
     <SrcSQL dialect='sqlite'>
       SELECT ST_union(geometry), DRVAL1, DRVAL2 
       FROM DEPARE group by DRVAL1
     </SrcSQL>
   </OGRVRTLayer>
</OGRVRTDataSource>

The third step could be used both with ogr2ogr or directly with Mapserver

In Mapserver it would look something like this when using the vrt file directly:

LAYER
  NAME DEPARE_2
  TYPE POLYGON
  CONNECTIONTYPE OGR
  CONNECTION './depare_join.vrt'
  DATA DEPARE_VRT

The rest is the same in the Mapserver layer

I haven't found a good way to combine ogrtindex with vrt:s 

Have fun /Lars S.


-----Originalmeddelande-----
Från: "Milis Inpo" <milis.inpo at gmail.com>
Till: mapserver-users at lists.osgeo.org
Datum: 2015-09-12 19:52
Ämne: [mapserver-users] [ASK] Merge polygon from multiple source files

Hi,

I would like to find a way to merge polygon from multiple source files. I have one set of ENC S57 files which contains 13 files. I would like to extract the DEPARE layer from each file and merge it with other polygon if it is side by side and has same depth value.


Is there anyway for me to do that in Mapserver ?
TIA




Best Regards,


Tenlee

_______________________________________________
mapserver-users mailing list
mapserver-users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users

-- 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20150919/e6655769/attachment.html>


More information about the mapserver-users mailing list