Hi, It is also possible to sort the shapefile with ogr2ogr. Out of my head it goes like:
ogr2ogr -f "ESRI Shapefile" -sql "select * from unsorted order by sort_item" sorted.shp unsorted.shp Syntax it not necessarily exactly right but sorting works and I am using it regularly for sorting Mapserver tileindex shapefiles. Mapserver draws the last feature in the shapefile last and by sorting image tiles by year I can guarantee that most fresh image will be on top if images overlap. -Jukka Rahkonen- -----Alkuperäinen viesti----- Lähettäjä: [email protected] puolesta: Nicolas Gillet Lähetetty: ti 15.12.2009 18:05 Vastaanottaja: [email protected] Aihe: [Mapnik-users] Tip : Sorting data in a Shape file 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. _______________________________________________ Mapnik-users mailing list [email protected] https://lists.berlios.de/mailman/listinfo/mapnik-users _______________________________________________ Mapnik-users mailing list [email protected] https://lists.berlios.de/mailman/listinfo/mapnik-users

