[Qgis-user] Fwd: create a shapefile tile index from a boundingbox list

maning sambale emmanuel.sambale at gmail.com
Mon Dec 7 01:54:21 PST 2009


I am forwarding this to the list in case others have a similar
problem.  Big thanks to Hermann Peifer for sharing.


You could save the below script code as tindex.awk and run the command
as follows:

awk -f tindex.awk yourfile.csv > index.gmt

... followed by

ogr2ogr index.shp index.gmt


Hope this helps, Hermann


$ cat tindex.awk
# Script to generate tile index, based on CSV data
# Usage: awk -f <script.awk> datafile.csv
# Hermann, December 2009

BEGIN{

      # Field separator
      FS = ","

      # Header rows of GMT file
      print "# @VGMT1.0 @GPOLYGON"
      print "# @Jp\"+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs\""
      print "# @NCellCode"
      print "# @Tstring"
      print "# FEATURE_DATA"
}

# Create 1 polygon per record
{
      # Bounding box, adjust as needed
      W = $2
      S = $3
      E = $4
      N = $5

      # Print header rows for feature
      print ">"
      print "# @D\"" $1 "\""
      print "# @P"

      # Print the box
      print W, S
      print W, N
      print E, N
      print E, S
      print W, S
}



-------- Original Message  --------
Subject: create a shapefile tile index from a boundingbox list
From: maning sambale <emmanuel.sambale at gmail.com>
To: Hermann Peifer <peifer at gmx.eu>
Date: 04/12/2009 00:04

> please, please send me the script.  thanks!
>
> On Thu, Dec 3, 2009 at 7:43 PM, Hermann Peifer <peifer at gmx.eu> wrote:
>>
>> maning sambale wrote:
>>>
>>> Thanks Alex!
>>>
>>> On Thu, Dec 3, 2009 at 5:08 PM, Alex Mandel
>>> <tech_dev-V1ui0Jp4Xm2ZwHVy+eqOOgC/G2K4zDHf at public.gmane.org> wrote:
>>>>
>>>> maning sambale wrote:
>>>>>
>>>>> Hi,
>>>>>
>>>>> I have a csv file containing a list of topographic maps with bounding
>>>>> box coordinates like this:
>>>>> sheet no, upper left coordinates (lon/lat), lower left coordinates
>>>>> (lon/lat), lower right coordinates (lon/lat), upper right coordinates
>>>>> (lon/lat)
>>>>> 3631-I,7,121.5,7,122,6.5,121.5,6.5,121.5
>>>>>
>>>>> I want to convert the text file into a shapefile polygon box.  In the
>>>>> past I used delimited text plugin converting the four corners as
>>>>> separate records.  Then digitize a polygon (snapping to the point).
>>>>> Any other way to do this in QGIS?
>>
>> I have a 5-line awk script for converting corner coordinates into a GMT
>> format, which can then be translated into a shapefile, with ogr2ogr.
>>
>> Drop me a line if you are interested.
>>
>> Hermann
>>
>>
>
>
>



-- 
cheers,
maning
------------------------------------------------------
"Freedom is still the most radical idea of all" -N.Branden
wiki: http://esambale.wikispaces.com/
blog: http://epsg4253.wordpress.com/
------------------------------------------------------



More information about the Qgis-user mailing list