[gdal-dev] loading geometries only into postgis via ogr2ogr using shp file only as input

Chaitanya kumar CH chaitanya.ch at gmail.com
Thu Jun 7 19:54:55 PDT 2012


Karsten,

shapelib used by OGR can handle shapefiles without the dbf files.
However, it uses the shx file to build the index. It may be possible to
build the index by reading the shp file, but it needs non-trivial changes
to the shapelib.

On Fri, Jun 8, 2012 at 5:13 AM, karsten <karsten at terragis.net> wrote:

> **
>  ****Hi All,
>
> I posted the question below in the PostGIS email and local CUGOS email
> lists and got some good input. **
> **Now I wanted to determine how hard it would be to 'hack' the ogr2ogr
> utility program to be able to only load the geometries of a shape file (shp
> file only, without shx and dbf that are usually required) into PostGIS. Thu
> s only the geometry is needed and a unique id, the test that ogr2ogr does if
> shx and dbf are present should be omitted (that is that hack I am talking
> about)
> Any ideas on that if that could be accomplished with by hacking ogr2ogr without
> too much trouble ? Or is there any other utility tool out there to get
> this done preferably without programming :)**
> **
>
> Cheers
> Karsten
> Terra GIS LTD
> www.terragis.net**
> **........................................................................
> .........................................................................
> ..........................................................................
> .........**
> **>>> I am working on a data upload function where for a web map a user
> can upload a shape file onto the server, the file will then be loaded via a
> utility into PostGIS e.g. using ogr2ogr or shp2pgsql.
> Now we all know that usually a shape files has at least 3 files shp, shx
> and dbf to be complete... but unusually - well I was wondering if it would
> be possible to only use a shp file alone to load the geometry to PostGIS
> (if it is ok to loose index and attributes)
>
> The reason is this would have several advantages for the work I am tying
> to do
> 1. the shape file is user provided (if will be always 'simple' polygon
> shapes, but due to that will always have non consistent attributes (i.e not
> the same table schema) which are not needed anyway for the purposes of the
> app
> 2. the geometry alone will be used to show areas of Interest for the user
> on the map (attributes are not needed, only location and extent matters)
> 3. inconsistencies of differing attributes will not be a problem if I
> could in fact only import the geometry to PostGIS and simply add a unique
> gid and user id as only default attributes to the PostGIS table
> 4. another advantage would be that only the single shp file alone would
> need to be uploaded to the server :) >>>>
> .........................................................................
> .........................................
> **
>
>
>
>
>
> =======
> Email scanned by PC Tools - No viruses or spyware found.
> (Email Guard: 9.0.0.888, Virus/Spyware Database: 6.19840)
> http://www.pctools.com<http://www.pctools.com/?cclick=EmailFooterClean_51>
> =======
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>



-- 
Best regards,
Chaitanya kumar CH.

+91-9494447584
17.2416N 80.1426E
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20120608/71b6924f/attachment.html>


More information about the gdal-dev mailing list