[Qgis-user] batch shapefile reproject?

Nick Ves vesnikos at gmail.com
Sat May 19 16:06:59 PDT 2012


I think that macos have their native bash interpreter (aka the TERMINAL).

if so a simple

for file in `ls *.shp` ; do ogr2ogr <ogr2ogr-commands> $file; done


should do the trick. Just run it from the terminal inside the folder you
have your shapes, or write it down to a file, make it executable (chmod +x
the-script.sh) and run it (double click?)
 The above might need some fine-tuning thats the general idea :)

happy scripting

Nick Ves

On Sat, May 19, 2012 at 11:53 AM, gvSIGMac <gvsig.mac at gmail.com> wrote:

> If you got Qgis from
> www.kyngchaos.com
> you already have ogr2ogr in your system thru gdal
> http://www.kyngchaos.com/software/frameworks
> You only need to set your path or run
> /Library/Frameworks/GDAL.framework/Versions/Current/Programs/ogr2ogr
> ________________________________
> Agustin
>
> On 18/05/2012, at 20:23, Chris Henrick <chrishenrick at gmail.com> wrote:
>
> Thanks for the pointer David, I appreciate it.
>
> I'm using QGIS 1.7.4 on Mac OSX 10.6.8, so I can run ogr2ogr in linux. I'm
> not too familiar with running code in terminal, but a friend recomended
> installing home brew and xcode first. Do you know of any helpful tutorials
> to help a newby get started with running open source command line code?
>
> regards,
>
> -Chris
>
>
> On Fri, May 18, 2012 at 11:12 AM, David J. Bakeman <dbakeman at comcast.net>wrote:
>
>> **
>> Chris Henrick wrote:
>>
>> Hi there,
>>
>>  Does anyone have a python script or know of a 3rd party plug in that
>> will allow a directory of shapefiles to be reprojected into a specified
>> CRS? Would also be helpful to do the same with the clip tool
>>
>> You didn't say what OS so your mileage may vary.  For this kind of
>> operation I would use the ogr2ogr application from the gdal utilities.  I
>> believe if you're using the windows osgeo install that it is installed if
>> you're using linux it's a matter of installing gdal which if you have qgis
>> it's probably already there.
>>
>> So to reproject a bunch of shapefiles the source files in d0 and the
>> destination in d1:
>>
>> ogr2ogr -t_srs (specify the target CRS you can use proj4 string or an
>> existing .prj file) d1 d0
>>
>> The default type for ogr2ogr is shapefile so you don't need to specify a
>> type even.  ogr2ogr also does other operations including clipping.
>>
>>
>>  I'm a fairly novice programmer so any advice would be appreciated.
>>
>>  thanks,
>>
>> -Chris
>>
>>
>> _______________________________________________
>> Qgis-user mailing listQgis-user at lists.osgeo.orghttp://lists.osgeo.org/mailman/listinfo/qgis-user
>>
>>
>>
> _______________________________________________
> Qgis-user mailing list
> Qgis-user at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-user
>
>
> _______________________________________________
> Qgis-user mailing list
> Qgis-user at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-user
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20120520/9a6c70a7/attachment.html>


More information about the Qgis-user mailing list