[Mapnik-users] Tip : Sorting data in a Shape file

Nicolas Gillet nicolas.gillet at market-ip.com
Tue Dec 15 17:05:02 CET 2009


Hello.

In order to have things drawn the right way, its often necessary to sort
data.
For the application dealing directly with Postgis/Postgres an "ORDER BY"
clause does the trick but for shape files it isn't that simple.

After a few trial with pgsql2shp I finally found that the output file will
always be sorted on the "gid" column when it's present and do not care about
any "order by" you could set.
In order to avoid this sorting you have to avoid this column.

An example :
pgsql2shp -r -f "C:\temp\nw" -h %host% -P %pass% -u %user% %db% -g true_geom
"SELECT id, feattyp, frc, net2class, fow, oneway, lvl, shieldnum,
ST_Transform(the_geom, 900913) as true_geom FROM neo_nw ORDER BY lvl, FRC
DESC"
-> this one will respect my "order by" clause

pgsql2shp -r -f "C:\temp\nw" -h %host% -P %pass% -u %user% %db% -g true_geom
"SELECT gid, id, feattyp, frc, net2class, fow, oneway, lvl, shieldnum,
ST_Transform(the_geom, 900913) as true_geom FROM neo_nw ORDER BY lvl, FRC
DESC"
-> this one won't respect my "order by" clause (because gid is in the column
list and overrules my "order by").

Nicolas
Gillet

-- 
View this message in context: http://old.nabble.com/Tip-%3A-Sorting-data-in-a-Shape-file-tp26796227p26796227.html
Sent from the Mapnik - Users mailing list archive at Nabble.com.




More information about the Mapnik-users mailing list