Linux/Cygwin shell scripts for simplifying admin layers

I am working on scripts to import shapefiles to PostGIS, simplify them, and export to GeoJSON using Geoserver:

http://www.openhealthconsortium.org/wiki/doku.php?id=importing_to_ohm

Any reason you would not do this with GDAL (ogr2ogr) directly?

···

On 12/15/09, Knut Staring <knutst@gmail.com> wrote:

I am working on scripts to import shapefiles to PostGIS, simplify them, and
export to GeoJSON using Geoserver:

http://www.openhealthconsortium.org/wiki/doku.php?id=importing_to_ohm

Any reason you would not do this with GDAL (ogr2ogr) directly?

Maybe lack of knowledge? Can you enlighten me?

Knut

···

On Tue, Dec 15, 2009 at 11:38 AM, Jason Pickering jason.p.pickering@gmail.com wrote:

On 12/15/09, Knut Staring knutst@gmail.com wrote:

I am working on scripts to import shapefiles to PostGIS, simplify them, and

export to GeoJSON using Geoserver:

http://www.openhealthconsortium.org/wiki/doku.php?id=importing_to_ohm


Cheers,
Knut Staring

Hi Knut,

This procedure has already been described briefly in the GIS user
manual. Take a look there for a start, included below for your
convenience.

"1.1.2. Production of GeoJSON files with GDAL

GDAL is a multi-platform toolkit for the manipulation of geographical
data. It is freely available for a wide-range of platforms at
http://gdal.org

Production of GeoJSON files are straightforward with GDAL. Just
execute (on Windows)

ogr2ogr.exe -f "GeoJSON" dst_datasource_name src_datasource_name

or on Linux

ogr2ogr -f "GeoJSON"dst_datasource_name src_datasource_name

Replace dst_datasource_name with the path to the destination
geographical data file (following the naming convention described
above) and src_datasource_name with the source geographical data file.
Take note that you may need to specify input and output coordinate
systems as described above. "

Also, FME will do this job very nicely.

Regards,
Jason

···

On 12/15/09, Knut Staring <knutst@gmail.com> wrote:

On Tue, Dec 15, 2009 at 11:38 AM, Jason Pickering < > jason.p.pickering@gmail.com> wrote:

Any reason you would not do this with GDAL (ogr2ogr) directly?

Maybe lack of knowledge? Can you enlighten me?

Knut

On 12/15/09, Knut Staring <knutst@gmail.com> wrote:
> I am working on scripts to import shapefiles to PostGIS, simplify them,
and
> export to GeoJSON using Geoserver:
>
> http://www.openhealthconsortium.org/wiki/doku.php?id=importing_to_ohm
>

--
Cheers,
Knut Staring

Thanks, this is helpful, I should indeed have read the GIS user manual, was not aware that you had put this in there, and also somehow had the mistaken impression ogr did not output geojson.

Do you also have a solution for the simplification/generalization without going via postgis and geoserver?

I suppose I could do shp2pgsql -> simplify -> pgsql2shp -> ogr2ogr -> geojson (thus eliminating the need for Geoserver).

As for FME, I have not looked at how to include it in scripts (and we only have one license for it).

Knut

Hi Knut,

This procedure has already been described briefly in the GIS user

manual. Take a look there for a start, included below for your

convenience.

"1.1.2. Production of GeoJSON files with GDAL

GDAL is a multi-platform toolkit for the manipulation of geographical

data. It is freely available for a wide-range of platforms at

http://gdal.org

Production of GeoJSON files are straightforward with GDAL. Just

execute (on Windows)

ogr2ogr.exe -f “GeoJSON” dst_datasource_name src_datasource_name

or on Linux

ogr2ogr -f "GeoJSON"dst_datasource_name src_datasource_name

Replace dst_datasource_name with the path to the destination

geographical data file (following the naming convention described

above) and src_datasource_name with the source geographical data file.

Take note that you may need to specify input and output coordinate

systems as described above. "

Can this be extended to include the generalization algorithm?

Also, FME will do this job very nicely.

True of course, but

···

On Tue, Dec 15, 2009 at 11:54 AM, Jason Pickering jason.p.pickering@gmail.com wrote:

Regards,

Jason

On 12/15/09, Knut Staring knutst@gmail.com wrote:

On Tue, Dec 15, 2009 at 11:38 AM, Jason Pickering < > > > jason.p.pickering@gmail.com> wrote:

Any reason you would not do this with GDAL (ogr2ogr) directly?

Maybe lack of knowledge? Can you enlighten me?

Knut

On 12/15/09, Knut Staring knutst@gmail.com wrote:

I am working on scripts to import shapefiles to PostGIS, simplify them,

and

export to GeoJSON using Geoserver:

http://www.openhealthconsortium.org/wiki/doku.php?id=importing_to_ohm

Cheers,

Knut Staring


Cheers,
Knut Staring

Hi Knut,
I think using Postgis would be the easiest way. I am not aware of how
ogr2ogr can do simplification but perhaps.

You can also use ogr2ogr for injection of shape files into Postgres,
instead of shp2pgsql.
Likewise, you can extract Postgis data out of Postgis with ogr2ogr.
With a carefully constructed SQL query, you might be able to do
everything in a single command similar to this
http://lists.maptools.org/pipermail/fwtools/2007-April/000750.html

I suppose I could do shp2pgsql -> simplify -> pgsql2shp -> ogr2ogr ->
geojson (thus eliminating the need for Geoserver).

As for FME, I have not looked at how to include it in scripts (and we only
have one license for it).

True. I was thinking maybe if you were going to do a one off
conversion, FME would be a good choice. However, for something to
distribute, ogr2ogr combined with Postgis should be able to do this
task .

Regards,
Jason

···

Knut
On Tue, Dec 15, 2009 at 11:54 AM, Jason Pickering > <jason.p.pickering@gmail.com> wrote:

Hi Knut,

This procedure has already been described briefly in the GIS user
manual. Take a look there for a start, included below for your
convenience.

"1.1.2. Production of GeoJSON files with GDAL

GDAL is a multi-platform toolkit for the manipulation of geographical
data. It is freely available for a wide-range of platforms at
http://gdal.org

Production of GeoJSON files are straightforward with GDAL. Just
execute (on Windows)

ogr2ogr.exe -f "GeoJSON" dst_datasource_name src_datasource_name

or on Linux

ogr2ogr -f "GeoJSON"dst_datasource_name src_datasource_name

Replace dst_datasource_name with the path to the destination
geographical data file (following the naming convention described
above) and src_datasource_name with the source geographical data file.
Take note that you may need to specify input and output coordinate
systems as described above. "

Can this be extended to include the generalization algorithm?

Also, FME will do this job very nicely.

True of course, but

Regards,
Jason

On 12/15/09, Knut Staring <knutst@gmail.com> wrote:
> On Tue, Dec 15, 2009 at 11:38 AM, Jason Pickering < >> > jason.p.pickering@gmail.com> wrote:
>
>> Any reason you would not do this with GDAL (ogr2ogr) directly?
>
>
> Maybe lack of knowledge? Can you enlighten me?
>
> Knut
>
>
>>
>>
>> On 12/15/09, Knut Staring <knutst@gmail.com> wrote:
>> > I am working on scripts to import shapefiles to PostGIS, simplify
>> > them,
>> and
>> > export to GeoJSON using Geoserver:
>> >
>> > http://www.openhealthconsortium.org/wiki/doku.php?id=importing_to_ohm
>> >
>>
>
>
>
> --
> Cheers,
> Knut Staring
>

--
Cheers,
Knut Staring