Thread: pgsql2shp usage

pgsql2shp usage

From
Anisha Kaul
Date:
Hello to all,

I downloaded an OSM map file namely "india.osm.bz2".
I transported it in PostgreSQL database "gis" with the command :

./osm2pgsql -m -d gis india.osm.bz2

The above command resulted in the creation of the following tables filled with data in database "gis"

gis=# \d
                 List of relations
 Schema |        Name        |   Type   |  Owner
--------+--------------------+----------+----------
 public | geometry_columns   | table    | anisha
 public | planet_osm_line    | table    | anisha
 public | planet_osm_point   | table    | anisha
 public | planet_osm_polygon | table    | anisha
 public | planet_osm_roads   | table    | anisha
 public | polygon_oid_seq    | sequence | postgres
 public | spatial_ref_sys    | table    | anisha

Now to convert the map data of one of the above tables in a shape file, I issued the following command:

pgsql2shp -f myfile gis planet_osm_line

Output:
Initializing... Warning, field addr:housenumber renamed to ADDR:HOUSE
Warning, field addr:interpolation renamed to ADDR:INTER
Warning, field admin_level renamed to ADMIN_LEVE
Warning, field construction renamed to CONSTRUCTI
Warning, field power_source renamed to POWER_SOUR
Done (postgis major version: 1).
Output shape: PolyLine
Dumping:

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

[126149 rows].

Question :
_______________________________________________________________________________________
How should I verify that the shape file resultant of the above command is a valid and uncorrupted one ?
_______________________________________________________________________________________

I am worried because the projection file namely "myfile.prj" contains the following !

PROJCS["WGS84 / Simple Mercator",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS_1984", 6378137.0,
298.257223563]],PRIMEM["Greenwich", 0.0],UNIT["degree", 0.017453292519943295],AXIS["Longitude",
EAST],AXIS["Latitude", NORTH]],PROJECTION["Mercator_1SP_Google"],PARAMETER["latitude_of_origin",
0.0],PARAMETER["central_meridian", 0.0],PARAMETER["scale_factor", 1.0],PARAMETER["false_easting",
0.0],PARAMETER["false_northing", 0.0],UNIT["m", 1.0],AXIS["x", EAST],AXIS["y", NORTH],AUTHORITY["EPSG","900913"]]

The latitude/longitude values don't seem to be of India !!!!

Thanking you in anticipation,

Regards,
Anisha Kaul

-------------------------------------
Hi-Tech Gears Limited, Gurgaon, India





Re: pgsql2shp usage

From
"Randall Thompson"
Date:
The Attribute Tables for a shape file is stored in .DBF format which has a restriction that field names are only ten characters long, so the warnings are simply informing you that those field names that are longer than 10 characters are being truncated.  The projection definition indicates that the output spatial reference system (900913) is a variation of the Mercator projection which is used by Google Maps, Bing Maps, and other web map services.  So, these are not lat/long coordinates.

Randall Thompson
Castle Rock GIS

Randall.Thompson@CastleRockGIS.com


==================================================================================
Hello to all,

I downloaded an OSM map file namely "india.osm.bz2".
I transported it in PostgreSQL database "gis" with the command :

./osm2pgsql -m -d gis india.osm.bz2

The above command resulted in the creation of the following tables filled with data in database "gis"

gis=# \d
List of relations
Schema | Name | Type | Owner
--------+--------------------+----------+----------
public | geometry_columns | table | anisha
public | planet_osm_line | table | anisha
public | planet_osm_point | table | anisha
public | planet_osm_polygon | table | anisha
public | planet_osm_roads | table | anisha
public | polygon_oid_seq | sequence | postgres
public | spatial_ref_sys | table | anisha

Now to convert the map data of one of the above tables in a shape file, I issued the following command:

pgsql2shp -f myfile gis planet_osm_line

Output:
Initializing... Warning, field addr:housenumber renamed to ADDR:HOUSE
Warning, field addr:interpolation renamed to ADDR:INTER
Warning, field admin_level renamed to ADMIN_LEVE
Warning, field construction renamed to CONSTRUCTI
Warning, field power_source renamed to POWER_SOUR
Done (postgis major version: 1).
Output shape: PolyLine
Dumping:
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX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XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
[126149 rows].

Question :
_______________________________________________________________________________________
How should I verify that the shape file resultant of the above command is a valid and uncorrupted one ?
_______________________________________________________________________________________

I am worried because the projection file namely "myfile.prj" contains the following !

PROJCS["WGS84 / Simple Mercator",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS_1984", 6378137.0,
298.257223563]],PRIMEM["Greenwich", 0.0],UNIT["degree", 0.017453292519943295],AXIS["Longitude",
EAST],AXIS["Latitude", NORTH]],PROJECTION["Mercator_1SP_Google"],PARAMETER["latitude_of_origin",
0.0],PARAMETER["central_meridian", 0.0],PARAMETER["scale_factor", 1.0],PARAMETER["false_easting",
0.0],PARAMETER["false_northing", 0.0],UNIT["m", 1.0],AXIS["x", EAST],AXIS["y", NORTH],AUTHORITY["EPSG","900913"]]

The latitude/longitude values don't seem to be of India !!!!

Thanking you in anticipation,

Regards,
Anisha Kaul

-------------------------------------
Hi-Tech Gears Limited, Gurgaon, India

Re: pgsql2shp usage

From
Anisha Kaul
Date:
On Saturday 09 January 2010 19:03:59 Randall Thompson wrote:
> The Attribute Tables for a shape file are stored in .DBF format which has a
> restriction that field names are only ten characters long, so the warnings
> are simply informing you that those field names that are longer than 10
> characters are being truncated.  The projection definition indicates that
> the output spatial reference system (900913) is a variation of the Mercator
> projection which is used by Google Maps, Bing Maps, and other web map
> services.  So, these are not lat/long coordinates.
>
> Randall Thompson
> Castle Rock GIS
>
> ----------------------------------------

Many thanks to you for bothering to reply !

As you said that they are not the latitude/longitude coordinates, please guide me, if you can, that where should
I get the information regarding the projections w.r.t map of india stored in the shape file ?

--
Regards,
Anisha Kaul

-------------------------------------
Hi-Tech Gears Limited, Gurgaon, India