[postgis-users] pgsql2shp usage

Paragon Corporation lr at pcorp.us
Sat Jan 9 12:42:24 PST 2010


Anish,

Question 1
The warnings.  That's because esri shape file format is dbf which only
allows 10 characters for a field name.  So the warning is telling you its
truncating the names so they are within 10 characters.  Your field names in
the dbf will be slightly different is all

Question 2
Never worked with osm data, but since I created the .prj generator in
pgsql2shp, I can tell you it reads the srid of the geometry and looks up the

srtext in spatial ref and outputs that to the .prj file.

I suspect osm data is in Mercator not long lat.  If you want your output to
be in long lat, you need to transform and use an sql statement

pgsql2shp -f "/path/to/filename" -h myserver -u apguser -P apgpassword
mygisdb 
	"SELECT field1 AS hs_num, field2...., ST_Transform(the_geom,4326) As
the_geom FROM planet_osm_line"


Or you can create a view with a transformed geometry.  

Using an SQL statement or a view will also allow you to control how the
fields are renamed since you can alias them as names less than 10
characters,


Hope that helps,
Regina  

-----Original Message-----
From: postgis-users-bounces at postgis.refractions.net
[mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of Anisha
Kaul
Sent: Saturday, January 09, 2010 7:37 AM
To: postgis-users at postgis.refractions.net
Subject: [postgis-users] pgsql2shp usage

Hello to all,

I hope this is the right mailing lists w.r.t pgsql2shp.

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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XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XX
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
[126149 rows].

Questions :
____________________________________________________________________________
___________
Are these the right steps to load an OSM file in postgres ?
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 !!!!

Kindly help !!
Thanking you in anticipation,

Regards,
Anisha Kaul

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




_______________________________________________
postgis-users mailing list
postgis-users at postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users






More information about the postgis-users mailing list