[OSGeo-Discuss] Call for help: GDAL and txt2shp.py

Dane Springmeyer blake at hailmail.net
Mon Jul 7 10:19:06 PDT 2008


Hi Kjell,

> Not having worked much with GIS systems or projection/coordinate  
> systems before, I am struggling to understand the meaning of all  
> this. However, the following (esriwkt) was the result of the visit  
> to the link above, and I am injected it into the .prj file before  
> running the script all over again:

You are not alone. Projected coordinate systems can confuse beginners  
and experts alike.

My understanding is that you have gps data and you are not sure what  
coordinate system it is in. You ran Matt Perry's script to convert the  
text-based coordinates into a shapefile format, but you still need to  
assign a coordinate system.

>  However, the following (esriwkt) was the result of the visit to the  
> link above, and I am injected it into the .prj file before running  
> the script all over again:
> PROJCS["Nahrwan 1967 / UTM zone 39N",GEOGCS["Nahrwan  
> 1967",DATUM["D_Nahrwan_1967",SPHEROID["Clarke_1880_RGS", 
> 6378249.145,293.465]],PRIMEM["Greenwich",0],UNIT["Degree", 
> 0.017453292519943295 
> ]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin", 
> 0],PARAMETER["central_meridian",51],PARAMETER["scale_factor", 
> 0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing", 
> 0],UNIT["Meter",1]]
> Please let me know if I got this completely wrong and please excuse  
> my lack of knowledge here.
>

First, you only need to assign the projection AFTER you run the  
txt2shp.py script.

Second, I can see now (from your image links) that your data was  
collected in Lebanon, which means that the link I directed you to will  
not provide a reference to the correct UTM zone.

There are two possible UTM zones for Lebanon: UTM 36N or UTM 37N.

WGS 84 / UTM zone 36N
http://spatialreference.org/ref/epsg/32636/

WGS 84 / UTM zone 37N
http://spatialreference.org/ref/epsg/32637/

You can check for yourself by downloading a world borders shapefile (http://thematicmapping.org/downloads/world_borders.php 
) and a world UTM zone shapefile (http://earth-info.nga.mil/GandG/coordsys/gislayers/zips/mgrs6x8.zip 
), both in the WGS 84/EPSG 4326 coordinate system.

If you have more GPS data from other countries I highly recommend  
getting familiar with UTM zones.

>
> It did. Garmin GPSMap 60 CS.
>
> But, still, even with the new projection file, this thing still  
> looks like this:
>
> http://www.ia-stud.hiof.no/~kjellare/misc/gdal_fail3_lebanon.png
>
> I even tried reversing the coordinates in the input file, but with  
> almost the same result:
>
> http://www.ia-stud.hiof.no/~kjellare/misc/gdal_fail3_lebanon2.png
>
> Hm... Not sure how to proceed from here.
>

If you try to load data in different coordinate systems into the same  
QGIS project, QGIS  will not (by default) make an effort to 'reproject- 
on-the-fly' when rendering, unless you explicitly set the Qgis project  
to do so. So even if you assign the correct UTM zone to your points,  
if you open them in Qgis along with a base layer in WGS 84 projection,  
they will not line up. You need to go to SETTINGS > PROJECT PROPERTIES  
 > PROJECTION > ENABLE ON THE FLY PROJECTION.

Or use the command line program ogr2ogr to reproject your shapefile to  
WGS84/EPSG 4326 from your assumed UTM projection. That command would  
look like:

$ ogr2ogr -s_srs EPSG:32636 -t_srs EPSG:4326 lebanon_points_wgs84.shp  
lebanon_points_utm36N.shp

Then, if the assumed source projection was correct, your new shapefile  
should line up with other data in WGS 84.


>> ...
>> In Qgis you should be able to reproject to UTM and label your  
>> points. Qgis will also export to PNG format if that is what you  
>> want. However I don't think that Qgis will output an ESRI world  
>> file (the only way that I know to keep a PNG spatially reference...  
>> but the application uDIG will output a .wld world file to spatially  
>> reference a PNG).
>
> I am in need of a open source command-line style software here, in  
> order to automate this entire endevour.
> Both uDIG and QGIS appears to be GUI style applications.
> Are there a way around this to let me export the shapefiles I have  
> to a .png raster file to complete my mission?
>
> Kjell Are
>


Yes, they are GUI applications... but don't you just need to automate  
the processing of your GPS data? If you want to create one PNG raster  
then QGIS or uDIG are the ideal tools to layout your png map. Just  
open all your shapefiles (you can even merge them all into one  
shapefile with ogr2ogr), label them, then zoom to each group and  
export a PNG file....

If you truly want to automate the creation of  *many* PNG graphics  
then you'll need to look into scripting a mapping toolkit like  
Mapserver or Mapnik.



Dane



> _______________________________________________
> Discuss mailing list
> Discuss at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/discuss

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/discuss/attachments/20080707/cc1ae960/attachment-0002.html>


More information about the Discuss mailing list